From 71db3f90849add8306e79ce00b2672f602015717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 19 Oct 2023 13:05:58 +0200 Subject: [PATCH] Use live reference pack for IntrinsicsInSystemPrivatecorelibAnalyzer.Tests This avoids an issue where the analyzer test tries to restore reference assemblies from nuget.org during the test. We already have helpers in place to use the live reference pack instead. Fixes https://github.com/dotnet/runtime/issues/90951 Fixes https://github.com/dotnet/runtime/issues/93103 --- .../CSharpAnalyzerVerifier`1+Test.cs | 6 ++++++ ...rinsicsInSystemPrivateCoreLib.Tests.csproj | 2 ++ ...trinsicsInSystemPrivateCoreLibUnitTests.cs | 19 ------------------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs index 1372bc02caacd..fb8a08a8c4905 100644 --- a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs +++ b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs @@ -1,5 +1,6 @@ using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; namespace IntrinsicsInSystemPrivateCoreLib.Test @@ -11,6 +12,11 @@ public class Test : CSharpAnalyzerTest { public Test() { + // Clear out the default reference assemblies. We explicitly add references from the live ref pack, + // so we don't want the Roslyn test infrastructure to resolve/add any default reference assemblies + ReferenceAssemblies = new ReferenceAssemblies(string.Empty); + TestState.AdditionalReferences.AddRange(SourceGenerators.Tests.LiveReferencePack.GetMetadataReferences()); + SolutionTransforms.Add((solution, projectId) => { var compilationOptions = solution.GetProject(projectId).CompilationOptions; diff --git a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj index 790a0c81a3635..62859b1fbbad0 100644 --- a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj +++ b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent) + true @@ -13,6 +14,7 @@ + diff --git a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLibUnitTests.cs b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLibUnitTests.cs index 10c304ac76a04..2efb366d161c8 100644 --- a/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLibUnitTests.cs +++ b/src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLibUnitTests.cs @@ -90,7 +90,6 @@ class PackedSimd "; [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodUnprotectedUse() { var test = BoilerPlate + @" @@ -110,7 +109,6 @@ static void FuncBad() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodUnprotectedUseWithIntrinsicsHelperAttribute() { var test = BoilerPlate + @" @@ -131,7 +129,6 @@ static void FuncGood() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodUnprotectedUseWithIntrinsicsHelperAttributeComplex() { var test = BoilerPlate + @" @@ -157,7 +154,6 @@ static void FuncGood() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodUnprotectedUseInLocalFunctionWithIntrinsicsHelperAttributeNotOnLocalFunction() { var test = BoilerPlate + @" @@ -183,7 +179,6 @@ static void LocalFunc() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodUnprotectedUseInLambdaWithIntrinsicsHelperAttributeOnOuterFunction() { var test = BoilerPlate + @" @@ -209,7 +204,6 @@ static void FuncBad() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodUnprotectedUseInLocalFunctionWithIntrinsicsHelperAttributeOnLocalFunction() { var test = BoilerPlate + @" @@ -235,7 +229,6 @@ static void LocalFunc() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodUnprotectedNestedTypeUse() { var test = BoilerPlate + @" @@ -275,7 +268,6 @@ static void FuncGood() [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodWithIfStatementButWithInadequateHelperMethodAttribute() { var test = BoilerPlate + @" @@ -317,7 +309,6 @@ static void FuncBad() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodWithIfStatementWithNestedAndBaseTypeLookupRequired() { var test = BoilerPlate + @" @@ -337,7 +328,6 @@ static void FuncGood() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodWithTernaryOperator() { var test = BoilerPlate + @" @@ -356,7 +346,6 @@ static bool FuncGood() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodWithIfStatementWithOrOperationCase() { var test = BoilerPlate + @" @@ -386,7 +375,6 @@ static void FuncGood() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodWithIfStatementWithOrOperationCaseWithImplicationProcessingRequired() { var test = BoilerPlate + @" @@ -416,7 +404,6 @@ static void FuncGood() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodWithIfStatementAroundLocalFunctionDefinition() { var test = BoilerPlate + @" @@ -446,7 +433,6 @@ void LocalFunction() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodWithIfStatementAroundLambdaFunctionDefinition() { var test = BoilerPlate + @" @@ -473,7 +459,6 @@ static void FuncGood() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestHelperMethodsCanOnlyBeCalledWithAppropriateIsSupportedChecksError() { var test = BoilerPlate + @" @@ -524,7 +509,6 @@ static void FuncBad() await VerifyCS.VerifyAnalyzerAsync(test, expected, expected2, expected3, expected4, expected5); } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestHelperMethodsCanOnlyBeCalledWithAppropriateIsSupportedChecksSuccess() { var test = BoilerPlate + @" @@ -565,7 +549,6 @@ static void FuncGood() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestHelperMethodsUnrelatedPropertyDoesntHelp() { var test = BoilerPlate + @" @@ -596,7 +579,6 @@ static void FuncBad() } [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestHelperMethodsWithHelperProperty() { var test = BoilerPlate + @" @@ -627,7 +609,6 @@ static void FuncGood() [Fact] - [SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")] public async Task TestMethodUseOfIntrinsicsFromWithinOtherMethodOnIntrinsicType() { var test = @"