-
Notifications
You must be signed in to change notification settings - Fork 4
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
Generic Type Names Display in Graphs #2
Comments
Maybe? I know we've run into folks who have tried to load two versions of the same assembly into an AppDomain and wonder why they resolve an At the same time, I get the point on graph readability; and maybe if you're getting graphs that isn't the place to troubleshoot that sort of issue? I haven't seen any code snippets or libraries that convert the type names back to something readable. Seems like we'd be doing some level of code generation based on a type name to get it back to a C# look/format. |
We could have the prettification optional, defaulted to On, to allow for people who want to see absolutely everything. At a simple level, the display pseudo-code might just be:
Will that be enough for most cases? |
I think you're going to get into weirdness if it's an I'm also sort of torn on whether we should trim namespaces. I think they should stay, so you get The "simplest thing that could possibly work" might be a regex against the type name that's already been resolved. For example:
OK, yeah, that's long and not simple looking, but it breaks down reasonably.
A .NET identifier is matched by this set of Unicode character codes. That is, the first character has to be a letter; but after that it can be letters or numbers. I wasn't precise here since I basically allow something like After that, you have the
The count of parameters, so just drop that. Then the opening bracket that has the types inside.
Here's where I get fuzzy. I'm not sure if each generic type is in brackets, like
Match the type name there, but drop all the crap about version and culture. Finally, closing bracket.
Obviously I haven't tested it other than on a quick online regex tester. Point being, though, the work of recursion is already done for us, so we could do string manipulation to get the pretty name out rather than trying to redo all the work. Another option would be to do something with Roslyn to generate C# code based on the name and use what gets generated, since that'll be correct guaranteed. |
Ahhh, regexes, my old friend. Could do it that way I suppose. The Roslyn CodeDOM way might be easier to maintain in the future I'd argue. It's also not a super complex API to use. If it helps I've used CodeDOM to generate extension methods before, here: https://github.com/autostep/AutoStep/blob/develop/tools/ExtensionMethodsGenerator/Program.cs |
The Roslyn way would also probably be more reliable. |
Just adding this to the v6 release so we can track it. |
Do you think it's worth prettifying generic type names in the graph? For example, when I resolve an IEnumerable of a Service I get:
It might be nice to be able to give formatted generic names; people use generic services a lot.
The text was updated successfully, but these errors were encountered: