Skip to content

Conversation

akoeplinger
Copy link
Member

@akoeplinger akoeplinger commented Jul 31, 2025

Addresses all the new warnings in the newer analyzer version.

Fixes #97088

@akoeplinger akoeplinger force-pushed the akoeplinger-patch-2 branch from c340a3c to 9c7794e Compare August 3, 2025 12:54
@Copilot Copilot AI review requested due to automatic review settings August 4, 2025 08:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses fixes for XUnit analyzer issues by updating test method signatures to use nullable parameter types where null values are being tested. The changes ensure that test parameter declarations are correctly annotated as nullable when the test methods are designed to accept null values through inline data attributes.

  • Updates test method parameter types to use nullable annotations (e.g., string?, Type?, etc.)
  • Fixes test methods to properly handle async/await patterns where incorrect return types were used
  • Includes minor project file updates to include necessary test infrastructure files

Reviewed Changes

Copilot reviewed 299 out of 377 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Reflection/AssemblyMetadataAttributeTests.cs Updated test parameter to accept nullable string values
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/NullableTests.cs Updated test parameter to accept nullable Type values
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/IntPtrTests.cs Updated test parameters to accept nullable object values
src/libraries/System.Net.Sockets/tests/FunctionalTests/DisconnectTest.cs Fixed async test methods to return Task instead of void
src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSExportTest.cs Fixed async test method return type
src/libraries/System.IO.FileSystem.Tests/File/AppendAllBytesAsync.cs Fixed async test method to properly await operations
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileSystemTest.cs Updated TheoryData generic types for better type safety
src/libraries/System.Linq/tests/WhereTests.cs Fixed test assertions to use appropriate methods
Many other test files Similar updates to parameter nullability annotations and async patterns
Comments suppressed due to low confidence (1)

src/libraries/System.Net.Sockets/tests/FunctionalTests/DisconnectTest.cs:76

  • This ActiveIssue attribute was added but there's no context about why this test method was marked as having an active issue. The GitHub issue reference should be validated to ensure it's correctly tracking the actual problem.
        [ActiveIssue("https://github.com/dotnet/runtime/issues/118314")]

@akoeplinger akoeplinger enabled auto-merge (squash) August 4, 2025 18:33
@akoeplinger akoeplinger merged commit a44f532 into main Aug 4, 2025
150 of 152 checks passed
radekdoulik pushed a commit to radekdoulik/runtime that referenced this pull request Aug 5, 2025
* Remove pinned XunitAnalyzersVersion from Versions.props

Fixes dotnet#97088

* Fix xUnit1012: Null should not be used for value type parameters

* Fix xUnit1037: There are fewer theory data type arguments than required by the parameters of the test method

* Fix xUnit1041: Fixture arguments to test classes must have fixture sources

* Fix xUnit1048: Avoid using 'async void' for test methods as it is deprecated in xUnit.net v3

* Fix xUnit2021: Async assertions should be awaited

* Fix xUnit2027: Comparison of sets to linear containers have undefined results

* Fix xUnit2029: Do not use Assert.Empty to check if a value does not exist in a collection

* Fix xUnit2031: Do not use Where clause with Assert.Single

* Disable test that started erroring
@MichalStrehovsky
Copy link
Member

I'm seeing coreCLR pri-1 outerloop failures that look like:

src/tests/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.cs(56,30): error xUnit1041: Fixture argument 'id' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) (https://xunit.net/xunit.analyzers/rules/xUnit1041) [/__w/1/s/src/tests/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.csproj]

E.g. https://dev.azure.com/dnceng-public/public/_build/results?buildId=1114184&view=logs&jobId=71d923da-3b2b-5516-1160-0ea57864003b&j=71d923da-3b2b-5516-1160-0ea57864003b&t=9df8b2f7-960f-560c-e71f-0a84b98b0ae3

Could this be related to the upgraded xunit analyzers?

@akoeplinger
Copy link
Member Author

yes. I'll fix it

@akoeplinger akoeplinger deleted the akoeplinger-patch-2 branch August 5, 2025 12:19
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-codeflow for labeling automated codeflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove pinned xunit.analyzers version
3 participants