From cd7d136d84c9ae3fe708ebaeaf3b2f154f5785d3 Mon Sep 17 00:00:00 2001 From: Tobi Kli Date: Thu, 31 Mar 2022 15:40:56 +0200 Subject: [PATCH] fix: only consider .json additionalfiles --- example/kli.Localize.Example/kli.Localize.Example.csproj | 2 +- src/kli.Localize.Generator/LocalizeCodeGenerator.cs | 7 +++++-- src/kli.Localize.Test/kli.Localize.Test.csproj | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/example/kli.Localize.Example/kli.Localize.Example.csproj b/example/kli.Localize.Example/kli.Localize.Example.csproj index d992ffe..a5c55a2 100644 --- a/example/kli.Localize.Example/kli.Localize.Example.csproj +++ b/example/kli.Localize.Example/kli.Localize.Example.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 diff --git a/src/kli.Localize.Generator/LocalizeCodeGenerator.cs b/src/kli.Localize.Generator/LocalizeCodeGenerator.cs index ac64bac..8e011a0 100644 --- a/src/kli.Localize.Generator/LocalizeCodeGenerator.cs +++ b/src/kli.Localize.Generator/LocalizeCodeGenerator.cs @@ -1,4 +1,6 @@ -using kli.Localize.Generator.Internal; +using System; +using System.Linq; +using kli.Localize.Generator.Internal; using Microsoft.CodeAnalysis; namespace kli.Localize.Generator @@ -20,7 +22,8 @@ public void Execute(GeneratorExecutionContext context) var translationReader = new TranslationReader(context.ReportDiagnostic); var codeGenerator = new LocalizeCodeGeneratorCore(translationReader); - foreach (var file in context.AdditionalFiles) + var additionalFiles = context.AdditionalFiles.Where(af => af.Path.EndsWith(".json", StringComparison.OrdinalIgnoreCase)); + foreach (var file in additionalFiles) { var namespaceResolver = new NamespaceResolver(file.Path, context.Compilation.AssemblyName, context.AnalyzerConfigOptions.GlobalOptions.TryGetValue); diff --git a/src/kli.Localize.Test/kli.Localize.Test.csproj b/src/kli.Localize.Test/kli.Localize.Test.csproj index f7c6fd1..b624e36 100644 --- a/src/kli.Localize.Test/kli.Localize.Test.csproj +++ b/src/kli.Localize.Test/kli.Localize.Test.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 9.0 false