@@ -753,18 +753,37 @@ GeneratorOptions options
753753 : options . MemberDeclaration . OmitEndOfStatement ,
754754 TranslateLanguagePrimitiveType = options . TranslateLanguagePrimitiveTypeDeclaration ,
755755 } ;
756+
756757 var method = m as MethodInfo ;
757- var methodReturnType = method ? . ReturnParameter ? . FormatTypeName (
758+ string ? methodReturnType ;
759+
760+ try {
761+ methodReturnType = method ? . ReturnParameter ? . FormatTypeName (
758762#pragma warning disable SA1114
759763#if SYSTEM_REFLECTION_NULLABILITYINFOCONTEXT
760- nullabilityInfoContext : formattingOptions. NullabilityInfoContext ,
764+ nullabilityInfoContext : formattingOptions. NullabilityInfoContext ,
761765#endif
762- typeWithNamespace: formattingOptions. FormatTypeWithNamespace
766+ typeWithNamespace: formattingOptions. FormatTypeWithNamespace
763767#pragma warning restore SA1114
764- ) ;
765- var methodReturnTypeAttributes = method is null
766- ? null
767- : GenerateParameterAttributeList ( method . ReturnParameter , referencingNamespaces , options ) ;
768+ ) ;
769+ }
770+ catch ( TypeLoadException ) {
771+ // FIXME: https://github.com/smdn/Smdn.Reflection.ReverseGenerating/issues/31
772+ methodReturnType = "<unknown>" ;
773+ }
774+
775+ string ? methodReturnTypeAttributes ;
776+
777+ try {
778+ methodReturnTypeAttributes = method is null
779+ ? null
780+ : GenerateParameterAttributeList ( method . ReturnParameter , referencingNamespaces , options ) ;
781+ }
782+ catch ( TypeLoadException ) {
783+ // FIXME: https://github.com/smdn/Smdn.Reflection.ReverseGenerating/issues/31
784+ methodReturnTypeAttributes = "[...]" ;
785+ }
786+
768787 var methodGenericParameters = m . IsGenericMethod
769788 ? string . Concat (
770789 "<" ,
@@ -782,12 +801,22 @@ GeneratorOptions options
782801 ">"
783802 )
784803 : null ;
785- var methodParameterList = string . Join (
786- ", " ,
787- m . GetParameters ( ) . Select (
788- p => GenerateParameterDeclaration ( p , referencingNamespaces , options )
789- )
790- ) ;
804+
805+ string ? methodParameterList ;
806+
807+ try {
808+ methodParameterList = string . Join (
809+ ", " ,
810+ m . GetParameters ( ) . Select (
811+ p => GenerateParameterDeclaration ( p , referencingNamespaces , options )
812+ )
813+ ) ;
814+ }
815+ catch ( TypeLoadException ) {
816+ // FIXME: https://github.com/smdn/Smdn.Reflection.ReverseGenerating/issues/31
817+ methodParameterList = "..." ;
818+ }
819+
791820 var genericParameters = method is null
792821 ? null
793822 : asDelegateDeclaration
@@ -808,12 +837,17 @@ GeneratorOptions options
808837 string ? methodName = null ;
809838 var isFinalizer = false ;
810839
811- referencingNamespaces ? . UnionWith (
812- m
813- . GetSignatureTypes ( )
814- . Where ( static mpt => ! mpt . ContainsGenericParameters )
815- . SelectMany ( CSharpFormatter . ToNamespaceList )
816- ) ;
840+ try {
841+ referencingNamespaces ? . UnionWith (
842+ m
843+ . GetSignatureTypes ( )
844+ . Where ( static mpt => ! mpt . ContainsGenericParameters )
845+ . SelectMany ( CSharpFormatter . ToNamespaceList )
846+ ) ;
847+ }
848+ catch ( TypeLoadException ) {
849+ // FIXME: https://github.com/smdn/Smdn.Reflection.ReverseGenerating/issues/31
850+ }
817851
818852 if ( asDelegateDeclaration ) {
819853 methodName = m . GetDeclaringTypeOrThrow ( ) . FormatTypeName (
@@ -1241,8 +1275,13 @@ m is MethodInfo methodMayBeAccessor &&
12411275 if ( isAsyncStateMachine )
12421276 sb . Append ( "async " ) ;
12431277
1244- if ( method is not null && method . GetParameters ( ) . Any ( IsParameterUnsafe ) )
1245- sb . Append ( "unsafe " ) ;
1278+ try {
1279+ if ( method is not null && method . GetParameters ( ) . Any ( IsParameterUnsafe ) )
1280+ sb . Append ( "unsafe " ) ;
1281+ }
1282+ catch ( TypeLoadException ) {
1283+ // FIXME: https://github.com/smdn/Smdn.Reflection.ReverseGenerating/issues/31
1284+ }
12461285 }
12471286
12481287 static bool IsParameterUnsafe ( ParameterInfo p )
@@ -1255,8 +1294,13 @@ static bool IsParameterUnsafe(ParameterInfo p)
12551294 return false ;
12561295 }
12571296
1258- if ( member . IsHidingInheritedMember ( nonPublic : true ) )
1259- sb . Append ( "new " ) ;
1297+ try {
1298+ if ( member . IsHidingInheritedMember ( nonPublic : true ) )
1299+ sb . Append ( "new " ) ;
1300+ }
1301+ catch ( TypeLoadException ) {
1302+ // FIXME: https://github.com/smdn/Smdn.Reflection.ReverseGenerating/issues/31
1303+ }
12601304
12611305 SWITCH_MEMBER_TYPE :
12621306 switch ( member ) {
0 commit comments