Skip to content

Commit 7d471fa

Browse files
authored
Use live reference pack for IntrinsicsInSystemPrivatecorelibAnalyzer.Tests (#93721)
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 #90951 Fixes #93103
1 parent 0151c46 commit 7d471fa

File tree

4 files changed

+13
-25
lines changed

4 files changed

+13
-25
lines changed

src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.CodeAnalysis.CSharp.Testing;
22
using Microsoft.CodeAnalysis.Diagnostics;
3+
using Microsoft.CodeAnalysis.Testing;
34
using Microsoft.CodeAnalysis.Testing.Verifiers;
45

56
namespace IntrinsicsInSystemPrivateCoreLib.Test
@@ -11,6 +12,11 @@ public class Test : CSharpAnalyzerTest<TAnalyzer, XUnitVerifier>
1112
{
1213
public Test()
1314
{
15+
// Clear out the default reference assemblies. We explicitly add references from the live ref pack,
16+
// so we don't want the Roslyn test infrastructure to resolve/add any default reference assemblies
17+
ReferenceAssemblies = new ReferenceAssemblies(string.Empty);
18+
TestState.AdditionalReferences.AddRange(SourceGenerators.Tests.LiveReferencePack.GetMetadataReferences());
19+
1420
SolutionTransforms.Add((solution, projectId) =>
1521
{
1622
var compilationOptions = solution.GetProject(projectId).CompilationOptions;

src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
5+
<TestRunRequiresLiveRefPack>true</TestRunRequiresLiveRefPack>
56
</PropertyGroup>
67

78
<ItemGroup>
@@ -13,6 +14,7 @@
1314

1415
<ItemGroup>
1516
<ProjectReference Include="..\..\gen\System.Private.CoreLib.Generators.csproj" />
17+
<Compile Include="$(CommonTestPath)SourceGenerators\LiveReferencePack.cs" Link="Common\SourceGenerators\LiveReferencePack.cs" />
1618
<Compile Include="IntrinsicsInSystemPrivateCoreLibUnitTests.cs" />
1719
<Compile Include="CSharpAnalyzerVerifier`1.cs" />
1820
<Compile Include="CSharpAnalyzerVerifier`1+Test.cs" />

src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLibUnitTests.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace IntrinsicsInSystemPrivateCoreLib.Test
77
{
8-
[SkipOnPlatform(TestPlatforms.Browser, "Do not try to run analyzer tests in the browser")]
98
public class IntrinsicsInSystemPrivateCoreLibUnitTest
109
{
1110
string BoilerPlate = @"
@@ -90,7 +89,6 @@ class PackedSimd
9089
9190
";
9291
[Fact]
93-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
9492
public async Task TestMethodUnprotectedUse()
9593
{
9694
var test = BoilerPlate + @"
@@ -110,7 +108,6 @@ static void FuncBad()
110108
}
111109

112110
[Fact]
113-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
114111
public async Task TestMethodUnprotectedUseWithIntrinsicsHelperAttribute()
115112
{
116113
var test = BoilerPlate + @"
@@ -131,7 +128,6 @@ static void FuncGood()
131128
}
132129

133130
[Fact]
134-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
135131
public async Task TestMethodUnprotectedUseWithIntrinsicsHelperAttributeComplex()
136132
{
137133
var test = BoilerPlate + @"
@@ -157,7 +153,6 @@ static void FuncGood()
157153
}
158154

159155
[Fact]
160-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
161156
public async Task TestMethodUnprotectedUseInLocalFunctionWithIntrinsicsHelperAttributeNotOnLocalFunction()
162157
{
163158
var test = BoilerPlate + @"
@@ -183,7 +178,6 @@ static void LocalFunc()
183178
}
184179

185180
[Fact]
186-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
187181
public async Task TestMethodUnprotectedUseInLambdaWithIntrinsicsHelperAttributeOnOuterFunction()
188182
{
189183
var test = BoilerPlate + @"
@@ -209,7 +203,6 @@ static void FuncBad()
209203
}
210204

211205
[Fact]
212-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
213206
public async Task TestMethodUnprotectedUseInLocalFunctionWithIntrinsicsHelperAttributeOnLocalFunction()
214207
{
215208
var test = BoilerPlate + @"
@@ -235,7 +228,6 @@ static void LocalFunc()
235228
}
236229

237230
[Fact]
238-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
239231
public async Task TestMethodUnprotectedNestedTypeUse()
240232
{
241233
var test = BoilerPlate + @"
@@ -275,7 +267,6 @@ static void FuncGood()
275267

276268

277269
[Fact]
278-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
279270
public async Task TestMethodWithIfStatementButWithInadequateHelperMethodAttribute()
280271
{
281272
var test = BoilerPlate + @"
@@ -317,7 +308,6 @@ static void FuncBad()
317308
}
318309

319310
[Fact]
320-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
321311
public async Task TestMethodWithIfStatementWithNestedAndBaseTypeLookupRequired()
322312
{
323313
var test = BoilerPlate + @"
@@ -337,7 +327,6 @@ static void FuncGood()
337327
}
338328

339329
[Fact]
340-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
341330
public async Task TestMethodWithTernaryOperator()
342331
{
343332
var test = BoilerPlate + @"
@@ -356,7 +345,6 @@ static bool FuncGood()
356345
}
357346

358347
[Fact]
359-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
360348
public async Task TestMethodWithIfStatementWithOrOperationCase()
361349
{
362350
var test = BoilerPlate + @"
@@ -386,7 +374,6 @@ static void FuncGood()
386374
}
387375

388376
[Fact]
389-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
390377
public async Task TestMethodWithIfStatementWithOrOperationCaseWithImplicationProcessingRequired()
391378
{
392379
var test = BoilerPlate + @"
@@ -416,7 +403,6 @@ static void FuncGood()
416403
}
417404

418405
[Fact]
419-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
420406
public async Task TestMethodWithIfStatementAroundLocalFunctionDefinition()
421407
{
422408
var test = BoilerPlate + @"
@@ -446,7 +432,6 @@ void LocalFunction()
446432
}
447433

448434
[Fact]
449-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
450435
public async Task TestMethodWithIfStatementAroundLambdaFunctionDefinition()
451436
{
452437
var test = BoilerPlate + @"
@@ -473,7 +458,6 @@ static void FuncGood()
473458
}
474459

475460
[Fact]
476-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
477461
public async Task TestHelperMethodsCanOnlyBeCalledWithAppropriateIsSupportedChecksError()
478462
{
479463
var test = BoilerPlate + @"
@@ -524,7 +508,6 @@ static void FuncBad()
524508
await VerifyCS.VerifyAnalyzerAsync(test, expected, expected2, expected3, expected4, expected5);
525509
}
526510
[Fact]
527-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
528511
public async Task TestHelperMethodsCanOnlyBeCalledWithAppropriateIsSupportedChecksSuccess()
529512
{
530513
var test = BoilerPlate + @"
@@ -565,7 +548,6 @@ static void FuncGood()
565548
}
566549

567550
[Fact]
568-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
569551
public async Task TestHelperMethodsUnrelatedPropertyDoesntHelp()
570552
{
571553
var test = BoilerPlate + @"
@@ -596,7 +578,6 @@ static void FuncBad()
596578
}
597579

598580
[Fact]
599-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
600581
public async Task TestHelperMethodsWithHelperProperty()
601582
{
602583
var test = BoilerPlate + @"
@@ -627,7 +608,6 @@ static void FuncGood()
627608

628609

629610
[Fact]
630-
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93103")]
631611
public async Task TestMethodUseOfIntrinsicsFromWithinOtherMethodOnIntrinsicType()
632612
{
633613
var test = @"

src/libraries/tests.proj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@
8989
</ItemGroup>
9090

9191
<ItemGroup Condition="'$(TargetsMobile)' == 'true' or '$(TargetsLinuxBionic)' == 'true' or '$(TargetArchitecture)' == 'ARMv6'">
92-
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices\tests\LibraryImportGenerator.Tests\LibraryImportGenerator.Tests.csproj" />
92+
<!-- don't run source generator or roslyn analyzer tests on mobile -->
9393
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices\tests\ComInterfaceGenerator.Tests\ComInterfaceGenerator.Tests.csproj" />
94-
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices\tests\LibraryImportGenerator.UnitTests\LibraryImportGenerator.Unit.Tests.csproj" />
9594
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices\tests\ComInterfaceGenerator.Unit.Tests\ComInterfaceGenerator.Unit.Tests.csproj" />
95+
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices\tests\LibraryImportGenerator.Tests\LibraryImportGenerator.Tests.csproj" />
96+
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices\tests\LibraryImportGenerator.UnitTests\LibraryImportGenerator.Unit.Tests.csproj" />
97+
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices.JavaScript\tests\JSImportGenerator.UnitTest\JSImportGenerator.Unit.Tests.csproj" />
98+
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.CoreLib\tests\IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests\IntrinsicsInSystemPrivateCoreLib.Tests.csproj" />
9699
</ItemGroup>
97100

98101
<ItemGroup Condition="'$(TargetOS)' == 'windows' and '$(TargetArchitecture)' == 'arm'">
@@ -330,19 +333,16 @@
330333
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Text.Json\tests\System.Text.Json.SourceGeneration.Unit.Tests\System.Text.Json.SourceGeneration.Roslyn3.11.Unit.Tests.csproj" />
331334
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Text.Json\tests\System.Text.Json.SourceGeneration.Unit.Tests\System.Text.Json.SourceGeneration.Roslyn4.4.Unit.Tests.csproj" />
332335
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Text.RegularExpressions\tests\FunctionalTests\System.Text.RegularExpressions.Tests.csproj" />
333-
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices.JavaScript\tests\JSImportGenerator.UnitTest\JSImportGenerator.Unit.Tests.csproj" />
334336
<ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.Extensions.Configuration.Binder\tests\SourceGenerationTests\Microsoft.Extensions.Configuration.Binder.SourceGeneration.Tests.csproj" />
335337
<ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.Extensions.Options.ConfigurationExtensions\tests\SourceGenerationTests\Microsoft.Extensions.Options.ConfigurationExtensions.SourceGeneration.Tests.csproj" />
336338
<ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.Extensions.Options/tests/SourceGenerationTests/Microsoft.Extensions.Options.SourceGeneration.Tests.csproj" />
337339
<ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/Microsoft.Extensions.Options.SourceGeneration.Unit.Tests.csproj" />
338-
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj" />
339340
</ItemGroup>
340341

341342
<ItemGroup Condition="'$(TargetOS)' == 'browser' and '$(RunDisabledWasmTests)' != 'true' and '$(RunAOTCompilation)' != 'true'">
342343
</ItemGroup>
343344

344345
<ItemGroup Condition="'$(TargetOS)' == 'browser' and '$(RunDisabledWasmTests)' != 'true'">
345-
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices.JavaScript\tests\JSImportGenerator.UnitTest\JSImportGenerator.Unit.Tests.csproj" />
346346

347347
<!-- This test is disabled via an assembly-level attribute in source. We exclude it here to avoid queuing/running a work item entirely.
348348
https://github.com/dotnet/runtime/issues/35970 -->

0 commit comments

Comments
 (0)