Skip to content

Commit

Permalink
[tests] fix build warnings as errors in TestRunner.NUnit.NET (#9739)
Browse files Browse the repository at this point in the history
Context: #9732

In d3cde47, we made warnings -> errors on CI.

In #9732, the `$(SupportedOSPlatformVersion)` Roslyn analyzer was
"fixed" so it properly emits warnings now.

This causes several errors:

    tests/TestRunner.NUnit/NUnitTestRunner.cs(43,35): error CA1416: This call site is reachable on all platforms. 'Application.Context' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestRunner.cs(43,35): error CA1416: This call site is reachable on all platforms. 'Context.PackageName' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(39,32): error CA1416: This call site is reachable on all platforms. 'Instrumentation.Context' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(70,4): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(64,4): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(76,4): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(67,4): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(73,4): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(117,5): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(110,5): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(104,5): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]
    tests/TestRunner.NUnit/NUnitTestInstrumentation.cs(94,6): error CA1416: This call site is reachable on all platforms. 'Log.Info(string?, string)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj]

It appears this analyzer relies on `AssemblyInfo.cs` to determine the
`$(SupportedOSPlatformVersion)` value. `$(GenerateAssemblyInfo)=false`
appears to break this analyzer!

This commit removes `$(GenerateAssemblyInfo)=false` to allow
the .NET SDK to generate `AssemblyInfo.cs`. I also removed the
`Properties/AssemblyInfo.cs` file, as it would create duplicate
attributes. We do not *ship* this assembly, so the values in
`AssemblyInfo.cs` are probably not important.
  • Loading branch information
jonathanpeppers committed Jan 31, 2025
1 parent 68ff251 commit 51c73e6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
26 changes: 0 additions & 26 deletions tests/TestRunner.NUnit/Properties/AssemblyInfo.cs

This file was deleted.

1 change: 0 additions & 1 deletion tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Android.UnitTests.NUnit</RootNamespace>
<AssemblyName>TestRunner.NUnit.NET</AssemblyName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 51c73e6

Please sign in to comment.