@@ -1036,23 +1036,9 @@ private void DecodeInterceptsLocationChecksumBased(DecodeWellKnownAttributeArgum
1036
1036
}
1037
1037
thisNamespaceNames . Free ( ) ;
1038
1038
1039
- if ( ContainingType . IsGenericType )
1039
+ bool hadError = ReportBadInterceptsLocation ( diagnostics , attributeLocation ) ;
1040
+ if ( hadError )
1040
1041
{
1041
- diagnostics . Add ( ErrorCode . ERR_InterceptorContainingTypeCannotBeGeneric , attributeLocation , this ) ;
1042
- return ;
1043
- }
1044
-
1045
- if ( MethodKind != MethodKind . Ordinary )
1046
- {
1047
- diagnostics . Add ( ErrorCode . ERR_InterceptorMethodMustBeOrdinary , attributeLocation ) ;
1048
- return ;
1049
- }
1050
-
1051
- Debug . Assert ( _lazyCustomAttributesBag . IsEarlyDecodedWellKnownAttributeDataComputed ) ;
1052
- var unmanagedCallersOnly = this . GetUnmanagedCallersOnlyAttributeData ( forceComplete : false ) ;
1053
- if ( unmanagedCallersOnly != null )
1054
- {
1055
- diagnostics . Add ( ErrorCode . ERR_InterceptorCannotUseUnmanagedCallersOnly , attributeLocation ) ;
1056
1042
return ;
1057
1043
}
1058
1044
@@ -1194,23 +1180,9 @@ private void DecodeInterceptsLocationAttributeExperimentalCompat(
1194
1180
return ;
1195
1181
}
1196
1182
1197
- if ( ContainingType . IsGenericType )
1183
+ bool hadError = ReportBadInterceptsLocation ( diagnostics , attributeLocation ) ;
1184
+ if ( hadError )
1198
1185
{
1199
- diagnostics . Add ( ErrorCode . ERR_InterceptorContainingTypeCannotBeGeneric , attributeLocation , this ) ;
1200
- return ;
1201
- }
1202
-
1203
- if ( MethodKind != MethodKind . Ordinary )
1204
- {
1205
- diagnostics . Add ( ErrorCode . ERR_InterceptorMethodMustBeOrdinary , attributeLocation ) ;
1206
- return ;
1207
- }
1208
-
1209
- Debug . Assert ( _lazyCustomAttributesBag . IsEarlyDecodedWellKnownAttributeDataComputed ) ;
1210
- var unmanagedCallersOnly = this . GetUnmanagedCallersOnlyAttributeData ( forceComplete : false ) ;
1211
- if ( unmanagedCallersOnly != null )
1212
- {
1213
- diagnostics . Add ( ErrorCode . ERR_InterceptorCannotUseUnmanagedCallersOnly , attributeLocation ) ;
1214
1186
return ;
1215
1187
}
1216
1188
@@ -1374,6 +1346,31 @@ static void reportFeatureNotEnabled(BindingDiagnosticBag diagnostics, AttributeS
1374
1346
}
1375
1347
}
1376
1348
1349
+ private bool ReportBadInterceptsLocation ( BindingDiagnosticBag diagnostics , Location attributeLocation )
1350
+ {
1351
+ if ( ! this . GetIsNewExtensionMember ( ) && ContainingType . IsGenericType )
1352
+ {
1353
+ diagnostics . Add ( ErrorCode . ERR_InterceptorContainingTypeCannotBeGeneric , attributeLocation , this ) ;
1354
+ return true ;
1355
+ }
1356
+
1357
+ if ( MethodKind != MethodKind . Ordinary )
1358
+ {
1359
+ diagnostics . Add ( ErrorCode . ERR_InterceptorMethodMustBeOrdinary , attributeLocation ) ;
1360
+ return true ;
1361
+ }
1362
+
1363
+ Debug . Assert ( _lazyCustomAttributesBag . IsEarlyDecodedWellKnownAttributeDataComputed ) ;
1364
+ var unmanagedCallersOnly = this . GetUnmanagedCallersOnlyAttributeData ( forceComplete : false ) ;
1365
+ if ( unmanagedCallersOnly != null )
1366
+ {
1367
+ diagnostics . Add ( ErrorCode . ERR_InterceptorCannotUseUnmanagedCallersOnly , attributeLocation ) ;
1368
+ return true ;
1369
+ }
1370
+
1371
+ return false ;
1372
+ }
1373
+
1377
1374
private void DecodeUnmanagedCallersOnlyAttribute ( ref DecodeWellKnownAttributeArguments < AttributeSyntax , CSharpAttributeData , AttributeLocation > arguments )
1378
1375
{
1379
1376
Debug . Assert ( arguments . AttributeSyntaxOpt != null ) ;
0 commit comments