@@ -278,49 +278,7 @@ private static void BuildAssembly(IAssemblySymbol asm, TextWriter trapFile, bool
278278
279279 private static void BuildFunctionPointerTypeId ( this IFunctionPointerTypeSymbol funptr , Context cx , TextWriter trapFile , ISymbol symbolBeingDefined )
280280 {
281- trapFile . Write ( "delegate* " ) ;
282- trapFile . Write ( funptr . Signature . CallingConvention . ToString ( ) . ToLowerInvariant ( ) ) ;
283- if ( funptr . Signature . UnmanagedCallingConventionTypes . Any ( ) )
284- {
285- trapFile . Write ( '[' ) ;
286- trapFile . BuildList ( "," , funptr . Signature . UnmanagedCallingConventionTypes ,
287- ( ta , tb0 ) => ta . BuildOrWriteId ( cx , tb0 , symbolBeingDefined )
288- ) ;
289- trapFile . Write ( "]" ) ;
290- }
291-
292- trapFile . Write ( '<' ) ;
293- trapFile . BuildList ( "," , funptr . Signature . Parameters ,
294- ( p , trap ) =>
295- {
296- p . Type . BuildOrWriteId ( cx , trap , symbolBeingDefined ) ;
297- switch ( p . RefKind )
298- {
299- case RefKind . Out :
300- trap . Write ( " out" ) ;
301- break ;
302- case RefKind . In :
303- trap . Write ( " in" ) ;
304- break ;
305- case RefKind . Ref :
306- trap . Write ( " ref" ) ;
307- break ;
308- }
309- } ) ;
310-
311- if ( funptr . Signature . Parameters . Any ( ) )
312- {
313- trapFile . Write ( "," ) ;
314- }
315-
316- funptr . Signature . ReturnType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ;
317-
318- if ( funptr . Signature . ReturnsByRef )
319- trapFile . Write ( " ref" ) ;
320- if ( funptr . Signature . ReturnsByRefReadonly )
321- trapFile . Write ( " readonly ref" ) ;
322-
323- trapFile . Write ( '>' ) ;
281+ BuildFunctionPointerSignature ( funptr , trapFile , ( s , tw ) => s . BuildOrWriteId ( cx , tw , symbolBeingDefined ) ) ;
324282 }
325283
326284 private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , TextWriter trapFile , ISymbol symbolBeingDefined , bool addBaseClass , bool constructUnderlyingTupleType )
@@ -468,26 +426,24 @@ public static void BuildDisplayName(this ITypeSymbol type, Context cx, TextWrite
468426 }
469427 }
470428
471- private static void BuildFunctionPointerTypeDisplayName ( this IFunctionPointerTypeSymbol funptr , Context cx , TextWriter trapFile )
429+ public static void BuildFunctionPointerSignature ( IFunctionPointerTypeSymbol funptr , TextWriter trapFile ,
430+ Action < ITypeSymbol , TextWriter > buildNested )
472431 {
473432 trapFile . Write ( "delegate* " ) ;
474433 trapFile . Write ( funptr . Signature . CallingConvention . ToString ( ) . ToLowerInvariant ( ) ) ;
475434
476435 if ( funptr . Signature . UnmanagedCallingConventionTypes . Any ( ) )
477436 {
478437 trapFile . Write ( '[' ) ;
479- trapFile . BuildList (
480- "," ,
481- funptr . Signature . UnmanagedCallingConventionTypes ,
482- ( t , tb0 ) => t . BuildDisplayName ( cx , tb0 ) ) ;
438+ trapFile . BuildList ( "," , funptr . Signature . UnmanagedCallingConventionTypes , buildNested ) ;
483439 trapFile . Write ( "]" ) ;
484440 }
485441
486442 trapFile . Write ( '<' ) ;
487443 trapFile . BuildList ( "," , funptr . Signature . Parameters ,
488444 ( p , trap ) =>
489445 {
490- p . Type . BuildDisplayName ( cx , trapFile ) ;
446+ buildNested ( p . Type , trap ) ;
491447 switch ( p . RefKind )
492448 {
493449 case RefKind . Out :
@@ -507,16 +463,21 @@ private static void BuildFunctionPointerTypeDisplayName(this IFunctionPointerTyp
507463 trapFile . Write ( "," ) ;
508464 }
509465
510- funptr . Signature . ReturnType . BuildDisplayName ( cx , trapFile ) ;
466+ buildNested ( funptr . Signature . ReturnType , trapFile ) ;
511467
512468 if ( funptr . Signature . ReturnsByRef )
513469 trapFile . Write ( " ref" ) ;
514470 if ( funptr . Signature . ReturnsByRefReadonly )
515- trapFile . Write ( " readonly ref" ) ;
471+ trapFile . Write ( " ref readonly " ) ;
516472
517473 trapFile . Write ( '>' ) ;
518474 }
519475
476+ private static void BuildFunctionPointerTypeDisplayName ( this IFunctionPointerTypeSymbol funptr , Context cx , TextWriter trapFile )
477+ {
478+ BuildFunctionPointerSignature ( funptr , trapFile , ( s , tw ) => s . BuildDisplayName ( cx , tw ) ) ;
479+ }
480+
520481 private static void BuildNamedTypeDisplayName ( this INamedTypeSymbol namedType , Context cx , TextWriter trapFile , bool constructUnderlyingTupleType )
521482 {
522483 if ( ! constructUnderlyingTupleType && namedType . IsTupleType )
0 commit comments