Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] fix build warnings as errors in TestRunner.NUnit.NET #9739

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

jonathanpeppers
Copy link
Member

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 remove the $(GenerateAssemblyInfo)=false change 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.

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 remove the `$(GenerateAssemblyInfo)=false` change 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.
Copy link
Contributor

@jpobst jpobst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, we have this in the .csproj:

<SupportedOSPlatformVersion>$(AndroidMinimumDotNetApiLevel)</SupportedOSPlatformVersion>

But I suspect the way that actually makes it into the assembly as an [assembly:SupportedOSPlatformVersion ("")] is via the AssemblyInfo.cs that .NET generates with <GenerateAssemblyInfo>.

@jonathanpeppers
Copy link
Member Author

I don't think it's a bug, because they support you using the attribute manually [assembly:SupportedOSPlatformVersion ("")].

So, then if we prevent the attribute from being in the assembly, it doesn't work.

One test lane timed out, but going to merge to unblock some of the .NET 10 bumps.

@jonathanpeppers jonathanpeppers merged commit 18af3ac into main Jan 31, 2025
56 of 58 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/peppers/TestRunner.NUnit.NET branch January 31, 2025 19:38
jonathanpeppers added a commit that referenced this pull request Jan 31, 2025
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.
grendello added a commit that referenced this pull request Feb 3, 2025
* main:
  [tests] fix build warnings as errors in TestRunner.NUnit.NET (#9739)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants