TypeNameFormatter
TypeNameFormatter copied to clipboard
Support C#11 file-local types
C#11 introduced file-local types, e.g.:
file Widget { }
For such a type TypeNameFormatter's GetFormattedName with default options returns a string like:
<Widget>F17747E0EBC6415B90778A501AEC22976F1C544F0DC79EFDAF3C948D89987F740__Widget
I suggest that with default options the result should be simply Widget, corresponding to the name in C# code.
Perhaps there should be a new option to opt out of that, analagous to NoAnonymousTypes.
Note that my proposal opens the possiblility of collisions where (distinct) file-local types of the same name and namespace in different files would map to the same formatted name, even in Namespaces mode. I think that is fine - there is precedent for allowing collisions, for example in the case of anonymous types.