Exclude non-equivalent IDbContextFactory<TContext>.CreateDbContext() alternatives from VSTHRD103 - #1680
Open
wertzui (wertzui) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Author
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
🟢 Approval recommended
The change is data-driven, includes a targeted regression test, and updates documentation consistently with existing exclusion patterns.
Pull request overview
This pull request addresses a VSTHRD103 false positive by adding Entity Framework Core IDbContextFactory<TContext>.CreateDbContext() to the analyzer’s built-in “sync methods to exclude” list, so the analyzer no longer recommends CreateDbContextAsync() for this API.
Changes:
- Add
[Microsoft.EntityFrameworkCore.IDbContextFactory1]::CreateDbContext` to the shipped framework exclusions file used by VSTHRD103. - Extend the existing regression test that validates known framework APIs with non-equivalent async alternatives do not generate VSTHRD103.
- Update analyzer configuration documentation to include the new EF Core exclusion.
File summaries
| File | Description |
|---|---|
| test/Microsoft.VisualStudio.Threading.Analyzers.Tests/VSTHRD103UseAsyncOptionAnalyzerTests.cs | Adds a regression assertion that IDbContextFactory<TContext>.CreateDbContext() does not trigger VSTHRD103. |
| src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/buildTransitive/AdditionalFiles/vs-threading.SyncMethodsToExcludeFromVSTHRD103.frameworks.txt | Ships the new framework exclusion entry for EF Core IDbContextFactory<TContext>.CreateDbContext. |
| docfx/analyzers/configuration.md | Documents the new default exclusion in the VSTHRD103 configuration section. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Fixes #1679
Builds on the recently closed PR #1665
This PR excludes
Microsoft.EntityFrameworkCore.IDbContextFactory<TContext>.CreateDbContext()from VSTHRD103.