@@ -18,31 +18,11 @@ public sealed class ConstructedType : Type
1818 private readonly Type [ ] ? thisTypeArguments ;
1919
2020 private readonly Type ? containingType ;
21-
22- public override IEnumerable < Type > ThisTypeArguments => thisTypeArguments . EnumerateNull ( ) ;
23-
24- public override IEnumerable < Type > ThisGenericArguments => thisTypeArguments . EnumerateNull ( ) ;
25-
26- public override IEnumerable < IExtractionProduct > Contents
27- {
28- get
29- {
30- foreach ( var c in base . Contents )
31- yield return c ;
32-
33- var i = 0 ;
34- foreach ( var type in ThisTypeArguments )
35- {
36- yield return type ;
37- yield return Tuples . cil_type_argument ( this , i ++ , type ) ;
38- }
39- }
40- }
41-
42- public override Type SourceDeclaration => unboundGenericType ;
21+ private readonly NamedTypeIdWriter idWriter ;
4322
4423 public ConstructedType ( Context cx , Type unboundType , IEnumerable < Type > typeArguments ) : base ( cx )
4524 {
25+ idWriter = new NamedTypeIdWriter ( this ) ;
4626 var suppliedArgs = typeArguments . Count ( ) ;
4727 if ( suppliedArgs != unboundType . TotalTypeParametersCount )
4828 throw new InternalError ( "Unexpected number of type arguments in ConstructedType" ) ;
@@ -90,6 +70,28 @@ public override int GetHashCode()
9070 return h ;
9171 }
9272
73+ public override IEnumerable < Type > ThisTypeArguments => thisTypeArguments . EnumerateNull ( ) ;
74+
75+ public override IEnumerable < Type > ThisGenericArguments => thisTypeArguments . EnumerateNull ( ) ;
76+
77+ public override IEnumerable < IExtractionProduct > Contents
78+ {
79+ get
80+ {
81+ foreach ( var c in base . Contents )
82+ yield return c ;
83+
84+ var i = 0 ;
85+ foreach ( var type in ThisTypeArguments )
86+ {
87+ yield return type ;
88+ yield return Tuples . cil_type_argument ( this , i ++ , type ) ;
89+ }
90+ }
91+ }
92+
93+ public override Type SourceDeclaration => unboundGenericType ;
94+
9395 public override Type ? ContainingType => containingType ;
9496
9597 public override string Name => unboundGenericType . Name ;
@@ -107,34 +109,7 @@ public override Type Construct(IEnumerable<Type> typeArguments)
107109
108110 public override void WriteId ( TextWriter trapFile , bool inContext )
109111 {
110- if ( ContainingType != null )
111- {
112- ContainingType . GetId ( trapFile , inContext ) ;
113- trapFile . Write ( '.' ) ;
114- }
115- else
116- {
117- WriteAssemblyPrefix ( trapFile ) ;
118-
119- if ( ! ContainingNamespace . IsGlobalNamespace )
120- {
121- ContainingNamespace . WriteId ( trapFile ) ;
122- trapFile . Write ( '.' ) ;
123- }
124- }
125- trapFile . Write ( unboundGenericType . Name ) ;
126-
127- if ( thisTypeArguments != null && thisTypeArguments . Any ( ) )
128- {
129- trapFile . Write ( '<' ) ;
130- var index = 0 ;
131- foreach ( var t in thisTypeArguments )
132- {
133- trapFile . WriteSeparator ( "," , ref index ) ;
134- t . WriteId ( trapFile ) ;
135- }
136- trapFile . Write ( '>' ) ;
137- }
112+ idWriter . WriteId ( trapFile , inContext ) ;
138113 }
139114
140115 public override void WriteAssemblyPrefix ( TextWriter trapFile ) => unboundGenericType . WriteAssemblyPrefix ( trapFile ) ;
0 commit comments