dotnet / dotnet/docs

Is it possible to describe "typical" performance degradations of using abstract types, like IReadOnlyDictionary<T,T> over Dictionary<T,T>

Open
#38,279 2 comments 5 reactions 0 assignees View on GitHub
:watch: Not Triaged dotnet-fundamentals/svc
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
15h 21m
Merged PRs (30d)
370

Description

### Type of issue

Missing information

### Description

I appreciate the code analysis warnings introduced in .NET 8, but I'm struggling with this one. In general, my firm likes to enforce read-only usage of collections, via `IReadOnlyList` and `IReadOnlyDictionary`, and obviously this warning conflicts with that objective. It would be helpful to many folks getting this warning to understand the extent of the performance degradation from using an interface declaration vs. a concrete type declaration, even if the description of that degradation is very brief and broad (e.g. it's on average 10% slower, or 50% slower to call the virtual method).

### Page URL

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1859

### Content source URL

https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/quality-rules/ca1859.md

### Document Version Independent Id

c8f7f102-2398-9acc-71b8-b0f848a05b92

### Article author

gewarren

### Metadata

* ID: 0e2d460f-c6f3-1e26-d932-b7e69746e513
* Service: **dotnet-fundamentals**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.