From 78e42f789bd14919918074810069e63d5fd1d8d7 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 23 May 2023 00:29:48 +0200 Subject: [PATCH] Rename setting for using RID graph to System.Runtime.Loader.UseRidGraph (#86598) --- .../RidAssetResolution.cs | 86 +++++++++---------- .../hostpolicy/hostpolicy_context.cpp | 2 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/installer/tests/HostActivation.Tests/DependencyResolution/RidAssetResolution.cs b/src/installer/tests/HostActivation.Tests/DependencyResolution/RidAssetResolution.cs index 58e7fc417a8d4..cb924267ca254 100644 --- a/src/installer/tests/HostActivation.Tests/DependencyResolution/RidAssetResolution.cs +++ b/src/installer/tests/HostActivation.Tests/DependencyResolution/RidAssetResolution.cs @@ -13,30 +13,30 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution { public abstract class RidAssetResolutionBase : ComponentDependencyResolutionBase { - private static Version ReadRidGraphDisabledVersion = new Version(8, 0); + private static Version UseRidGraphDisabledVersion = new Version(8, 0); public class TestSetup { // Explicit RID (environment variable) to set when running the test // Value of null indicates unset (default) public string? Rid { get; init; } - // Represents the configuration (System.Host.Resolution.ReadRidGraph) for whether to read the RID graph + // Represents the configuration (System.Runtime.Loader.UseRidGraph) for whether to read the RID graph // Value of null indicates unset (default setting) - public bool? ReadRidGraph { get; init; } + public bool? UseRidGraph { get; init; } // Whether or not the root deps file has a RID graph public bool HasRidGraph { get; init; } // Expected behaviour of the test based on above settings - public bool ShouldReadRidGraph => ReadRidGraph == true; - public bool ShouldUseFallbackRid => ShouldReadRidGraph && (Rid == UnknownRid || !HasRidGraph); + public bool ShouldUseRidGraph => UseRidGraph == true; + public bool ShouldUseFallbackRid => ShouldUseRidGraph && (Rid == UnknownRid || !HasRidGraph); public override string ToString() => $""" {nameof(Rid)}: {(Rid ?? "")} - {nameof(ReadRidGraph)}: {(ReadRidGraph.HasValue ? ReadRidGraph : "")} + {nameof(UseRidGraph)}: {(UseRidGraph.HasValue ? UseRidGraph : "")} {nameof(HasRidGraph)}: {HasRidGraph} [computed] - {nameof(ShouldReadRidGraph)}: {ShouldReadRidGraph} + {nameof(ShouldUseRidGraph)}: {ShouldUseRidGraph} {nameof(ShouldUseFallbackRid)}: {ShouldUseFallbackRid} """; }; @@ -57,7 +57,7 @@ protected abstract void RunTest( protected TestApp UpdateAppConfigForTest(TestApp app, TestSetup setup, bool copyOnUpdate) { - if (!setup.ReadRidGraph.HasValue) + if (!setup.UseRidGraph.HasValue) return app; if (copyOnUpdate) @@ -65,8 +65,8 @@ protected TestApp UpdateAppConfigForTest(TestApp app, TestSetup setup, bool copy RuntimeConfig config = RuntimeConfig.FromFile(app.RuntimeConfigJson); - if (setup.ReadRidGraph.HasValue) - config.WithProperty("System.Host.Resolution.ReadRidGraph", setup.ReadRidGraph.ToString()); + if (setup.UseRidGraph.HasValue) + config.WithProperty("System.Runtime.Loader.UseRidGraph", setup.UseRidGraph.ToString()); config.Save(); @@ -112,7 +112,7 @@ private void RidSpecificAssemblyImpl(TestSetup setup, string includedPath, strin public void RidSpecificAssembly_RidGraph(string rid, string includedPath, string excludedPath) { RidSpecificAssemblyImpl( - new TestSetup() { Rid = rid, HasRidGraph = true, ReadRidGraph = true }, + new TestSetup() { Rid = rid, HasRidGraph = true, UseRidGraph = true }, includedPath, excludedPath); } @@ -132,7 +132,7 @@ public void RidSpecificAssembly_RidGraph(string rid, string includedPath, string [InlineData(UnknownRid, false, true)] [InlineData(UnknownRid, false, false)] [InlineData(UnknownRid, false, null)] - public void RidSpecificAssembly_CurrentRid(string rid, bool hasRuntimeFallbacks, bool? readRidGraph) + public void RidSpecificAssembly_CurrentRid(string rid, bool hasRuntimeFallbacks, bool? useRidGraph) { // When not using the RID graph, the host uses the target OS for which it was built to determine applicable // RIDs that apply, so it can find both the arch-specific and the OS-only assets. @@ -140,14 +140,14 @@ public void RidSpecificAssembly_CurrentRid(string rid, bool hasRuntimeFallbacks, // the current RID, so the OS-only asset remains excluded if there are no fallbacks. string includedPath = null; string excludedPath = $"{LinuxAssembly};{MacOSAssembly};{WindowsAssembly}"; - if (readRidGraph != true || hasRuntimeFallbacks) + if (useRidGraph != true || hasRuntimeFallbacks) { // Host should resolve to the RID corresponding to the platform on which it is running (includedPath, excludedPath) = GetExpectedPathsforCurrentRid(LinuxAssembly, MacOSAssembly, WindowsAssembly); } RidSpecificAssemblyImpl( - new TestSetup() { Rid = rid, HasRidGraph = hasRuntimeFallbacks, ReadRidGraph = readRidGraph }, + new TestSetup() { Rid = rid, HasRidGraph = hasRuntimeFallbacks, UseRidGraph = useRidGraph }, includedPath, excludedPath); } @@ -156,13 +156,13 @@ public void RidSpecificAssembly_CurrentRid(string rid, bool hasRuntimeFallbacks, [InlineData(true)] [InlineData(false)] [InlineData(null)] - public void RidSpecificAssembly_UnknownRid(bool? readRidGraph) + public void RidSpecificAssembly_UnknownRid(bool? useRidGraph) { string assetPath = $"{UnknownRid}/{UnknownRid}Asset"; string includedPath; string excludedPath; - if (readRidGraph == true) + if (useRidGraph == true) { // Host won't resolve the unknown RID asset includedPath = null; @@ -177,7 +177,7 @@ public void RidSpecificAssembly_UnknownRid(bool? readRidGraph) RunTest( p => p.WithAssemblyGroup(UnknownRid, g => g.WithAsset(assetPath)), - new TestSetup() { Rid = UnknownRid, ReadRidGraph = readRidGraph }, + new TestSetup() { Rid = UnknownRid, UseRidGraph = useRidGraph }, new ResolvedPaths() { IncludedAssemblyPaths = includedPath, ExcludedAssemblyPaths = excludedPath }); } @@ -200,7 +200,7 @@ private void RidSpecificNativeLibraryImpl(TestSetup setup, string includedPath, public void RidSpecificNativeLibrary_RidGraph(string rid, string includedPath, string excludedPath) { RidSpecificNativeLibraryImpl( - new TestSetup() { Rid = rid, HasRidGraph = true, ReadRidGraph = true }, + new TestSetup() { Rid = rid, HasRidGraph = true, UseRidGraph = true }, includedPath, excludedPath); } @@ -219,7 +219,7 @@ public void RidSpecificNativeLibrary_RidGraph(string rid, string includedPath, s [InlineData(UnknownRid, false, true)] [InlineData(UnknownRid, false, false)] [InlineData(UnknownRid, false, null)] - public void RidSpecificNativeLibrary_CurrentRid(string rid, bool hasRuntimeFallbacks, bool? readRidGraph) + public void RidSpecificNativeLibrary_CurrentRid(string rid, bool hasRuntimeFallbacks, bool? useRidGraph) { // When not using the RID graph, the host uses the target OS for which it was built to determine applicable // RIDs that apply, so it can find both the arch-specific and the OS-only assets. @@ -227,14 +227,14 @@ public void RidSpecificNativeLibrary_CurrentRid(string rid, bool hasRuntimeFallb // the current RID, so the OS-only asset remains excluded if there are no fallbacks. string includedPath = null; string excludedPath = "linux;osx;win"; - if (readRidGraph != true || hasRuntimeFallbacks) + if (useRidGraph != true || hasRuntimeFallbacks) { // Host should resolve to the RID corresponding to the platform on which it is running (includedPath, excludedPath) = GetExpectedPathsforCurrentRid("linux/", "osx/", "win/"); } RidSpecificNativeLibraryImpl( - new TestSetup() { Rid = rid, HasRidGraph = hasRuntimeFallbacks, ReadRidGraph = readRidGraph }, + new TestSetup() { Rid = rid, HasRidGraph = hasRuntimeFallbacks, UseRidGraph = useRidGraph }, includedPath, excludedPath); } @@ -243,13 +243,13 @@ public void RidSpecificNativeLibrary_CurrentRid(string rid, bool hasRuntimeFallb [InlineData(true)] [InlineData(false)] [InlineData(null)] - public void RidSpecificNativeLibrary_UnknownRid(bool? readRidGraph) + public void RidSpecificNativeLibrary_UnknownRid(bool? useRidGraph) { string assetPath = $"{UnknownRid}/{UnknownRid}Asset"; string includedPath; string excludedPath; - if (readRidGraph == true) + if (useRidGraph == true) { // Host won't resolve the unknown RID asset includedPath = null; @@ -264,7 +264,7 @@ public void RidSpecificNativeLibrary_UnknownRid(bool? readRidGraph) RunTest( p => p.WithNativeLibraryGroup(UnknownRid, g => g.WithAsset(assetPath)), - new TestSetup() { Rid = UnknownRid, ReadRidGraph = readRidGraph }, + new TestSetup() { Rid = UnknownRid, UseRidGraph = useRidGraph }, new ResolvedPaths() { IncludedNativeLibraryPaths = includedPath, ExcludedNativeLibraryPaths = excludedPath }); } @@ -279,7 +279,7 @@ public void MostSpecificRidAssemblySelected_RidGraph(string rid, string expected .WithAssemblyGroup("any", g => g.WithAsset("any/ManagedAny.dll")) .WithAssemblyGroup("win", g => g.WithAsset("win/ManagedWin.dll")) .WithAssemblyGroup("win-x64", g => g.WithAsset("win-x64/ManagedWin64.dll")), - new TestSetup() { Rid = rid, HasRidGraph = true, ReadRidGraph = true }, + new TestSetup() { Rid = rid, HasRidGraph = true, UseRidGraph = true }, new ResolvedPaths() { IncludedAssemblyPaths = expectedPath }); } @@ -308,7 +308,7 @@ public void MostSpecificRidAssemblySelected_RidGraph(string rid, string expected [InlineData(false, false, true)] [InlineData(false, false, false)] [InlineData(false, false, null)] - public void MostSpecificRidAssemblySelected(bool includeCurrentArch, bool hasRuntimeFallbacks, bool? readRidGraph) + public void MostSpecificRidAssemblySelected(bool includeCurrentArch, bool hasRuntimeFallbacks, bool? useRidGraph) { // When not using the RID graph, the host uses the target OS for which it was built to determine applicable // RIDs that apply, so it can find both the arch-specific and the OS-only assets. @@ -316,7 +316,7 @@ public void MostSpecificRidAssemblySelected(bool includeCurrentArch, bool hasRun // the current RID, so the OS-only asset remains excluded if there are no fallbacks. string includedPath = null; string excludedPath = $"{CurrentOSAsset};{DifferentArchAsset}"; - if (readRidGraph != true || hasRuntimeFallbacks) + if (useRidGraph != true || hasRuntimeFallbacks) { if (includeCurrentArch) { @@ -339,7 +339,7 @@ public void MostSpecificRidAssemblySelected(bool includeCurrentArch, bool hasRun } }, // RID is computed at run-time - new TestSetup() { Rid = null, HasRidGraph = hasRuntimeFallbacks, ReadRidGraph = readRidGraph }, + new TestSetup() { Rid = null, HasRidGraph = hasRuntimeFallbacks, UseRidGraph = useRidGraph }, new ResolvedPaths() { IncludedAssemblyPaths = includedPath, ExcludedAssemblyPaths = excludedPath }); } @@ -354,7 +354,7 @@ public void MostSpecificRidNativeLibrarySelected_RidGraph(string rid, string exp .WithNativeLibraryGroup("any", g => g.WithAsset("any/NativeAny.dll")) .WithNativeLibraryGroup("win", g => g.WithAsset("win/NativeWin.dll")) .WithNativeLibraryGroup("win-x64", g => g.WithAsset("win-x64/NativeWin64.dll")), - new TestSetup() { Rid = rid, HasRidGraph = true, ReadRidGraph = true }, + new TestSetup() { Rid = rid, HasRidGraph = true, UseRidGraph = true }, new ResolvedPaths() { IncludedNativeLibraryPaths = expectedPath }); } @@ -371,7 +371,7 @@ public void MostSpecificRidNativeLibrarySelected_RidGraph(string rid, string exp [InlineData(false, false, true)] [InlineData(false, false, false)] [InlineData(false, false, null)] - public void MostSpecificRidNativeLibrarySelected(bool includeCurrentArch, bool hasRuntimeFallbacks, bool? readRidGraph) + public void MostSpecificRidNativeLibrarySelected(bool includeCurrentArch, bool hasRuntimeFallbacks, bool? useRidGraph) { // When not using the RID graph, the host uses the target OS for which it was built to determine applicable // RIDs that apply, so it can find both the arch-specific and the OS-only assets. @@ -379,7 +379,7 @@ public void MostSpecificRidNativeLibrarySelected(bool includeCurrentArch, bool h // the current RID, so the OS-only asset remains excluded if there are no fallbacks. string includedPath = null; string excludedPath = $"{CurrentOS}/;{DifferentArch}/"; - if (readRidGraph != true || hasRuntimeFallbacks) + if (useRidGraph != true || hasRuntimeFallbacks) { if (includeCurrentArch) { @@ -402,7 +402,7 @@ public void MostSpecificRidNativeLibrarySelected(bool includeCurrentArch, bool h } }, // RID is computed at run-time - new TestSetup() { Rid = null, HasRidGraph = hasRuntimeFallbacks, ReadRidGraph = readRidGraph }, + new TestSetup() { Rid = null, HasRidGraph = hasRuntimeFallbacks, UseRidGraph = useRidGraph }, new ResolvedPaths() { IncludedNativeLibraryPaths = includedPath, ExcludedNativeLibraryPaths = excludedPath }); } @@ -419,7 +419,7 @@ public void MostSpecificRidAssemblySelectedPerType_RidGraph(string rid, string e .WithNativeLibraryGroup("win-x64", g => g.WithAsset("native/win-x64/n.dll")) .WithNativeLibraryGroup("win-x86", g => g.WithAsset("native/win-x86/n.dll")) .WithNativeLibraryGroup("linux", g => g.WithAsset("native/linux/n.so")), - new TestSetup() { Rid = rid, HasRidGraph = true, ReadRidGraph = true }, + new TestSetup() { Rid = rid, HasRidGraph = true, UseRidGraph = true }, new ResolvedPaths() { IncludedAssemblyPaths = expectedAssemblyPath, IncludedNativeLibraryPaths = expectedNativePath }); } @@ -430,7 +430,7 @@ public void MostSpecificRidAssemblySelectedPerType_RidGraph(string rid, string e [InlineData(false, true)] [InlineData(false, false)] [InlineData(false, null)] - public void MostSpecificRidAssemblySelectedPerType(bool hasRuntimeFallbacks, bool? readRidGraph) + public void MostSpecificRidAssemblySelectedPerType(bool hasRuntimeFallbacks, bool? useRidGraph) { // When not using the RID graph, the host uses the target OS for which it was built to determine applicable // RIDs that apply, so it can find both the arch-specific and the OS-only assets. @@ -440,7 +440,7 @@ public void MostSpecificRidAssemblySelectedPerType(bool hasRuntimeFallbacks, boo string excludedAssemblyPath = CurrentOSAsset; string includedNativePath = null; string excludedNativePath = $"native/{CurrentOS}/;native/{CurrentRidAsset}/"; - if (readRidGraph != true || hasRuntimeFallbacks) + if (useRidGraph != true || hasRuntimeFallbacks) { includedAssemblyPath = CurrentOSAsset; excludedAssemblyPath = null; @@ -454,7 +454,7 @@ public void MostSpecificRidAssemblySelectedPerType(bool hasRuntimeFallbacks, boo .WithNativeLibraryGroup(CurrentOS, g => g.WithAsset($"native/{CurrentOSAsset}")) .WithNativeLibraryGroup(CurrentRid, g => g.WithAsset($"native/{CurrentRidAsset}")), // RID is computed at run-time - new TestSetup() { Rid = null, HasRidGraph = hasRuntimeFallbacks, ReadRidGraph = readRidGraph }, + new TestSetup() { Rid = null, HasRidGraph = hasRuntimeFallbacks, UseRidGraph = useRidGraph }, new ResolvedPaths() { IncludedAssemblyPaths = includedAssemblyPath, ExcludedAssemblyPaths = excludedAssemblyPath, @@ -487,7 +487,7 @@ public void MostSpecificRidAssemblySelectedPerTypeMultipleAssets_RidGraph(string .WithNativeLibraryGroup("linux", g => g.WithAsset("native/linux/n.so"))) .WithPackage("ridAgnosticLib", "2.0.0", p => p .WithAssemblyGroup(null, g => g.WithAsset("PortableLib.dll").WithAsset("PortableLib2.dll"))), - setup: new TestSetup() { Rid = rid, HasRidGraph = true, ReadRidGraph = true }, + setup: new TestSetup() { Rid = rid, HasRidGraph = true, UseRidGraph = true }, // PortableLib and PortableLib2 are from a separate package which has no RID specific assets, // so the RID-agnostic assets are always included expected: new ResolvedPaths() @@ -504,7 +504,7 @@ public void MostSpecificRidAssemblySelectedPerTypeMultipleAssets_RidGraph(string [InlineData(false, true)] [InlineData(false, false)] [InlineData(false, null)] - public void MostSpecificRidAssemblySelectedPerTypeMultipleAssets(bool hasRuntimeFallbacks, bool? readRidGraph) + public void MostSpecificRidAssemblySelectedPerTypeMultipleAssets(bool hasRuntimeFallbacks, bool? useRidGraph) { // When not using the RID graph, the host uses the target OS for which it was built to determine applicable // RIDs that apply, so it can find both the arch-specific and the OS-only assets. @@ -514,7 +514,7 @@ public void MostSpecificRidAssemblySelectedPerTypeMultipleAssets(bool hasRuntime string includedAssemblyPath = "ridSpecificLib.dll"; string excludedAssemblyPath = $"{CurrentOSAsset};{CurrentOS}/{CurrentOS}Asset{suffix}.dll"; string includedNativePath = null; - if (readRidGraph != true || hasRuntimeFallbacks) + if (useRidGraph != true || hasRuntimeFallbacks) { includedAssemblyPath = $"{CurrentOSAsset};{CurrentOS}/{CurrentOS}Asset{suffix}.dll"; excludedAssemblyPath = "ridSpecificLib.dll"; @@ -539,7 +539,7 @@ public void MostSpecificRidAssemblySelectedPerTypeMultipleAssets(bool hasRuntime .WithNativeLibraryGroup(DifferentArch, g => g.WithAsset($"native/{DifferentArchAsset}"))) .WithPackage("ridAgnosticLib", "1.0.0", p => p .WithAssemblyGroup(null, g => g.WithAsset("PortableLib.dll").WithAsset("PortableLib2.dll"))), - setup: new TestSetup() { Rid = null, HasRidGraph = hasRuntimeFallbacks, ReadRidGraph = readRidGraph }, + setup: new TestSetup() { Rid = null, HasRidGraph = hasRuntimeFallbacks, UseRidGraph = useRidGraph }, // PortableLib and PortableLib2 are from a separate package which has no RID specific assets, // so the RID-agnostic assets are always included. noRidMatch is from a package where none of // RID-specific assets match, so the RID-agnostic asset is included. @@ -632,7 +632,7 @@ protected override void RunTest( .And.NotHaveResolvedAssembly(expected.ExcludedAssemblyPaths, app) .And.HaveResolvedNativeLibraryPath(expected.IncludedNativeLibraryPaths, app) .And.NotHaveResolvedNativeLibraryPath(expected.ExcludedNativeLibraryPaths, app) - .And.HaveReadRidGraph(setup.ShouldReadRidGraph) + .And.HaveReadRidGraph(setup.ShouldUseRidGraph) .And.HaveUsedFallbackRid(setup.ShouldUseFallbackRid) .And.HaveUsedFrameworkProbe(dotnet.GreatestVersionSharedFxPath, level: 1); } @@ -682,7 +682,7 @@ protected override void RunTest( .And.NotHaveResolvedComponentDependencyAssembly(expected.ExcludedAssemblyPaths, component) .And.HaveResolvedComponentDependencyNativeLibraryPath(expected.IncludedNativeLibraryPaths, component) .And.NotHaveResolvedComponentDependencyNativeLibraryPath(expected.ExcludedNativeLibraryPaths, component) - .And.HaveReadRidGraph(setup.ShouldReadRidGraph) + .And.HaveReadRidGraph(setup.ShouldUseRidGraph) .And.HaveUsedFallbackRid(setup.ShouldUseFallbackRid) .And.NotHaveUsedFrameworkProbe(dotnet.GreatestVersionSharedFxPath); } @@ -731,7 +731,7 @@ protected override void RunTest( .And.NotHaveResolvedComponentDependencyAssembly(expected.ExcludedAssemblyPaths, component) .And.HaveResolvedComponentDependencyNativeLibraryPath(expected.IncludedNativeLibraryPaths, component) .And.NotHaveResolvedComponentDependencyNativeLibraryPath(expected.ExcludedNativeLibraryPaths, component) - .And.HaveReadRidGraph(setup.ShouldReadRidGraph) + .And.HaveReadRidGraph(setup.ShouldUseRidGraph) .And.HaveUsedFallbackRid(setup.ShouldUseFallbackRid); } diff --git a/src/native/corehost/hostpolicy/hostpolicy_context.cpp b/src/native/corehost/hostpolicy/hostpolicy_context.cpp index 5172c8f947080..4c93ea300d7c5 100644 --- a/src/native/corehost/hostpolicy/hostpolicy_context.cpp +++ b/src/native/corehost/hostpolicy/hostpolicy_context.cpp @@ -137,7 +137,7 @@ namespace bool hostpolicy_context_t::should_read_rid_fallback_graph(const hostpolicy_init_t &init) { - const auto &iter = std::find(init.cfg_keys.cbegin(), init.cfg_keys.cend(), _X("System.Host.Resolution.ReadRidGraph")); + const auto &iter = std::find(init.cfg_keys.cbegin(), init.cfg_keys.cend(), _X("System.Runtime.Loader.UseRidGraph")); if (iter != init.cfg_keys.cend()) { size_t idx = iter - init.cfg_keys.cbegin();