@@ -280,17 +280,30 @@ private static void BuildAssembly(IAssemblySymbol asm, EscapingTextWriter trapFi
280280 private static void BuildFunctionPointerTypeId ( this IFunctionPointerTypeSymbol funptr , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined ) =>
281281 BuildFunctionPointerSignature ( funptr , trapFile , s => s . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ) ;
282282
283+ /// <summary>
284+ /// Workaround for a Roslyn bug: https://github.com/dotnet/roslyn/issues/53943
285+ /// </summary>
286+ public static IEnumerable < IFieldSymbol ? > GetTupleElementsMaybeNull ( this INamedTypeSymbol type ) =>
287+ type . TupleElements ;
288+
283289 private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType )
284290 {
285291 if ( ! constructUnderlyingTupleType && named . IsTupleType )
286292 {
287293 trapFile . Write ( '(' ) ;
288- trapFile . BuildList ( "," , named . TupleElements ,
289- f =>
294+ trapFile . BuildList ( "," , named . GetTupleElementsMaybeNull ( ) ,
295+ ( i , f ) =>
290296 {
291- trapFile . Write ( ( f . CorrespondingTupleField ?? f ) . Name ) ;
292- trapFile . Write ( ":" ) ;
293- 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+ }
294307 }
295308 ) ;
296309 trapFile . Write ( ")" ) ;
@@ -464,8 +477,14 @@ private static void BuildNamedTypeDisplayName(this INamedTypeSymbol namedType, C
464477 trapFile . Write ( '(' ) ;
465478 trapFile . BuildList (
466479 "," ,
467- namedType . TupleElements . Select ( f => f . Type ) ,
468- 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+ } ) ;
469488 trapFile . Write ( ")" ) ;
470489 return ;
471490 }
0 commit comments