This rule flags places where a CreateBuilder() or similar method is called to create a builder type that adds elements and finally constructs a collection type that has the CollectionBuilderAttribute attribute (for example, by calling ImmutableArray<T>.Builder.ToImmutable()). Instead, a collection expression ([...]) could be used to initialize the collection.
Piezīme
This rule requires more recent versions of the immutable APIs (for example, System.Collections.Immutable), which opt in to the collection-expression pattern.
Options
Options specify the behavior that you want the rule to enforce. For information about configuring options, see Option format.
dotnet_style_prefer_collection_expression
Property
Value
Description
Option name
dotnet_style_prefer_collection_expression
Option values
true | when_types_exactly_match
Prefer to use collection expressions only when types match exactly.
when_types_loosely_match (.NET 9 and later versions)*
Šī satura avotu var atrast vietnē GitHub, kur varat arī izveidot un pārskatīt problēmas un atgādāšanas pieprasījumus. Lai iegūtu papildinformāciju, skatiet mūsu līdzstrādnieku rokasgrāmatu.
.NET atsauksmes
.NET ir atklātā pirmkoda projekts. Atlasiet saiti, lai sniegtu atsauksmes:
Pievienojieties meetup sērijai, lai kopā ar citiem izstrādātājiem un ekspertiem izveidotu mērogojamus AI risinājumus, kuru pamatā ir reālas lietošanas gadījumi.