public void ResolveWithConfiguredRuntimeWindowsCanStillResolveCorLib() { Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), NonWindowsPlatform); var assemblyName = typeof(object).Assembly.GetName(); var assemblyRef = new AssemblyReference( assemblyName.Name, assemblyName.Version, false, assemblyName.GetPublicKeyToken()); var config = RuntimeConfiguration.FromJson(@"{ ""runtimeOptions"": { ""tfm"": ""netcoreapp3.1"", ""framework"": { ""name"": ""Microsoft.WindowsDesktop.App"", ""version"": ""3.1.0"" } } }"); var resolver = new DotNetCoreAssemblyResolver(config, new Version(3, 1, 0)); var assemblyDef = resolver.Resolve(assemblyRef); Assert.NotNull(assemblyDef); Assert.Equal(assemblyName.Name, assemblyDef.Name); Assert.NotNull(assemblyDef.ManifestModule.FilePath); }
public void ResolveWithConfiguredRuntime() { var assemblyName = typeof(object).Assembly.GetName(); var assemblyRef = new AssemblyReference( assemblyName.Name, assemblyName.Version, false, assemblyName.GetPublicKeyToken()); var config = RuntimeConfiguration.FromJson(@"{ ""runtimeOptions"": { ""tfm"": ""netcoreapp3.1"", ""framework"": { ""name"": ""Microsoft.NETCore.App"", ""version"": ""3.1.0"" } } }"); var resolver = new DotNetCoreAssemblyResolver(config, new Version(3, 1, 0)); var assemblyDef = resolver.Resolve(assemblyRef); Assert.NotNull(assemblyDef); Assert.Equal(assemblyName.Name, assemblyDef.Name); Assert.NotNull(assemblyDef.ManifestModule.FilePath); Assert.Contains("Microsoft.NETCore.App", assemblyDef.ManifestModule.FilePath); }
public void ResolveWithConfiguredRuntimeWindowsResolvesRightWindowsBase() { Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), NonWindowsPlatform); var assemblyRef = new AssemblyReference( "WindowsBase", new Version(4, 0, 0, 0), false, new byte[] { 0x31, 0xbf, 0x38, 0x56, 0xad, 0x36, 0x4e, 0x35 }); var config = RuntimeConfiguration.FromJson(@"{ ""runtimeOptions"": { ""tfm"": ""netcoreapp3.1"", ""framework"": { ""name"": ""Microsoft.WindowsDesktop.App"", ""version"": ""3.1.0"" } } }"); var resolver = new DotNetCoreAssemblyResolver(config, new Version(3, 1, 0)); var assemblyDef = resolver.Resolve(assemblyRef); Assert.NotNull(assemblyDef); Assert.Equal("WindowsBase", assemblyDef.Name); Assert.NotNull(assemblyDef.ManifestModule.FilePath); Assert.Contains("Microsoft.WindowsDesktop.App", assemblyDef.ManifestModule.FilePath); }
public void ReadMultipleFrameworks() { var config = RuntimeConfiguration.FromJson(@"{ ""runtimeOptions"": { ""tfm"": ""net5.0"", ""includedFrameworks"": [ { ""name"": ""Microsoft.NETCore.App"", ""version"": ""5.0.0"" }, { ""name"": ""Microsoft.WindowsDesktop.App"", ""version"": ""5.0.0"" } ] } }"); Assert.NotNull(config.RuntimeOptions); Assert.Equal("net5.0", config.RuntimeOptions.TargetFrameworkMoniker); var frameworks = config.RuntimeOptions.IncludedFrameworks; Assert.Contains(frameworks, framework => framework.Name == "Microsoft.NETCore.App" && framework.Version == "5.0.0"); Assert.Contains(frameworks, framework => framework.Name == "Microsoft.WindowsDesktop.App" && framework.Version == "5.0.0"); }
public void ReadSingleFramework() { var config = RuntimeConfiguration.FromJson(@"{ ""runtimeOptions"": { ""tfm"": ""netcoreapp3.1"", ""framework"": { ""name"": ""Microsoft.NETCore.App"", ""version"": ""3.1.0"" } } }"); Assert.NotNull(config.RuntimeOptions); Assert.Equal("netcoreapp3.1", config.RuntimeOptions.TargetFrameworkMoniker); var framework = config.RuntimeOptions.Framework; Assert.NotNull(framework); Assert.Equal("Microsoft.NETCore.App", framework.Name); Assert.Equal("3.1.0", framework.Version); }
public void ReadConfigurationProperties() { var config = RuntimeConfiguration.FromJson(@"{ ""runtimeOptions"": { ""tfm"": ""netcoreapp3.1"", ""framework"": { ""name"": ""Microsoft.NETCore.App"", ""version"": ""3.1.0"" }, ""configProperties"": { ""System.GC.Concurrent"": false, ""System.Threading.ThreadPool.MinThreads"": 4 } } }"); var value = Assert.Contains("System.GC.Concurrent", (IDictionary <string, JsonElement>)config.RuntimeOptions.ConfigProperties); Assert.Equal(JsonValueKind.False, value.ValueKind); value = Assert.Contains("System.Threading.ThreadPool.MinThreads", (IDictionary <string, JsonElement>)config.RuntimeOptions.ConfigProperties); Assert.Equal(JsonValueKind.Number, value.ValueKind); Assert.Equal(4, value.GetInt32()); }