@@ -45,7 +45,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
45
45
. Collect ( )
46
46
. SelectMany ( ( files , _ ) => files ) ;
47
47
48
- // TODO: Add support for usedKeys
49
48
var invocationKeys = context . SyntaxProvider
50
49
. CreateSyntaxProvider (
51
50
predicate : ( n , _ ) => n is InvocationExpressionSyntax ,
@@ -100,7 +99,6 @@ private void Execute(SourceProductionContext spc,
100
99
var localizedStrings = data . Item1 . Item1 . Item1 . Item1 . LocalizableStrings ;
101
100
102
101
var assemblyName = compilation . AssemblyName ?? Constants . DefaultNamespace ;
103
- var optimizationLevel = compilation . Options . OptimizationLevel ;
104
102
var useDI = configOptions . GetFLLUseDependencyInjection ( ) ;
105
103
106
104
var pluginInfo = GetValidPluginInfo ( pluginClasses , spc , useDI ) ;
@@ -109,7 +107,6 @@ private void Execute(SourceProductionContext spc,
109
107
spc ,
110
108
xamlFiles [ 0 ] ,
111
109
localizedStrings ,
112
- optimizationLevel ,
113
110
assemblyName ,
114
111
useDI ,
115
112
pluginInfo ,
@@ -383,7 +380,6 @@ private static (string Summary, ImmutableArray<LocalizableStringParam> Parameter
383
380
384
381
#region Get Used Localization Keys
385
382
386
- // TODO: Add support for usedKeys
387
383
private static string GetLocalizationKeyFromInvocation ( GeneratorSyntaxContext context , CancellationToken ct )
388
384
{
389
385
if ( ct . IsCancellationRequested )
@@ -548,28 +544,22 @@ private static void GenerateSource(
548
544
SourceProductionContext spc ,
549
545
AdditionalText xamlFile ,
550
546
ImmutableArray < LocalizableString > localizedStrings ,
551
- OptimizationLevel optimizationLevel ,
552
547
string assemblyName ,
553
548
bool useDI ,
554
549
PluginClassInfo pluginInfo ,
555
550
IEnumerable < string > usedKeys )
556
551
{
557
- // Get unusedKeys if we need to optimize
558
- IEnumerable < string > unusedKeys = new List < string > ( ) ;
559
- if ( optimizationLevel == OptimizationLevel . Release )
560
- {
561
- unusedKeys = localizedStrings
552
+ // Report unusedKeys
553
+ var unusedKeys = localizedStrings
562
554
. Select ( ls => ls . Key )
563
555
. ToImmutableHashSet ( )
564
556
. Except ( usedKeys ) ;
565
-
566
- foreach ( var key in unusedKeys )
567
- {
568
- spc . ReportDiagnostic ( Diagnostic . Create (
569
- SourceGeneratorDiagnostics . LocalizationKeyUnused ,
570
- Location . None ,
571
- key ) ) ;
572
- }
557
+ foreach ( var key in unusedKeys )
558
+ {
559
+ spc . ReportDiagnostic ( Diagnostic . Create (
560
+ SourceGeneratorDiagnostics . LocalizationKeyUnused ,
561
+ Location . None ,
562
+ key ) ) ;
573
563
}
574
564
575
565
var sourceBuilder = new StringBuilder ( ) ;
@@ -636,12 +626,6 @@ private static void GenerateSource(
636
626
// Generate localization methods
637
627
foreach ( var ls in localizedStrings )
638
628
{
639
- // TODO: Add support for usedKeys
640
- /*if (unusedKeys.Contains(ls.Key))
641
- {
642
- continue;
643
- }*/
644
-
645
629
GenerateDocComments ( sourceBuilder , ls , tabString ) ;
646
630
GenerateLocalizationMethod ( sourceBuilder , ls , getTranslation , tabString ) ;
647
631
}
0 commit comments