@@ -100,7 +100,9 @@ private void Execute(SourceProductionContext spc,
100
100
var assemblyName = compilation . AssemblyName ?? Constants . DefaultNamespace ;
101
101
var useDI = configOptions . GetFLLUseDependencyInjection ( ) ;
102
102
103
- var pluginInfo = GetValidPluginInfo ( pluginClasses , spc , useDI ) ;
103
+ var pluginInfo = PluginInfoHelper . GetValidPluginInfoAndReportDiagnostic ( pluginClasses , spc , useDI ) ;
104
+
105
+ if ( pluginInfo == null ) return ;
104
106
105
107
GenerateSource (
106
108
spc ,
@@ -421,88 +423,6 @@ private static string GetLocalizationKeyFromInvocation(GeneratorSyntaxContext co
421
423
422
424
#endregion
423
425
424
- #region Get Plugin Class Info
425
-
426
- private static PluginClassInfo GetValidPluginInfo (
427
- ImmutableArray < PluginClassInfo > pluginClasses ,
428
- SourceProductionContext context ,
429
- bool useDI )
430
- {
431
- // If p is null, this class does not implement IPluginI18n
432
- var iPluginI18nClasses = pluginClasses . Where ( p => p != null ) . ToArray ( ) ;
433
- if ( iPluginI18nClasses . Length == 0 )
434
- {
435
- context . ReportDiagnostic ( Diagnostic . Create (
436
- SourceGeneratorDiagnostics . CouldNotFindPluginEntryClass ,
437
- Location . None
438
- ) ) ;
439
- return null ;
440
- }
441
-
442
- // If we use dependency injection, we do not need to check if there is a valid plugin context
443
- // Also we do not need to return the plugin info
444
- if ( useDI )
445
- {
446
- return null ;
447
- }
448
-
449
- // If p.PropertyName is null, this class does not have PluginInitContext property
450
- var iPluginI18nClassesWithContext = iPluginI18nClasses . Where ( p => p . PropertyName != null ) . ToArray ( ) ;
451
- if ( iPluginI18nClassesWithContext . Length == 0 )
452
- {
453
- foreach ( var pluginClass in iPluginI18nClasses )
454
- {
455
- context . ReportDiagnostic ( Diagnostic . Create (
456
- SourceGeneratorDiagnostics . CouldNotFindContextProperty ,
457
- pluginClass . Location ,
458
- pluginClass . ClassName
459
- ) ) ;
460
- }
461
- return null ;
462
- }
463
-
464
- // Rest classes have implemented IPluginI18n and have PluginInitContext property
465
- // Check if the property is valid
466
- foreach ( var pluginClass in iPluginI18nClassesWithContext )
467
- {
468
- if ( pluginClass . IsValid == true )
469
- {
470
- return pluginClass ;
471
- }
472
-
473
- if ( ! pluginClass . IsStatic )
474
- {
475
- context . ReportDiagnostic ( Diagnostic . Create (
476
- SourceGeneratorDiagnostics . ContextPropertyNotStatic ,
477
- pluginClass . Location ,
478
- pluginClass . PropertyName
479
- ) ) ;
480
- }
481
-
482
- if ( pluginClass . IsPrivate )
483
- {
484
- context . ReportDiagnostic ( Diagnostic . Create (
485
- SourceGeneratorDiagnostics . ContextPropertyIsPrivate ,
486
- pluginClass . Location ,
487
- pluginClass . PropertyName
488
- ) ) ;
489
- }
490
-
491
- if ( pluginClass . IsProtected )
492
- {
493
- context . ReportDiagnostic ( Diagnostic . Create (
494
- SourceGeneratorDiagnostics . ContextPropertyIsProtected ,
495
- pluginClass . Location ,
496
- pluginClass . PropertyName
497
- ) ) ;
498
- }
499
- }
500
-
501
- return null ;
502
- }
503
-
504
- #endregion
505
-
506
426
#region Generate Source
507
427
508
428
private static void GenerateSource (
0 commit comments