Skip to content

Commit

Permalink
Use live reference pack for IntrinsicsInSystemPrivatecorelibAnalyzer.…
Browse files Browse the repository at this point in the history
…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 dotnet#90951
Fixes dotnet#93103
  • Loading branch information
akoeplinger committed Oct 19, 2023
1 parent 04ede0d commit 71db3f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,6 +12,11 @@ public class Test : CSharpAnalyzerTest<TAnalyzer, XUnitVerifier>
{
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<TestRunRequiresLiveRefPack>true</TestRunRequiresLiveRefPack>
</PropertyGroup>

<ItemGroup>
Expand All @@ -13,6 +14,7 @@

<ItemGroup>
<ProjectReference Include="..\..\gen\System.Private.CoreLib.Generators.csproj" />
<Compile Include="$(CommonTestPath)SourceGenerators\LiveReferencePack.cs" Link="Common\SourceGenerators\LiveReferencePack.cs" />
<Compile Include="IntrinsicsInSystemPrivateCoreLibUnitTests.cs" />
<Compile Include="CSharpAnalyzerVerifier`1.cs" />
<Compile Include="CSharpAnalyzerVerifier`1+Test.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class PackedSimd
";
[Fact]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
public async Task TestMethodUnprotectedUse()
{
var test = BoilerPlate + @"
Expand All @@ -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 + @"
Expand All @@ -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 + @"
Expand All @@ -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 + @"
Expand All @@ -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 + @"
Expand All @@ -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 + @"
Expand All @@ -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 + @"
Expand Down Expand Up @@ -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 + @"
Expand Down Expand Up @@ -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 + @"
Expand All @@ -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 + @"
Expand All @@ -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 + @"
Expand Down Expand Up @@ -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 + @"
Expand Down Expand Up @@ -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 + @"
Expand Down Expand Up @@ -446,7 +433,6 @@ void LocalFunction()
}

[Fact]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
public async Task TestMethodWithIfStatementAroundLambdaFunctionDefinition()
{
var test = BoilerPlate + @"
Expand All @@ -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 + @"
Expand Down Expand Up @@ -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 + @"
Expand Down Expand Up @@ -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 + @"
Expand Down Expand Up @@ -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 + @"
Expand Down Expand Up @@ -627,7 +609,6 @@ static void FuncGood()


[Fact]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
public async Task TestMethodUseOfIntrinsicsFromWithinOtherMethodOnIntrinsicType()
{
var test = @"
Expand Down

0 comments on commit 71db3f9

Please sign in to comment.