Nick Craver on Twitter: “I see a lot of MyEnum.Member.ToString() in code reviews across various projects – instead you should use: nameof(MyEnum.Member)”
Posted by jpluimers on 2020/06/25
I love nameof
(and wish many more languages had a similar feature), but since it got introduced so late in the C# language, there is still a lot of old idiom going around. Luckily most of that are not string literals, but you see the occasional reminder to get rid of that cruft: [WayBack] Nick Craver on Twitter: “I see a lot of MyEnum.Member.ToString() in code reviews across various projects – instead you should use: nameof(MyEnum.Member)”.
Luckily, there is a Roslyn analyser for it: [WayBack] Andy Edinborough on Twitter: “Roslynator: https://t.co/3LDUG9WRvE… “.
[WayBack] GitHub – JosefPihrt/Roslynator: A collection of 190+ analyzers and 190+ refactorings for C#, powered by Roslyn.
[WayBack] Antão Almada on Twitter: “I use Enums.NET https://t.co/YaIZWpYVxJ… “ which is a cool library that I’ve used a lot:
[WayBack] GitHub – TylerBrinkley/Enums.NET: Enums.NET is a high-performance type-safe .NET enum utility library
–jeroen
Leave a Reply