@@ -122,6 +122,24 @@ public static bool ContainsTypeParameters(this ITypeSymbol type, Context cx, ISy
122
122
}
123
123
}
124
124
125
+ /// <summary>
126
+ /// Write the identifier for the symbol <paramref name="type"/> to the trapfile <paramref name="trapFile"/>.
127
+ /// If any nested types are found in the identifier, then they are written out explicitly, without
128
+ /// prefixing the assembly ID.
129
+ /// </summary>
130
+ /// <param name="type">The type to write.</param>
131
+ /// <param name="cx">The extraction context.</param>
132
+ /// <param name="trapFile">The trap file to write to.</param>
133
+ /// <param name="symbolBeingDefined">The outer symbol being defined (to avoid recursive ids).</param>
134
+ public static void BuildNestedTypeId ( this ITypeSymbol type , Context cx , TextWriter trapFile , ISymbol symbolBeingDefined )
135
+ {
136
+ void WriteType ( Context cx , TextWriter trapFile , ITypeSymbol symbol , ISymbol symbolBeingDefined )
137
+ {
138
+ symbol . BuildTypeId ( cx , trapFile , false , symbolBeingDefined , WriteType ) ;
139
+ }
140
+ WriteType ( cx , trapFile , type , symbolBeingDefined ) ;
141
+ }
142
+
125
143
/// <summary>
126
144
/// Constructs a unique string for this type symbol.
127
145
///
@@ -130,8 +148,10 @@ public static bool ContainsTypeParameters(this ITypeSymbol type, Context cx, ISy
130
148
/// </summary>
131
149
/// <param name="cx">The extraction context.</param>
132
150
/// <param name="trapFile">The trap builder used to store the result.</param>
151
+ /// <param name="prefix">Whether to prefix the type ID with the assembly ID.</param>
152
+ /// <param name="symbolBeingDefined">The outer symbol being defined (to avoid recursive ids).</param>
133
153
/// <param name="subTermAction">The action to apply to syntactic sub terms of this type.</param>
134
- public static void BuildTypeId ( this ITypeSymbol type , Context cx , TextWriter trapFile , bool prefix , ISymbol SymbolBeingDefined , Action < Context , TextWriter , ITypeSymbol , ISymbol > subTermAction )
154
+ public static void BuildTypeId ( this ITypeSymbol type , Context cx , TextWriter trapFile , bool prefix , ISymbol symbolBeingDefined , Action < Context , TextWriter , ITypeSymbol , ISymbol > subTermAction )
135
155
{
136
156
if ( type . SpecialType != SpecialType . None && ! ( type is INamedTypeSymbol n && n . IsGenericType ) )
137
157
{
@@ -150,7 +170,7 @@ public static void BuildTypeId(this ITypeSymbol type, Context cx, TextWriter tra
150
170
{
151
171
case TypeKind . Array :
152
172
var array = ( IArrayTypeSymbol ) type ;
153
- subTermAction ( cx , trapFile , array . ElementType , SymbolBeingDefined ) ;
173
+ subTermAction ( cx , trapFile , array . ElementType , symbolBeingDefined ) ;
154
174
array . BuildArraySuffix ( trapFile ) ;
155
175
return ;
156
176
case TypeKind . Class :
@@ -160,16 +180,16 @@ public static void BuildTypeId(this ITypeSymbol type, Context cx, TextWriter tra
160
180
case TypeKind . Delegate :
161
181
case TypeKind . Error :
162
182
var named = ( INamedTypeSymbol ) type ;
163
- named . BuildNamedTypeId ( cx , trapFile , prefix , SymbolBeingDefined , subTermAction ) ;
183
+ named . BuildNamedTypeId ( cx , trapFile , prefix , symbolBeingDefined , subTermAction ) ;
164
184
return ;
165
185
case TypeKind . Pointer :
166
186
var ptr = ( IPointerTypeSymbol ) type ;
167
- subTermAction ( cx , trapFile , ptr . PointedAtType , SymbolBeingDefined ) ;
187
+ subTermAction ( cx , trapFile , ptr . PointedAtType , symbolBeingDefined ) ;
168
188
trapFile . Write ( '*' ) ;
169
189
return ;
170
190
case TypeKind . TypeParameter :
171
191
var tp = ( ITypeParameterSymbol ) type ;
172
- if ( ! SymbolEqualityComparer . Default . Equals ( tp . ContainingSymbol , SymbolBeingDefined ) )
192
+ if ( ! SymbolEqualityComparer . Default . Equals ( tp . ContainingSymbol , symbolBeingDefined ) )
173
193
{
174
194
switch ( tp . TypeParameterKind )
175
195
{
@@ -179,7 +199,7 @@ public static void BuildTypeId(this ITypeSymbol type, Context cx, TextWriter tra
179
199
trapFile . Write ( '_' ) ;
180
200
break ;
181
201
case TypeParameterKind . Type :
182
- subTermAction ( cx , trapFile , tp . ContainingType , SymbolBeingDefined ) ;
202
+ subTermAction ( cx , trapFile , tp . ContainingType , symbolBeingDefined ) ;
183
203
trapFile . Write ( '_' ) ;
184
204
break ;
185
205
}
0 commit comments