Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
next-version: 3.21.0
next-version: 3.22.0
mode: ContinuousDelivery
branches:
main:
Expand Down
18 changes: 9 additions & 9 deletions package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,15 @@ public static class PackageTests
}
});

StandardAndZipLists.Add(new PackageTest(1, "AppContextBaseDirectory_NET80")
{
Description = "Test Setting the BaseDirectory to match test assembly location targeting .NET 8.0",
Arguments = "testdata/net8.0/AppContextTest.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("AppContextTest.dll", "netcore-8.0") }
}
});
//StandardAndZipLists.Add(new PackageTest(1, "AppContextBaseDirectory_NET80")
//{
// Description = "Test Setting the BaseDirectory to match test assembly location targeting .NET 8.0",
// Arguments = "testdata/net8.0/AppContextTest.dll",
// ExpectedResult = new ExpectedResult("Passed")
// {
// Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("AppContextTest.dll", "netcore-8.0") }
// }
//});

AllLists.Add(new PackageTest(1, "UnmanagedAssemblyTest")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
<PackageReference Include="NUnitLite" Version="4.2.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'!='net462'">
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<Content Include="TestListWithEmptyLine.tst">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
23 changes: 13 additions & 10 deletions src/NUnitEngine/nunit.engine.core/Drivers/NUnitNetCore31Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using System.Linq;
using System.Collections.Generic;
using System.IO;
using NUnit.Engine.Internal;
using System.Reflection;
using NUnit.Engine.Extensibility;
using System.Runtime.Loader;
using NUnit.Engine.Internal;
using NUnit.Engine.Extensibility;

namespace NUnit.Engine.Drivers
{
Expand Down Expand Up @@ -56,21 +56,24 @@ public class NUnitNetCore31Driver : IFrameworkDriver
/// <returns>An XML string representing the loaded test</returns>
public string Load(string assemblyPath, IDictionary<string, object> settings)
{
//if (assemblyPath.EndsWith("WpfTest.dll"))
// System.Diagnostics.Debugger.Launch();

log.Debug($"Loading {assemblyPath}");
var idPrefix = string.IsNullOrEmpty(ID) ? "" : ID + "-";

assemblyPath = Path.GetFullPath(assemblyPath); //AssemblyLoadContext requires an absolute path
//_assemblyLoadContext = new TestAssemblyLoadContext(assemblyPath);
//_assemblyLoadContext = AssemblyLoadContext.Default;
_assemblyLoadContext = new AssemblyLoadContext(assemblyPath);
_testAssemblyResolver = new TestAssemblyResolver(_assemblyLoadContext, assemblyPath);

try
{
_testAssembly = _assemblyLoadContext.LoadFromAssemblyPath(assemblyPath);
_testAssembly = AssemblyHelper.FindLoadedAssemblyByPath(assemblyPath);

if (_testAssembly != null)
_assemblyLoadContext = AssemblyLoadContext.GetLoadContext(_testAssembly);
else
{
_assemblyLoadContext = new AssemblyLoadContext(Path.GetFileNameWithoutExtension(assemblyPath));
_testAssembly = _assemblyLoadContext.LoadFromAssemblyPath(assemblyPath);
}

_testAssemblyResolver = new TestAssemblyResolver(_assemblyLoadContext, assemblyPath);
}
catch (Exception e)
{
Expand Down
26 changes: 26 additions & 0 deletions src/NUnitEngine/nunit.engine.core/Internal/AssemblyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

using System;
using System.IO;
using System.Linq;
using System.Reflection;
#if NETCOREAPP3_1_OR_GREATER
using System.Runtime.Loader;
#endif

namespace NUnit.Engine.Internal
{
/// <summary>
Expand Down Expand Up @@ -69,5 +74,26 @@ public static string GetAssemblyPathFromCodeBase(string codeBase)

return codeBase.Substring(start);
}

// For assemblies already loaded by MTP (net core and above) or by means
public static Assembly FindLoadedAssemblyByPath(string assemblyPath)
{
var full = Path.GetFullPath(assemblyPath);

return AppDomain.CurrentDomain.GetAssemblies()
.FirstOrDefault(a =>
!a.IsDynamic &&
!string.IsNullOrEmpty(a.Location) &&
StringComparer.OrdinalIgnoreCase.Equals(Path.GetFullPath(a.Location), full));
}

public static Assembly FindLoadedAssemblyByName(AssemblyName assemblyName)
{
return AppDomain.CurrentDomain.GetAssemblies()
.FirstOrDefault(a =>
!a.IsDynamic &&
!string.IsNullOrEmpty(a.Location) &&
a.GetName() == assemblyName);
}
}
}
143 changes: 0 additions & 143 deletions src/NUnitEngine/nunit.engine.core/Internal/TestAssemblyLoadContext.cs

This file was deleted.

Loading