diff --git a/Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs b/Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs index 9f797c8..5a3b6c6 100644 --- a/Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs +++ b/Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs @@ -45,7 +45,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .Collect() .SelectMany((files, _) => files); - // TODO: Add support for usedKeys var invocationKeys = context.SyntaxProvider .CreateSyntaxProvider( predicate: (n, _) => n is InvocationExpressionSyntax, @@ -100,7 +99,6 @@ private void Execute(SourceProductionContext spc, var localizedStrings = data.Item1.Item1.Item1.Item1.LocalizableStrings; var assemblyName = compilation.AssemblyName ?? Constants.DefaultNamespace; - var optimizationLevel = compilation.Options.OptimizationLevel; var useDI = configOptions.GetFLLUseDependencyInjection(); var pluginInfo = GetValidPluginInfo(pluginClasses, spc, useDI); @@ -109,7 +107,6 @@ private void Execute(SourceProductionContext spc, spc, xamlFiles[0], localizedStrings, - optimizationLevel, assemblyName, useDI, pluginInfo, @@ -383,7 +380,6 @@ private static (string Summary, ImmutableArray Parameter #region Get Used Localization Keys - // TODO: Add support for usedKeys private static string GetLocalizationKeyFromInvocation(GeneratorSyntaxContext context, CancellationToken ct) { if (ct.IsCancellationRequested) @@ -548,28 +544,22 @@ private static void GenerateSource( SourceProductionContext spc, AdditionalText xamlFile, ImmutableArray localizedStrings, - OptimizationLevel optimizationLevel, string assemblyName, bool useDI, PluginClassInfo pluginInfo, IEnumerable usedKeys) { - // Get unusedKeys if we need to optimize - IEnumerable unusedKeys = new List(); - if (optimizationLevel == OptimizationLevel.Release) - { - unusedKeys = localizedStrings + // Report unusedKeys + var unusedKeys = localizedStrings .Select(ls => ls.Key) .ToImmutableHashSet() .Except(usedKeys); - - foreach (var key in unusedKeys) - { - spc.ReportDiagnostic(Diagnostic.Create( - SourceGeneratorDiagnostics.LocalizationKeyUnused, - Location.None, - key)); - } + foreach (var key in unusedKeys) + { + spc.ReportDiagnostic(Diagnostic.Create( + SourceGeneratorDiagnostics.LocalizationKeyUnused, + Location.None, + key)); } var sourceBuilder = new StringBuilder(); @@ -636,12 +626,6 @@ private static void GenerateSource( // Generate localization methods foreach (var ls in localizedStrings) { - // TODO: Add support for usedKeys - /*if (unusedKeys.Contains(ls.Key)) - { - continue; - }*/ - GenerateDocComments(sourceBuilder, ls, tabString); GenerateLocalizationMethod(sourceBuilder, ls, getTranslation, tabString); }