* fix #3469 by correcting overflow and enabling tests * pr feedback
This commit is contained in:
parent
ec02de828e
commit
762a259e9f
3 changed files with 10 additions and 8 deletions
|
@ -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"
|
||||||
};
|
};
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue