Skip to content

Exclude non-equivalent IDbContextFactory<TContext>.CreateDbContext() alternatives from VSTHRD103 - #1680

Open
wertzui (wertzui) wants to merge 1 commit into
microsoft:mainfrom
wertzui:bugfix/1679_False_Positive_with_VSTHRD103_and_EF_Core_IDbContextFactory_TContext__CreateDbContext
Open

Exclude non-equivalent IDbContextFactory<TContext>.CreateDbContext() alternatives from VSTHRD103#1680
wertzui (wertzui) wants to merge 1 commit into
microsoft:mainfrom
wertzui:bugfix/1679_False_Positive_with_VSTHRD103_and_EF_Core_IDbContextFactory_TContext__CreateDbContext

Conversation

@wertzui

Copy link
Copy Markdown

Fixes #1679
Builds on the recently closed PR #1665

This PR excludes Microsoft.EntityFrameworkCore.IDbContextFactory<TContext>.CreateDbContext() from VSTHRD103.

Copilot AI lite review requested due to automatic review settings September 7, 2026 20:47
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@wertzui

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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.

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.

False Positive with VSTHRD103 and EF Core IDbContextFactory<TContext>.CreateDbContext()

2 participants