@@ -283,20 +283,27 @@ private static void BuildFunctionPointerTypeId(this IFunctionPointerTypeSymbol f
283283 /// <summary>
284284 /// Workaround for a Roslyn bug: https://github.com/dotnet/roslyn/issues/53943
285285 /// </summary>
286- public static IEnumerable < IFieldSymbol > TupleElementsAdjusted ( this INamedTypeSymbol type ) =>
287- type . TupleElements . Where ( f => f is not null && f . Type is not null ) ;
286+ public static IEnumerable < IFieldSymbol ? > GetTupleElementsMaybeNull ( this INamedTypeSymbol type ) =>
287+ type . TupleElements ;
288288
289289 private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType )
290290 {
291291 if ( ! constructUnderlyingTupleType && named . IsTupleType )
292292 {
293293 trapFile . Write ( '(' ) ;
294- trapFile . BuildList ( "," , named . TupleElementsAdjusted ( ) ,
295- f =>
294+ trapFile . BuildList ( "," , named . GetTupleElementsMaybeNull ( ) ,
295+ ( i , f ) =>
296296 {
297- trapFile . Write ( ( f . CorrespondingTupleField ?? f ) . Name ) ;
298- trapFile . Write ( ":" ) ;
299- f . Type . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType : false ) ;
297+ if ( f is null )
298+ {
299+ trapFile . Write ( $ "null({ i } )") ;
300+ }
301+ else
302+ {
303+ trapFile . Write ( ( f . CorrespondingTupleField ?? f ) . Name ) ;
304+ trapFile . Write ( ":" ) ;
305+ f . Type . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType : false ) ;
306+ }
300307 }
301308 ) ;
302309 trapFile . Write ( ")" ) ;
@@ -470,8 +477,14 @@ private static void BuildNamedTypeDisplayName(this INamedTypeSymbol namedType, C
470477 trapFile . Write ( '(' ) ;
471478 trapFile . BuildList (
472479 "," ,
473- namedType . TupleElementsAdjusted ( ) . Select ( f => f . Type ) ,
474- t => t . BuildDisplayName ( cx , trapFile ) ) ;
480+ namedType . GetTupleElementsMaybeNull ( ) ,
481+ ( i , f ) =>
482+ {
483+ if ( f is null )
484+ trapFile . Write ( $ "null({ i } )") ;
485+ else
486+ f . Type . BuildDisplayName ( cx , trapFile ) ;
487+ } ) ;
475488 trapFile . Write ( ")" ) ;
476489 return ;
477490 }
0 commit comments