Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DependencyContext splitting on semi-colon #87518

Merged
merged 3 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ internal sealed class DependencyContextPaths
private const string DepsFilesProperty = "APP_CONTEXT_DEPS_FILES";
private const string FxDepsFileProperty = "FX_DEPS_FILE";

private static readonly char[] s_semicolon = new[] { ';' };
eerhardt marked this conversation as resolved.
Show resolved Hide resolved

public static DependencyContextPaths Current { get; } = GetCurrent();

public string? Application { get; }
Expand All @@ -20,8 +22,6 @@ internal sealed class DependencyContextPaths

public IEnumerable<string> NonApplicationPaths { get; }

private static readonly char[] s_semicolon = new[] { ';' };

public DependencyContextPaths(
string? application,
string? sharedRuntime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ public void MergeMergesRuntimeGraph()
Subject.Fallbacks.Should().BeEquivalentTo("win7-x64", "win7-x86");
}

[Fact]
public void DefaultWorksCorrectly()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt this also fails on NativeAOT on runtime-extra-platforms:

Assert.NotNull() Failure

Stack trace
   at Microsoft.Extensions.DependencyModel.Tests.DependencyContextTests.DefaultWorksCorrectly() + 0x76
   at Microsoft.Extensions.DependencyModel.Tests!<BaseAddress>+0x1292ea4
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0xe6

GetEntryAssembly() does work on NativeAOT though

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing in #87666.

{
// only need to assert the context contains non-null properties.

var context = DependencyContext.Default;
Assert.NotNull(context);
Assert.NotNull(context.RuntimeGraph);
Assert.NotNull(context.RuntimeLibraries);
Assert.NotNull(context.Target);
}

private TargetInfo CreateTargetInfo()
{
return new TargetInfo(
Expand Down