Reputation: 552
In .Net I can (and should) apply the FlagsAttribute
to enums that are used as bitmask. This way I can use the HasFlag()
-method and ReSharper doesn't get angry if I do bitwise operations on them.
In a project I have to use an enum from a dll written in vb6 which of course does not have the FlagsAttribute
. (I have seen the code, the values are bit flags.)
Eventhough VisualStudio marks it as red in code whenever I use .HasFlag()
, it compiles and runs just fine. And I can "disable" the ReSharper warning on bitwise operations by always casting the enum to int (or suppress it with a comment, …)
Yet I wonder if there is a somewhat cleaner approach like marking the enum as flags once?
Upvotes: 0
Views: 273
Reputation: 499132
You can't mark an external dependency - if you have a dll
, whatever its source, you can't simply change its internals (well, you can, but that would require rewriting the binary).
One option is to write your own flags enumeration and a mapper between the VB6 one and yours and simply use your version in your code and simply ignore the issues in the mapping layer.
Upvotes: 3