Skip to content

Fix xUnit1051: pass TestContext.Current.CancellationToken to async methods#53714

Merged
MichaelSimons merged 14 commits intomainfrom
copilot/rebase-main-and-verify-build
Apr 21, 2026
Merged

Fix xUnit1051: pass TestContext.Current.CancellationToken to async methods#53714
MichaelSimons merged 14 commits intomainfrom
copilot/rebase-main-and-verify-build

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

Resolves xUnit1051 violations across the test codebase by passing TestContext.Current.CancellationToken to async methods that accept a CancellationToken parameter.

Changes

  • Remove xUnit1051 suppression from test/Directory.Build.props — the rule is now enforced rather than globally suppressed.
  • Pass TestContext.Current.CancellationToken to ~1,400 async call sites across:
    • Roslyn analyzer tests (src/Microsoft.CodeAnalysis.NetAnalyzers/tests/)
    • Razor, container, hot-reload, template engine, watch, and Aspire tests (test/)

What this enables

With xUnit v3, TestContext.Current.CancellationToken is cancelled when a test times out or is otherwise cancelled. Flowing this token to async operations ensures tests tear down promptly on cancellation rather than hanging until a hard timeout kills the process.

Related

…thods

Replace CancellationToken.None, default, and bare async calls with
TestContext.Current.CancellationToken across all test projects so that
test cancellation is responsive to the xUnit v3 runner.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com>
Copilot AI and others added 5 commits April 6, 2026 15:49
…ests.cs

Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/e9531e94-e7ea-4058-ac0c-71b86ea936ff

Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com>
…ests.cs

Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/e9531e94-e7ea-4058-ac0c-71b86ea936ff

Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/e9531e94-e7ea-4058-ac0c-71b86ea936ff

Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com>
…ests.cs

Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com>
Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com>
…nd-verify-build

# Conflicts:
#	test/Microsoft.NET.Sdk.Razor.Tool.Tests/DefaultRequestDispatcherTest.cs
@MichaelSimons MichaelSimons marked this pull request as ready for review April 14, 2026 15:35
@MichaelSimons MichaelSimons requested review from a team as code owners April 14, 2026 15:35
Copilot AI review requested due to automatic review settings April 14, 2026 15:35
@MichaelSimons MichaelSimons requested review from a team and tmat as code owners April 14, 2026 15:35
Copy link
Copy Markdown
Contributor

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 enforces xUnit1051 across the repository’s test code by removing the global suppression and updating async call sites to flow TestContext.Current.CancellationToken, ensuring async work cooperates with xUnit v3 test cancellation/timeouts.

Changes:

  • Removed xUnit1051 from NoWarn in test/Directory.Build.props.
  • Updated test code to pass TestContext.Current.CancellationToken to async APIs that accept a CancellationToken.
  • Updated Roslyn analyzer test utilities/verifiers to pass the xUnit cancellation token into RunAsync(...).

Reviewed changes

