-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Enum must have DisplayName to get DisplayName #214
Comments
This is a potentially expensive analyzer as it requires walking via symbols. Expensive as in it will use some CPU and may slow down builds. |
Yeah, it's a shame this logic doesn't exist in netstandard API base. Everyone copies and pastes the same StackOverflow answer for how to do this everywhere. |
If it is in a different library it is tricky, if it is in a nuget package we can specialcase it. |
I guess the solution is to search StackOverflow for all the code snippets and edit the posts so that people are encouraged to specialcase with the nuget package we provide. One more yak to shave before the day is won. |
An alternative is to use heuristics, name of the method, return type etc. simple but could mean false negatives. If we go that route we want separate id for sure so it can be disabled if it is annoying. |
I would if such an approach should have a second assembly of analyzers called ReflectionAnalyzers.Expensive and that the warning in the base library should suggest you can disable it and enable the expensive one instead. |
I would suggest that if you have a package to introduce this api, then that package should probably have it's own analyzer to enforce it's correct usage rather than relying on ReflectionAnalyzers. |
That makes a lot of sense - as a consultant, if I jump from project to project, all I would have to do is pull in my project and have it pull in the analyzer as a private asset and I could automatically know when team members are not following my architecture. |
where GetDisplayName is defined as an extension method:
Is this do-able? In the general case if GetDisplayName is in a different library, how will you know to peer into the extension method to validate its behavior? On one hand, the only scenarios I know of for putting extension methods on enums are exactly this scenario. On the other, I don't want to complicate ReflectionAnalyzers with potentially slow analyzers. Would this be efficient?
The text was updated successfully, but these errors were encountered: