@@ -103,11 +103,7 @@ private void Execute(SourceProductionContext spc,
103103 var optimizationLevel = compilation . Options . OptimizationLevel ;
104104 var useDI = configOptions . GetFLLUseDependencyInjection ( ) ;
105105
106- PluginClassInfo pluginInfo = null ;
107- if ( ! useDI )
108- {
109- pluginInfo = GetValidPluginInfo ( pluginClasses , spc ) ;
110- }
106+ var pluginInfo = GetValidPluginInfo ( pluginClasses , spc , useDI ) ;
111107
112108 GenerateSource (
113109 spc ,
@@ -463,7 +459,8 @@ private static PluginClassInfo GetPluginClassInfo(GeneratorSyntaxContext context
463459
464460 private static PluginClassInfo GetValidPluginInfo (
465461 ImmutableArray < PluginClassInfo > pluginClasses ,
466- SourceProductionContext context )
462+ SourceProductionContext context ,
463+ bool useDI )
467464 {
468465 // If p is null, this class does not implement IPluginI18n
469466 var iPluginI18nClasses = pluginClasses . Where ( p => p != null ) . ToArray ( ) ;
@@ -476,6 +473,13 @@ private static PluginClassInfo GetValidPluginInfo(
476473 return null ;
477474 }
478475
476+ // If we use dependency injection, we do not need to check if there is a valid plugin context
477+ // Also we do not need to return the plugin info
478+ if ( useDI )
479+ {
480+ return null ;
481+ }
482+
479483 // If p.PropertyName is null, this class does not have PluginInitContext property
480484 var iPluginI18nClassesWithContext = iPluginI18nClasses . Where ( p => p . PropertyName != null ) . ToArray ( ) ;
481485 if ( iPluginI18nClassesWithContext . Length == 0 )
0 commit comments