@@ -465,8 +465,9 @@ private static PluginClassInfo GetValidPluginInfo(
465
465
ImmutableArray < PluginClassInfo > pluginClasses ,
466
466
SourceProductionContext context )
467
467
{
468
- var nonNullExistClasses = pluginClasses . Where ( p => p != null && p . PropertyName != null ) . ToArray ( ) ;
469
- if ( nonNullExistClasses . Length == 0 )
468
+ // If p is null, this class does not implement IPluginI18n
469
+ var iPluginI18nClasses = pluginClasses . Where ( p => p != null ) . ToArray ( ) ;
470
+ if ( iPluginI18nClasses . Length == 0 )
470
471
{
471
472
context . ReportDiagnostic ( Diagnostic . Create (
472
473
SourceGeneratorDiagnostics . CouldNotFindPluginEntryClass ,
@@ -475,7 +476,24 @@ private static PluginClassInfo GetValidPluginInfo(
475
476
return null ;
476
477
}
477
478
478
- foreach ( var pluginClass in nonNullExistClasses )
479
+ // If p.PropertyName is null, this class does not have PluginInitContext property
480
+ var iPluginI18nClassesWithContext = iPluginI18nClasses . Where ( p => p . PropertyName != null ) . ToArray ( ) ;
481
+ if ( iPluginI18nClassesWithContext . Length == 0 )
482
+ {
483
+ foreach ( var pluginClass in iPluginI18nClasses )
484
+ {
485
+ context . ReportDiagnostic ( Diagnostic . Create (
486
+ SourceGeneratorDiagnostics . CouldNotFindContextProperty ,
487
+ pluginClass . Location ,
488
+ pluginClass . ClassName
489
+ ) ) ;
490
+ }
491
+ return null ;
492
+ }
493
+
494
+ // Rest classes have implemented IPluginI18n and have PluginInitContext property
495
+ // Check if the property is valid
496
+ foreach ( var pluginClass in iPluginI18nClassesWithContext )
479
497
{
480
498
if ( pluginClass . IsValid == true )
481
499
{
0 commit comments