Open taylorchasewhite opened 11 months ago
From https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-8/, it appears to be ~20%. That said, at a difference of 0.3ns, I'll personally stick to IReadOnlyXyz
types except on the hottest of paths.
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
andIReadOnlyDictionary
, 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