Skip to content

Commit 81f4889

Browse files
committed
Use one Api
1 parent 13dfbb2 commit 81f4889

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,8 @@ private void GenerateSource(
215215
string getTranslation = null;
216216
if (useDI)
217217
{
218-
sourceBuilder.AppendLine($"{tabString}private static Flow.Launcher.Plugin.IPublicAPI? api = null;");
219-
sourceBuilder.AppendLine($"{tabString}private static Flow.Launcher.Plugin.IPublicAPI Api => api ??= CommunityToolkit.Mvvm.DependencyInjection.Ioc.Default.GetRequiredService<Flow.Launcher.Plugin.IPublicAPI>();");
220-
sourceBuilder.AppendLine();
221-
getTranslation = "Api.GetTranslation";
218+
// Use Api from LocalizeSourceGenerator
219+
getTranslation = $"{assemblyNamespace}.{Constants.ClassName}.Api.GetTranslation";
222220
}
223221
else if (pluginInfo?.IsValid == true)
224222
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ private static void GenerateSource(
499499
if (useDI)
500500
{
501501
sourceBuilder.AppendLine($"{tabString}private static Flow.Launcher.Plugin.IPublicAPI? api = null;");
502-
sourceBuilder.AppendLine($"{tabString}private static Flow.Launcher.Plugin.IPublicAPI Api => api ??= CommunityToolkit.Mvvm.DependencyInjection.Ioc.Default.GetRequiredService<Flow.Launcher.Plugin.IPublicAPI>();");
502+
// Internal for EnumSourceGenerator to use
503+
sourceBuilder.AppendLine($"{tabString}internal static Flow.Launcher.Plugin.IPublicAPI Api => api ??= CommunityToolkit.Mvvm.DependencyInjection.Ioc.Default.GetRequiredService<Flow.Launcher.Plugin.IPublicAPI>();");
503504
sourceBuilder.AppendLine();
504505
getTranslation = "Api.GetTranslation";
505506
}

0 commit comments

Comments
 (0)