Make CA1849 configurable to exclude certain type or APIs #6860
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers
help wanted
The issue is up-for-grabs, and can be claimed by commenting
Analyzer
Diagnostic ID: CA1849
Describe the improvement
CA1849
Call async methods when in an async method
causing false positives in case the Async version of the API is not recommended, for example in #6684Using
DbContext.AddRange(params object[])
reports a warning and suggests usingDbContext.AddRangeAsync(params object[])
.However the
AddRangeAsync()
method exists only for very special edge cases and should not be used by default, as described on https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontext.addrangeasync?view=efcore-7.0Same issue happening with
DbSet<TEntity>.Add(TEntity entity)
andDbSet<TEntity>.AddRange(params TEntity[] entities)
dotnet/efcore#31431Describe suggestions on how to achieve the rule
We need make the rule configurable so that it could exclude the above APIs (or the type) from diagnostics
Additional context
Originally posted by @jeffhandley in #6858 (review)
The text was updated successfully, but these errors were encountered: