File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . IO ;
3- using System . Linq ;
43using System . Reflection . Metadata ;
54using System . Reflection . PortableExecutable ;
65
@@ -83,7 +82,7 @@ public void WriteAssemblyPrefix(TextWriter trapFile)
8382 trapFile . Write ( GetString ( def . Name ) ) ;
8483 trapFile . Write ( '_' ) ;
8584 trapFile . Write ( def . Version . ToString ( ) ) ;
86- trapFile . Write ( "::" ) ;
85+ trapFile . Write ( Entities . Type . AssemblyTypeNameSeparator ) ;
8786 }
8887
8988 public Entities . TypeSignatureDecoder TypeSignatureDecoder { get ; }
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ namespace Semmle.Extraction.CIL.Entities
1212 public abstract class Type : TypeContainer , IMember
1313 {
1414 public override string IdSuffix => ";cil-type" ;
15- internal const string PrimitiveTypePrefix = "builtin:" ;
15+ internal const string AssemblyTypeNameSeparator = "::" ;
16+ internal const string PrimitiveTypePrefix = "builtin" + AssemblyTypeNameSeparator + "System." ;
1617
1718 protected Type ( Context cx ) : base ( cx ) { }
1819
@@ -72,6 +73,21 @@ public virtual IEnumerable<Type> ThisTypeArguments
7273
7374 public void GetId ( TextWriter trapFile , bool inContext ) => WriteId ( trapFile , inContext ) ;
7475
76+ /// <summary>
77+ /// Returns the friendly qualified name of types, such as
78+ /// ``"System.Collection.Generic.List`1"`` or
79+ /// ``"System.Collection.Generic.List<System.Int32>"``.
80+ ///
81+ /// Note that method/type generic type parameters never show up in the returned name.
82+ /// </summary>
83+ public string GetQualifiedName ( )
84+ {
85+ using var writer = new StringWriter ( ) ;
86+ GetId ( writer , false ) ;
87+ var name = writer . ToString ( ) ;
88+ return name . Substring ( name . IndexOf ( AssemblyTypeNameSeparator ) + 2 ) ;
89+ }
90+
7591 public abstract CilTypeKind Kind { get ; }
7692
7793 public override IEnumerable < IExtractionProduct > Contents
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ public override void WriteAssemblyPrefix(TextWriter trapFile)
114114 trapFile . Write ( Cx . GetString ( assemblyDef . Name ) ) ;
115115 trapFile . Write ( '_' ) ;
116116 trapFile . Write ( assemblyDef . Version . ToString ( ) ) ;
117- trapFile . Write ( "::" ) ;
117+ trapFile . Write ( Entities . Type . AssemblyTypeNameSeparator ) ;
118118 break ;
119119 default :
120120 Cx . WriteAssemblyPrefix ( trapFile ) ;
You can’t perform that action at this time.
0 commit comments