fix #3469 by correcting overflow and enabling tests (#3471)

* fix #3469 by correcting overflow and enabling tests

* pr feedback
This commit is contained in:
Andrew Stanton-Nurse 2016-06-10 17:28:23 -07:00 committed by GitHub
parent ec02de828e
commit 762a259e9f
3 changed files with 10 additions and 8 deletions

View file

@ -39,6 +39,7 @@ namespace Microsoft.DotNet.Cli.Build
"Microsoft.DotNet.Cli.Utils.Tests", "Microsoft.DotNet.Cli.Utils.Tests",
"Microsoft.DotNet.Compiler.Common.Tests", "Microsoft.DotNet.Compiler.Common.Tests",
"Microsoft.DotNet.ProjectModel.Tests", "Microsoft.DotNet.ProjectModel.Tests",
"Microsoft.DotNet.ProjectModel.Loader.Tests",
"Microsoft.Extensions.DependencyModel.Tests", "Microsoft.Extensions.DependencyModel.Tests",
"Performance" "Performance"
}; };

View file

@ -20,7 +20,7 @@ namespace Microsoft.DotNet.ProjectModel.Loader
public static AssemblyLoadContext CreateLoadContext( public static AssemblyLoadContext CreateLoadContext(
this ProjectContext context, this ProjectContext context,
string runtimeIdentifier, string runtimeIdentifier,
string configuration) => CreateLoadContext(context, runtimeIdentifier, configuration); string configuration) => CreateLoadContext(context, runtimeIdentifier, configuration, outputPath: null);
public static AssemblyLoadContext CreateLoadContext( public static AssemblyLoadContext CreateLoadContext(
this ProjectContext context, this ProjectContext context,
@ -124,4 +124,4 @@ namespace Microsoft.DotNet.ProjectModel.Loader
} }
} }
} }
} }

View file

@ -13,20 +13,21 @@ namespace Microsoft.DotNet.ProjectModel.Loader.Tests
[Fact] [Fact]
public void LoadContextCanLoadProjectOutput() public void LoadContextCanLoadProjectOutput()
{ {
var testInstance = TestAssetsManager.CreateTestInstance("TestProjectWithResource") var testInstance = TestAssetsManager.CreateTestInstance("TestProjectWithCultureSpecificResource")
.WithLockFiles() .WithLockFiles()
.WithBuildArtifacts(); .WithBuildArtifacts();
var rid = DependencyContext.Default.Target.Runtime; var runtimeIdentifier = DependencyContext.Default.Target.Runtime;
var context = ProjectContext.Create(testInstance.TestRoot, NuGetFramework.Parse("netcoreapp1.0"), new[] { rid }); var context = ProjectContext.Create(testInstance.TestRoot, NuGetFramework.Parse("netcoreapp1.0"), new[] { runtimeIdentifier });
var loadContext = context.CreateLoadContext(rid, Constants.DefaultConfiguration); var loadContext = context.CreateLoadContext(runtimeIdentifier, Constants.DefaultConfiguration);
// Load the project assembly // Load the project assembly
var asm = loadContext.LoadFromAssemblyName(new AssemblyName("TestProjectWithResource")); var assembly = loadContext.LoadFromAssemblyName(new AssemblyName("TestProjectWithCultureSpecificResource"));
// Call Program.GetMessage() and assert the output // Call Program.GetMessage() and assert the output
var message = (string)asm.GetType("TestProjectWithCultureSpecificResource").GetRuntimeMethod("GetMessage", Type.EmptyTypes).Invoke(null, new object[0]); var type = assembly.GetType("TestProjectWithCultureSpecificResource.Program");
var message = (string)type.GetRuntimeMethod("GetMessage", Type.EmptyTypes).Invoke(null, new object[0]);
Assert.Equal("Hello World!" + Environment.NewLine + "Bonjour!", message); Assert.Equal("Hello World!" + Environment.NewLine + "Bonjour!", message);
} }
} }