Tag: typename

在Visual Studio中有一种方法可以轻松获得合格的类型名称吗?

我正在寻找一个扩展/进程来获取Visual Studio中对象的程序集限定类型名称。 我知道你可以写一个快速的控制台应用程序输出这个但发现它是一个笨拙的过程。 理想情况下,我希望能够右键单击类型名称,并可以选择将其程序集限定名复制到剪贴板,以便粘贴到我的DI Container的配置文件中。

如何解析C#generics类型名称?

如何解析格式为List或Dictionary C#样式generics类型名称,甚至更复杂的Dictionary<string,Dictionary> 。 假设这些名称是字符串,实际上可能不代表现有类型。 它应该很容易解析BogusClass<A,B,Vector> 。 为了清楚List`1[[System.Int32]] ,我对解析格式为List`1[[System.Int32]] .NET内部类型名称不感兴趣,而是对源代码中出现的实际C#类型名称感兴趣,使用点或不使用名称空间限定符符号。 正则表达式是因为这些是嵌套结构。 我想也许System.CodeDom.CodeTypeReference构造函数会为我解析它,因为它有string BaseType和CodeTypeReferenceCollection TypeArguments成员,但那些显然需要手动设置。 CodeTypeReference是我需要的一种结构: class TypeNameStructure { public string Name; public TypeNameStructure[] GenericTypeArguments; public bool IsGenericType{get;} public bool IsArray{get;} //would be nice to detect this as well public TypeNameStructure( string friendlyCSharpName ) { //Parse friendlyCSharpName into name and generic type arguments recursively } } 框架中是否有任何现有的类来实现这种类型名称解析? […]