Copilot reviewed 254 out of 254 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/dotnet.Tests/CommandTests/New/WorkloadsInfoProviderTests.cs Passes xUnit cancellation token to GetInstalledWorkloadsAsync.
test/dotnet.Tests/CommandTests/New/SdkInfoProviderTests.cs Passes xUnit cancellation token to SDK info provider async calls.
test/dotnet-watch.Tests/Watch/GlobbingAppTests.cs Passes xUnit cancellation token to Task.Delay used in WhenAny.
test/dotnet-watch.Tests/FileWatcher/FileWatcherTests.cs Passes xUnit cancellation token to Task.Delay waits.
test/dotnet-watch.Tests/CommandLine/ProgramTests.cs Passes xUnit cancellation token to async waits.
test/dotnet-new.IntegrationTests/TemplateEngineSamplesTest.cs Passes xUnit cancellation token into template verification execution.
test/dotnet-new.IntegrationTests/DotnetClassTemplateTests.cs Passes xUnit cancellation token into template verification execution.
test/dotnet-new.IntegrationTests/CommonTemplatesTests.cs Passes xUnit cancellation token into SDK queries + template verification.
test/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/TemplateCommandTests.cs Passes xUnit cancellation token into constraint validation.
test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/ConcatenateFilesTest.cs Passes xUnit cancellation token to Task.Delay.
test/Microsoft.NET.Sdk.Razor.Tool.Tests/ServerLifecycleTest.cs Passes xUnit cancellation token into server runner.
test/Microsoft.NET.Sdk.Razor.Tool.Tests/DefaultRequestDispatcherTest.cs Threads xUnit cancellation token into async server response reads and background task.
test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs Passes xUnit cancellation token to background task runner.
test/Microsoft.NET.Build.Containers.UnitTests/FallbackToHttpMessageHandlerTests.cs Passes xUnit cancellation token to HttpClient.GetAsync.
test/Microsoft.NET.Build.Containers.UnitTests/AuthHandshakeMessageHandlerTests.cs Passes xUnit cancellation token to HttpClient.GetAsync.
test/Microsoft.NET.Build.Containers.IntegrationTests/RegistryTests.cs Passes xUnit cancellation token to registry fetch.
test/Microsoft.DotNet.HotReload.Client.Tests/ArrayBufferWriterTests.cs Passes xUnit cancellation token to stream WriteAsync.
test/Microsoft.AspNetCore.Watch.BrowserRefresh.Tests/ResponseStreamWrapperCompressionTest.cs Passes xUnit cancellation token to wrapper async writes.
test/Directory.Build.props Removes xUnit1051 suppression so the rule is enforced.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Test.Utilities/VisualBasicSecurityCodeFixVerifier`2.cs Imports xUnit and passes xUnit cancellation token to RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Test.Utilities/VisualBasicCodeFixVerifier`2.cs Imports xUnit and passes xUnit cancellation token to RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Test.Utilities/CSharpSecurityCodeFixVerifier`2.cs Imports xUnit and passes xUnit cancellation token to RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Test.Utilities/CSharpCodeFixVerifier`2.cs Imports xUnit and passes xUnit cancellation token to RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlTextReaderDerivedClassDesignSetInsecureSettingsInMethodTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingInApiDesignXmlDocumentDerivedClassDesignConstructorNoSecureXmlResolverTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetFramework.Analyzers/DoNotUseInsecureDtdProcessingAnalyzerTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Usage/UseVolatileReadWriteTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Usage/PreferGenericOverloadsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Usage/DoNotCompareSpanToNullTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Tasks/UseValueTaskCorrectlyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Tasks/DoNotUseWhenAllOrWaitAllWithSingleArgumentTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Tasks/DoNotUseNonCancelableTaskDelayWithWhenAnyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/UseSharedAccessProtocolHttpsOnlyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/UseSecureCookiesASPNetCoreTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/UseDefaultDllImportSearchPathsAttributeTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/UseDefaultDllImportSearchPathsAttributeForLibraryImportAndDllImportTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/UseContainerLevelAccessPolicyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/UseAutoValidateAntiforgeryTokenTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/TaintedDataAnalyzerTestBase.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/SslProtocolsAnalyzerTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/SetViewStateUserKeyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/SetHttpOnlyForHttpCookieTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForXmlInjectionVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForXamlInjectionVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForXPathInjectionVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForSqlInjectionVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForRegexInjectionVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForOpenRedirectVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForLdapInjectionVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForDllInjectionVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/ReviewCodeForCommandExecutionVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/JsonNetTypeNameHandlingTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFInsufficientIterationCountTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseWeakKDFAlgorithmTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureSettingsForJsonNetTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerNetDataContractSerializerWithoutBinderTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerNetDataContractSerializerMethodsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJsonNetWithoutBinderTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerJavascriptSerializerWithSimpleTypeResolverTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterWithoutBinderTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializerBinaryFormatterMethodsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializationObjectStateFormatterTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseInsecureDeserializationLosFormatterTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseDeprecatedSecurityProtocolsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseDSATests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseCreateEncryptorWithNonDefaultIVTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotUseAccountSASTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotInstallRootCertTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotDisableUsingServicePointManagerSecurityProtocolsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotDisableTokenValidationChecksTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotDisableSchUseStrongCryptoTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotDisableRequestValidationTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotDisableHttpClientCRLCheckTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotDisableHTTPHeaderCheckingTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotDisableCertificateValidationTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DoNotAlwaysSkipTokenValidationInDelegatesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInWebSerializableObjectGraphTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInSerializableTypeTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInObjectGraphTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Security/DataSetDataTableInIFormatterObjectGraphTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/UseThreadStaticCorrectlyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/UseRegexMembersTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/UseOrdinalStringComparisonTests.Fixer.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/UseExceptionThrowHelpersTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/UseEnvironmentMembersTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/SpecifyCultureInfoTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/PreferStreamAsyncMemoryOverloadsTestBase.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/PreferJsonElementParseTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkISerializableTypesWithSerializableTests.Fixer.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkAllNonSerializableFieldsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/MarkAllNonSerializableFieldsTests.Fixer.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/LoggerMessageDefineTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/InstantiateArgumentExceptionsCorrectlyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/InitializeStaticFieldsInlineTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/ForwardCancellationTokenToInvocationsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectlyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/DoNotCallEnumerableCastOrOfTypeWithIncompatibleTypesAnalyzerTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureTests.Operators.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureTests.Enums.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureTests.Dependencies.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/CallGCSuppressFinalizeCorrectlyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/AvoidZeroLengthArrayAllocationsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/AvoidUnreliableStreamReadTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Runtime/AvoidConstArraysTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Resources/MarkAssembliesWithNeutralResourcesLanguageTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UseStringMethodCharOverloadWithSingleCharactersTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UseStringContainsCharOverloadWithSingleCharactersTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UseStartsWithInsteadOfIndexOfComparisonWithZeroTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UseSpanClearInsteadOfFillTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UseSearchValuesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UsePropertyInsteadOfCountMethodWhenAvailableTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UseConcreteTypeTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UseCompositeFormatTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/UseAsSpanInsteadOfRangeIndexerTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/RecommendCaseInsensitiveStringComparison.VisualBasic.Tests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/RecommendCaseInsensitiveStringComparison.CSharp.Tests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/PreferReadOnlySpanOverSpanTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/PreferDictionaryTryAddOverGuardedAddTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/PreferConvertToHexStringOverBitConverterTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/DoNotUseCountWhenAnyCanBeUsedTests.Tests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/DoNotUseCountWhenAnyCanBeUsedTests.Code.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/ConstantExpectedTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/AvoidSingleUseOfLocalJsonSerializerOptionsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Performance/AvoidPotentiallyExpensiveCallWhenLoggingTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/InteropServices/UseValidPlatformStringTest.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/InteropServices/DynamicInterfaceCastableImplementationTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/InteropServices/DisableRuntimeMarshallingTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/Data/ReviewSQLQueriesForSecurityVulnerabilitiesTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/SealMethodsThatSatisfyPrivateInterfacesTests.Fixer.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RethrowToPreserveStackDetailsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RemoveEmptyFinalizersTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotPassDisposablesIntoUnawaitedTasksTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotInitializeUnnecessarilyTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotDeclareEventFieldsAsVirtualTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotCallOverridableMethodsInConstructorsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/AvoidMultipleEnumerationsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/Maintainability/UseNameOfInPlaceOfStringTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternalTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsTests*.cs Passes xUnit cancellation token to analyzer test RunAsync across operator-specific test files.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/Maintainability/AvoidUnusedPrivateFieldsTests.cs Passes xUnit cancellation token to analyzer test RunAsync.
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/Tests.cs Passes xUnit cancellation token to analyzer test RunAsync across API design guideline tests.

