diff options
author | Steve Harter <steveharter@users.noreply.github.com> | 2022-09-30 16:51:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-30 16:51:44 +0300 |
commit | ac8ed2945e5ac0df7e0f42afd10c819dec0b166a (patch) | |
tree | 65bdf3db6fd2fcbe9d55a1941c331efff07b865d /src | |
parent | 60b40c38eb06106164a125b0ec6521024f62e46f (diff) |
Support running Reflection tests within Visual Studio (#75915)
Diffstat (limited to 'src')
-rw-r--r-- | src/libraries/System.Reflection/tests/AssemblyTests.cs | 15 | ||||
-rw-r--r-- | src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj | 2 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/libraries/System.Reflection/tests/AssemblyTests.cs b/src/libraries/System.Reflection/tests/AssemblyTests.cs index bd86b761db5..61059307625 100644 --- a/src/libraries/System.Reflection/tests/AssemblyTests.cs +++ b/src/libraries/System.Reflection/tests/AssemblyTests.cs @@ -154,10 +154,19 @@ namespace System.Reflection.Tests Assert.NotNull(Assembly.GetEntryAssembly()); string assembly = Assembly.GetEntryAssembly().ToString(); - // The single file test runner is not xunit.console - string expectedAssembly = PlatformDetection.IsNativeAot ? "System.Reflection.Tests" : "xunit.console"; + bool correct; + if (PlatformDetection.IsNativeAot) + { + // The single file test runner is not 'xunit.console'. + correct = assembly.IndexOf("System.Reflection.Tests", StringComparison.OrdinalIgnoreCase) != -1; + } + else + { + // Under Visual Studio, the runner is 'testhost', otherwise it is 'xunit.console'. + correct = assembly.IndexOf("xunit.console", StringComparison.OrdinalIgnoreCase) != -1 || + assembly.IndexOf("testhost", StringComparison.OrdinalIgnoreCase) != -1; + } - bool correct = assembly.IndexOf(expectedAssembly, StringComparison.OrdinalIgnoreCase) != -1; Assert.True(correct, $"Unexpected assembly name {assembly}"); } diff --git a/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj b/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj index 5da8f6dbc76..bc011a8a600 100644 --- a/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj +++ b/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj @@ -2,8 +2,6 @@ <PropertyGroup> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> <TestRuntime>true</TestRuntime> - <!-- LoadFrom_SameIdentityAsAssemblyWithDifferentPath_ReturnsEqualAssemblies test relies on no deps.json --> - <GenerateDependencyFile>false</GenerateDependencyFile> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <!-- SYSLIB0013: Uri.EscapeUriString is obsolete SYSLIB0037: AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete. --> |