Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -109,7 +107,6 @@ private void Execute(SourceProductionContext spc,
spc,
xamlFiles[0],
localizedStrings,
optimizationLevel,
assemblyName,
useDI,
pluginInfo,
Expand Down Expand Up @@ -383,7 +380,6 @@ private static (string Summary, ImmutableArray<LocalizableStringParam> Parameter

#region Get Used Localization Keys

// TODO: Add support for usedKeys
private static string GetLocalizationKeyFromInvocation(GeneratorSyntaxContext context, CancellationToken ct)
{
if (ct.IsCancellationRequested)
Expand Down Expand Up @@ -548,28 +544,22 @@ private static void GenerateSource(
SourceProductionContext spc,
AdditionalText xamlFile,
ImmutableArray<LocalizableString> localizedStrings,
OptimizationLevel optimizationLevel,
string assemblyName,
bool useDI,
PluginClassInfo pluginInfo,
IEnumerable<string> usedKeys)
{
// Get unusedKeys if we need to optimize
IEnumerable<string> unusedKeys = new List<string>();
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();
Expand Down Expand Up @@ -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);
}
Expand Down
Loading