@@ -282,54 +282,60 @@ private static void BuildFunctionPointerTypeId(this IFunctionPointerTypeSymbol f
282282 public static IEnumerable < IFieldSymbol ? > GetTupleElementsMaybeNull ( this INamedTypeSymbol type ) =>
283283 type . TupleElements ;
284284
285- private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType )
285+ private static void BuildQualifierAndName ( INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined )
286286 {
287- if ( ! constructUnderlyingTupleType && named . IsTupleType )
287+ if ( named . ContainingType is not null )
288288 {
289- trapFile . Write ( '(' ) ;
290- trapFile . BuildList ( "," , named . GetTupleElementsMaybeNull ( ) ,
291- ( i , f ) =>
292- {
293- if ( f is null )
294- {
295- trapFile . Write ( $ "null({ i } )") ;
296- }
297- else
298- {
299- trapFile . Write ( ( f . CorrespondingTupleField ?? f ) . Name ) ;
300- trapFile . Write ( ":" ) ;
301- f . Type . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType : false ) ;
302- }
303- }
304- ) ;
305- trapFile . Write ( ")" ) ;
306- return ;
289+ named . ContainingType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType : false ) ;
290+ trapFile . Write ( '.' ) ;
307291 }
308-
309- void AddContaining ( )
292+ else if ( named . ContainingNamespace is not null )
310293 {
311- if ( named . ContainingType is not null )
312- {
313- named . ContainingType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType : false ) ;
314- trapFile . Write ( '.' ) ;
315- }
316- else if ( named . ContainingNamespace is not null )
294+ if ( cx . ShouldAddAssemblyTrapPrefix && named . ContainingAssembly is not null )
295+ BuildAssembly ( named . ContainingAssembly , trapFile ) ;
296+ named . ContainingNamespace . BuildNamespace ( cx , trapFile ) ;
297+ }
298+
299+ var name = named . IsFileLocal ? named . MetadataName : named . Name ;
300+ trapFile . Write ( name ) ;
301+ }
302+
303+ private static void BuildTupleId ( INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined )
304+ {
305+ trapFile . Write ( '(' ) ;
306+ trapFile . BuildList ( "," , named . GetTupleElementsMaybeNull ( ) ,
307+ ( i , f ) =>
317308 {
318- if ( cx . ShouldAddAssemblyTrapPrefix && named . ContainingAssembly is not null )
319- BuildAssembly ( named . ContainingAssembly , trapFile ) ;
320- named . ContainingNamespace . BuildNamespace ( cx , trapFile ) ;
309+ if ( f is null )
310+ {
311+ trapFile . Write ( $ "null({ i } )") ;
312+ }
313+ else
314+ {
315+ trapFile . Write ( ( f . CorrespondingTupleField ?? f ) . Name ) ;
316+ trapFile . Write ( ":" ) ;
317+ f . Type . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType : false ) ;
318+ }
321319 }
320+ ) ;
321+ trapFile . Write ( ")" ) ;
322+ }
323+
324+ private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType )
325+ {
326+ if ( ! constructUnderlyingTupleType && named . IsTupleType )
327+ {
328+ BuildTupleId ( named , cx , trapFile , symbolBeingDefined ) ;
329+ return ;
322330 }
323331
324332 if ( named . TypeParameters . IsEmpty )
325333 {
326- AddContaining ( ) ;
327- trapFile . Write ( named . Name ) ;
334+ BuildQualifierAndName ( named , cx , trapFile , symbolBeingDefined ) ;
328335 }
329336 else if ( named . IsReallyUnbound ( ) )
330337 {
331- AddContaining ( ) ;
332- trapFile . Write ( named . Name ) ;
338+ BuildQualifierAndName ( named , cx , trapFile , symbolBeingDefined ) ;
333339 trapFile . Write ( "`" ) ;
334340 trapFile . Write ( named . TypeParameters . Length ) ;
335341 }
0 commit comments