Page MenuHomePhabricator

csharp: CA1717 - Add [Flags] for enums
ClosedPublic

Authored by lauromoura on Nov 20 2019, 2:45 PM.

Details

Summary

Using the naive approach of checking if the name ends with Flags.

Ref T8411

Depends on D10708

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
lauromoura created this revision.Nov 20 2019, 2:45 PM
lauromoura requested review of this revision.Nov 20 2019, 2:45 PM

Oooohhh... I had not thought about this. C# needs to know which EO enums are flags and which are not, and this info is not in Eolian... this is going to be hard without introducing new Eolian syntax.
Well, if the "s" trick does not work, I guess we can always add "[Flags]" unconditionally. What's the worst that could happen?

Oooohhh... I had not thought about this. C# needs to know which EO enums are flags and which are not, and this info is not in Eolian... this is going to be hard without introducing new Eolian syntax.
Well, if the "s" trick does not work, I guess we can always add "[Flags]" unconditionally. What's the worst that could happen?

From what I could find, [Flags] is just a hint that the enum is a flag-like enum and can have its values combined.

https://docs.microsoft.com/en-us/dotnet/api/system.flagsattribute?view=netframework-4.8

From what I could find, [Flags] is just a hint that the enum is a flag-like enum and can have its values combined.

Exactly, so nothing very bad, except that we would be telling the users that flags can be combined when they cannot...

Update making it check only for the "Flags" suffix.

A special check is made for Efl.Ui.InputHints while the Text api is changing.

lauromoura edited the summary of this revision. (Show Details)Nov 22 2019, 11:37 AM
felipealmeida accepted this revision.Nov 25 2019, 9:02 AM
This revision is now accepted and ready to land.Nov 25 2019, 9:02 AM

@lauromoura Did you check that all EO enums which are actually flags have the Flags suffix?
This would be very cool (and lucky for us) and we should enforce it somehow. Even if it is only in documentation.

If Efl.Ui.Input_Hints is the only one not following the rule, we can rename it since it's still beta.

This revision was automatically updated to reflect the committed changes.