@MichaelSimons
Copy link
Copy Markdown
Member

/ba-g all failures are related to #53879

@MichaelSimons
Copy link
Copy Markdown
Member

Gentle ping for a code review.

@MiYanni
Copy link
Copy Markdown
Member

MiYanni commented Apr 17, 2026

I'll take a look at this tomorrow.

Copy link
Copy Markdown
Member

@MiYanni MiYanni left a comment

Choose a reason for hiding this comment

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

Is there a way to add an analyzer so we can avoid this being a problem for future tests?

@MichaelSimons
Copy link
Copy Markdown
Member

Is there a way to add an analyzer so we can avoid this being a problem for future tests?

The warning/error comes from the xunit analyzer. This is new to xunit v3. I added the nowarn when migrating to v3 in order to keep the changes to a minimum. Going forward any new violations will break the build.

@MichaelSimons MichaelSimons force-pushed the copilot/rebase-main-and-verify-build branch from 0f7bfdd to 81f5b53 Compare April 21, 2026 13:30
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MichaelSimons
Copy link
Copy Markdown
Member

/ba-g tracked as known intermittent issue with #54014.

@MichaelSimons MichaelSimons merged commit b24e528 into main Apr 21, 2026
22 of 24 checks passed
@MichaelSimons MichaelSimons deleted the copilot/rebase-main-and-verify-build branch April 21, 2026 15:59
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.

5 participants