ToImmutable on an immutable collection (CA2009)
هذا المحتوى غير متوفر بلغتك بعد.
Key dotnet.performance.redundant-toimmutable · Severity info · Category performance
Microsoft analyzer CA2009. Flags ToImmutableArray/ToImmutableList and friends called on a collection that already is one.
Incorrect
Section titled “Incorrect”ImmutableArray<string> names = GetNames().ToImmutableArray();var copy = names.ToImmutableArray();Correct
Section titled “Correct”ImmutableArray<string> names = GetNames().ToImmutableArray();var copy = names;