From ddfe8bb915b073f048c5265a20d475b64e7cc329 Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Mon, 10 Mar 2025 23:42:08 +0800 Subject: [PATCH] Check CouldNotFindPluginEntryClass when use dependency injection --- .../Localize/LocalizeSourceGenerator.cs | 16 ++++++++++------ .../Flow.Launcher.Localization.csproj | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs b/Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs index a9594fd..9f797c8 100644 --- a/Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs +++ b/Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs @@ -103,11 +103,7 @@ private void Execute(SourceProductionContext spc, var optimizationLevel = compilation.Options.OptimizationLevel; var useDI = configOptions.GetFLLUseDependencyInjection(); - PluginClassInfo pluginInfo = null; - if (!useDI) - { - pluginInfo = GetValidPluginInfo(pluginClasses, spc); - } + var pluginInfo = GetValidPluginInfo(pluginClasses, spc, useDI); GenerateSource( spc, @@ -463,7 +459,8 @@ private static PluginClassInfo GetPluginClassInfo(GeneratorSyntaxContext context private static PluginClassInfo GetValidPluginInfo( ImmutableArray pluginClasses, - SourceProductionContext context) + SourceProductionContext context, + bool useDI) { // If p is null, this class does not implement IPluginI18n var iPluginI18nClasses = pluginClasses.Where(p => p != null).ToArray(); @@ -476,6 +473,13 @@ private static PluginClassInfo GetValidPluginInfo( return null; } + // If we use dependency injection, we do not need to check if there is a valid plugin context + // Also we do not need to return the plugin info + if (useDI) + { + return null; + } + // If p.PropertyName is null, this class does not have PluginInitContext property var iPluginI18nClassesWithContext = iPluginI18nClasses.Where(p => p.PropertyName != null).ToArray(); if (iPluginI18nClassesWithContext.Length == 0) diff --git a/Flow.Launcher.Localization/Flow.Launcher.Localization.csproj b/Flow.Launcher.Localization/Flow.Launcher.Localization.csproj index 03db6d9..e30852f 100644 --- a/Flow.Launcher.Localization/Flow.Launcher.Localization.csproj +++ b/Flow.Launcher.Localization/Flow.Launcher.Localization.csproj @@ -16,7 +16,7 @@ All - + All