Fix xUnit1051: pass TestContext.Current.CancellationToken to async methods#53714
Open
Fix xUnit1051: pass TestContext.Current.CancellationToken to async methods#53714
Conversation
…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 created this pull request from a session on behalf of
MichaelSimons
April 6, 2026 13:19
View session
…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
Contributor
There was a problem hiding this comment.
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
xUnit1051fromNoWarnintest/Directory.Build.props. - Updated test code to pass
TestContext.Current.CancellationTokento async APIs that accept aCancellationToken. - 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
approved these changes
Apr 14, 2026
Member
|
/ba-g all failures are related to #53879 |
Member
|
Gentle ping for a code review. |
Member
|
I'll take a look at this tomorrow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves xUnit1051 violations across the test codebase by passing
TestContext.Current.CancellationTokento async methods that accept aCancellationTokenparameter.Changes
test/Directory.Build.props— the rule is now enforced rather than globally suppressed.TestContext.Current.CancellationTokento ~1,400 async call sites across:src/Microsoft.CodeAnalysis.NetAnalyzers/tests/)test/)What this enables
With xUnit v3,
TestContext.Current.CancellationTokenis 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