lundi 10 août 2020

How to get simplified ReturnType through MethodInfo?

Using reflection to obtain a MethodInfo, I want to get a more user-friendly version of the ReturnType for some self-documentation.

Currently this methodInfo.ReturnType.Name returns something like Dictionary2 or IEnumerable1.

While this methodInfo.ReturnType.FullName; returns a far too lengthy version like System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral]]

or System.Collections.Generic.IEnumerable`1[[ProjectName.Namespace.Item, ProjectName, Version=1.9.0.0, Culture=neutral, PublicKeyToken=null]]

I could theoretically do some string manipulation to get rid of all of the excess information being displayed, but I would like to avoid that if possible.





Aucun commentaire:

Enregistrer un commentaire