@@ -212,7 +212,7 @@ static void BuildOrWriteId(this ISymbol symbol, Context cx, TextWriter trapFile,
212212 // #123 = @"C`1 : IEnumerable<__self___T>"
213213 // ```
214214 if ( SymbolEqualityComparer . Default . Equals ( symbol , symbolBeingDefined ) )
215- trapFile . Write ( $ "__self__") ;
215+ trapFile . Write ( "__self__" ) ;
216216 else if ( symbol is ITypeSymbol type && type . IdDependsOn ( cx , symbolBeingDefined ) )
217217 type . BuildTypeId ( cx , trapFile , symbolBeingDefined , addBaseClass ) ;
218218 else
@@ -294,12 +294,7 @@ void AddContaining()
294294 }
295295 }
296296
297- if ( named . IsAnonymousType )
298- {
299- AddContaining ( ) ;
300- named . BuildAnonymousName ( cx , trapFile , ( s0 , cx0 , trapFile0 ) => BuildOrWriteId ( s0 , cx0 , trapFile0 , symbolBeingDefined , addBaseClass ) , true ) ;
301- }
302- else if ( named . TypeParameters . IsEmpty )
297+ if ( named . TypeParameters . IsEmpty )
303298 {
304299 AddContaining ( ) ;
305300 trapFile . Write ( named . Name ) ;
@@ -310,20 +305,6 @@ void AddContaining()
310305 trapFile . Write ( named . Name ) ;
311306 trapFile . Write ( "`" ) ;
312307 trapFile . Write ( named . TypeParameters . Length ) ;
313- // Some types such as `<>f__AnonymousType0` are not considered anonymous types by Roslyn,
314- // perhaps because they contain type parameters. We still need to treat them like anonymous
315- // types, though, by adding the underlying properties, in order to disambiguate them
316- if ( named . Name . Contains ( "__AnonymousType" ) )
317- {
318- trapFile . Write ( '<' ) ;
319- trapFile . BuildList ( "," , named . GetMembers ( ) . OfType < IPropertySymbol > ( ) , ( prop , tb0 ) =>
320- {
321- tb0 . Write ( prop . Name ) ;
322- tb0 . Write ( " " ) ;
323- prop . Type . BuildOrWriteId ( cx , tb0 , symbolBeingDefined , addBaseClass ) ;
324- } ) ;
325- trapFile . Write ( '>' ) ;
326- }
327308 }
328309 else
329310 {
@@ -364,22 +345,14 @@ static void BuildNamespace(this INamespaceSymbol ns, Context cx, TextWriter trap
364345 trapFile . Write ( '.' ) ;
365346 }
366347
367- static void BuildAnonymousName ( this INamedTypeSymbol type , Context cx , TextWriter trapFile , Action < ITypeSymbol , Context , TextWriter > subTermAction , bool includeParamName )
348+ static void BuildAnonymousName ( this INamedTypeSymbol type , Context cx , TextWriter trapFile )
368349 {
369- var buildParam = includeParamName
370- ? ( prop , tb0 ) =>
371- {
372- tb0 . Write ( prop . Name ) ;
373- tb0 . Write ( ' ' ) ;
374- subTermAction ( prop . Type , cx , tb0 ) ;
375- }
376- : ( Action < IPropertySymbol , TextWriter > ) ( ( prop , tb0 ) => subTermAction ( prop . Type , cx , tb0 ) ) ;
377350 int memberCount = type . GetMembers ( ) . OfType < IPropertySymbol > ( ) . Count ( ) ;
378351 int hackTypeNumber = memberCount == 1 ? 1 : 0 ;
379352 trapFile . Write ( "<>__AnonType" ) ;
380353 trapFile . Write ( hackTypeNumber ) ;
381354 trapFile . Write ( '<' ) ;
382- trapFile . BuildList ( "," , type . GetMembers ( ) . OfType < IPropertySymbol > ( ) , buildParam ) ;
355+ trapFile . BuildList ( "," , type . GetMembers ( ) . OfType < IPropertySymbol > ( ) , ( prop , tb0 ) => BuildDisplayName ( prop . Type , cx , tb0 ) ) ;
383356 trapFile . Write ( '>' ) ;
384357 }
385358
@@ -444,11 +417,9 @@ public static void BuildNamedTypeDisplayName(this INamedTypeSymbol namedType, Co
444417 }
445418
446419 if ( namedType . IsAnonymousType )
447- {
448- namedType . BuildAnonymousName ( cx , trapFile , ( sub , cx0 , tb0 ) => sub . BuildDisplayName ( cx0 , tb0 ) , false ) ;
449- }
450-
451- trapFile . Write ( namedType . Name ) ;
420+ namedType . BuildAnonymousName ( cx , trapFile ) ;
421+ else
422+ trapFile . Write ( namedType . Name ) ;
452423 if ( namedType . IsGenericType && namedType . TypeKind != TypeKind . Error && namedType . TypeArguments . Any ( ) )
453424 {
454425 trapFile . Write ( '<' ) ;
0 commit comments