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
CC. @jkotas, are there any concerns on this one or with exposing generic variants of "most" static methods on System.Enum (outside the cost of specializing them in the runtime)?
It does seem like an analyzer could help cover a number of these scenarios and may be a better solution than exposing a generic variant of every method.
My opinion is that it is best to use the built-in bit operators for [Flags] enum operations. It is typically less characters, guaranteed to be fast and gives you full expressivity. I do not see a value in re-recreating longer named equivalents.
TEnum.HasFlag(Enum) can be called with any Enum , not just TEnum.
The built-in bit operators check that the enum types match already.
Activity
EgorBo commentedon Mar 6, 2022
IMO it's not clear from the proposal what this API is supposed to solve/help with.
SupinePandora43 commentedon Mar 6, 2022
TEnum.HasFlag(Enum)can be called with anyEnum, not justTEnum.teo-tsirpanis commentedon Mar 6, 2022
There could be an analyzer that warns about invalid usage of the non-generic
HasFlag.tannergooding commentedon Mar 14, 2022
CC. @jkotas, are there any concerns on this one or with exposing generic variants of "most" static methods on
System.Enum(outside the cost of specializing them in the runtime)?It does seem like an analyzer could help cover a number of these scenarios and may be a better solution than exposing a generic variant of every method.
jkotas commentedon Mar 14, 2022
My opinion is that it is best to use the built-in bit operators for
[Flags]enum operations. It is typically less characters, guaranteed to be fast and gives you full expressivity. I do not see a value in re-recreating longer named equivalents.The built-in bit operators check that the enum types match already.