-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Looks like a convenient meta-generator. 👍
One suggestion, though, which is relevant to a project I help out with, is to do minor re-write of the source files to fully-qualify all named type symbols. The one that would make me unable to use this in that project is the fact that Attribute isn't fully qualified, since there's an Attribute class in that project and global usings that mean it's accessible everywhere.
This would also have the advantage that the definition of the types in the generator project can use more normal style yet be 100% compatible in any project consuming the generator, if there would otherwise be any name collisions.
I think all you'd need to do to change it is something I use in generators I write, which is just one of the other available overloads of the ToDisplayString() method. To make it nice and concise to use in my generators, I also use the static readonly in the below example, but that's of course optional. I also don't have it emit global:: for them, because a project may have defined an extern alias or something.
/// <summary>Fully-qualified symbol name format without the "global::" prefix.</summary>
private static readonly SymbolDisplayFormat _fullyQualifiedSymbolDisplayFormatWithoutGlobal =
SymbolDisplayFormat.FullyQualifiedFormat.WithGlobalNamespaceStyle (SymbolDisplayGlobalNamespaceStyle.Omitted);And then, instead of using the empty overload of ToDisplayString(), use this one:
someNamedTypeSymbol.ToDisplayString (_fullyQualifiedSymbolDisplayFormatWithoutGlobal);