Skip to content

Commit f212528

Browse files
authored
Merge pull request #21 from Flow-Launcher/di_check_context1
Check CouldNotFindPluginEntryClass when use dependency injection
2 parents e660b95 + ddfe8bb commit f212528

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

Flow.Launcher.Localization/Flow.Launcher.Localization.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<ProjectReference Include="..\Flow.Launcher.Localization.Analyzers\Flow.Launcher.Localization.Analyzers.csproj">
1717
<PrivateAssets>All</PrivateAssets>
1818
</ProjectReference>
19-
<ProjectReference Include="..\Flow.Launcher.Localization.Shared\Flow.Launcher.Localization.Shared.csproj" >
19+
<ProjectReference Include="..\Flow.Launcher.Localization.Shared\Flow.Launcher.Localization.Shared.csproj">
2020
<PrivateAssets>All</PrivateAssets>
2121
</ProjectReference>
2222
<ProjectReference Include="..\Flow.Launcher.Localization.SourceGenerators\Flow.Launcher.Localization.SourceGenerators.csproj">

0 commit comments

Comments
 (0)