Open kartheekp-ms opened 1 year ago
I suggest you also configure the banned API analyser to flag usages of this method.
You could also write your own HasFlag
extension methods for specific enums to keep the same call-site code and avoid the allocations.
Avoid the following code in .NET Framework code paths because there are 2 boxing operations in
flags.HasFlag(MyFlags.Bit1)
method call resulting in unnecessary heap allocations.Prefer the following implementation as there are no heap allocations required.
There are several occurrences of Enum.HasFlag invocation in NuGet Client repo https://github.com/search?q=repo%3ANuGet%2FNuGet.Client%20HasFlag&type=code.
cc @drewnoakes - Thanks for sharing this tip.