You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SmartEnum.List currently is implemented as follows.
publicstaticIReadOnlyCollection<TEnum> List =>
_fromName.Value.Values
.ToList().AsReadOnly();
This API might be frequently called by the consumers, and creating a new list doesn't make much sense. Moreover, this is a property, and the consumer expects that the properties return precalculated fields. They shouldn't contain heavy operations or create additional allocations. If that's the case, then usually the API should be defined as a method, e.g. GetList().
We already keep the collection of discovered enums as Lazy<TEnum[]>. But, even internally this collection is never altered, so I suggest the state be kept as ReadOnlyCollection instead of an array, and List simply would return this field.
The
SmartEnum.List
currently is implemented as follows.This API might be frequently called by the consumers, and creating a new list doesn't make much sense. Moreover, this is a property, and the consumer expects that the properties return precalculated fields. They shouldn't contain heavy operations or create additional allocations. If that's the case, then usually the API should be defined as a method, e.g.
GetList()
.We already keep the collection of discovered enums as
Lazy<TEnum[]>
. But, even internally this collection is never altered, so I suggest the state be kept asReadOnlyCollection
instead of an array, andList
simply would return this field.Note: The
ReadOnlyCollection
is proposed since not all targetted TFMs support newer collection types.The text was updated successfully, but these errors were encountered: