Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
feast107 committed Dec 25, 2023
1 parent 7037629 commit 446b07f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace Antelcat.I18N.WPF.SourceGenerators.Generators;
[Generator(LanguageNames.CSharp)]
internal class ResourceKeysGenerator : AttributeDetectBaseGenerator
{
private static readonly string Attribute = $"{typeof(ResourceKeysOfAttribute).FullName}";
private static readonly string CultureInfo = $"global::{typeof(CultureInfo).FullName}";
private static readonly string ResourceProvider = $"global::{typeof(ResourceProvider).FullName}";
private static readonly string ModuleInitializer = $"global::{typeof(ModuleInitializerAttribute).FullName}";
private static readonly string Attribute = $"{typeof(ResourceKeysOfAttribute).FullName}";
private static readonly string CultureInfo = $"global::{typeof(CultureInfo).FullName}";
private static readonly string ResourceProvider = $"global::{typeof(ResourceProvider).FullName}";
private static readonly string ModuleInitializer = $"global::{typeof(ModuleInitializerAttribute).FullName}";

private static readonly string[] Exceptions =
{
"resourceMan",
Expand Down Expand Up @@ -91,23 +91,23 @@ private void UpdateSource()
}
""",
$$"""
[{{ModuleInitializer}}]
public static void Initialize()
{
RegisterProvider(new {{className}}());
}
"""
[{{ModuleInitializer}}]
public static void Initialize()
{
RegisterProvider(new {{className}}());
}
"""
)
.AddMembers(names.Select(x =>
$"public string {x} => {targetFullName}.{x};")
.ToArray())
)
)
).NormalizeWhitespace();

context.AddSource($"{generateCtx.TargetSymbol.GetFullyQualifiedName().Replace("global::", "")}.g.cs",
unit.GetText(Encoding.UTF8));

}
}
}
7 changes: 7 additions & 0 deletions src/Antelcat.I18N.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antelcat.I18N.Abstractions"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Antelcat.I18N.Abstractions.Shared", "Antelcat.I18N.Abstractions.Shared\Antelcat.I18N.Abstractions.Shared.shproj", "{F3F24657-983C-46FF-B928-ADD03557C562}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Feast.CodeAnalysis.LiteralGenerator", "..\extern\CodeAnalysis.Extensions\src\Feast.CodeAnalysis.LiteralGenerator\Feast.CodeAnalysis.LiteralGenerator.csproj", "{13AC62C7-D492-40B2-8231-B9A2545D7388}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -87,6 +89,10 @@ Global
{2BA15A8E-6C3E-4B33-BFF4-D9255202D71D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BA15A8E-6C3E-4B33-BFF4-D9255202D71D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BA15A8E-6C3E-4B33-BFF4-D9255202D71D}.Release|Any CPU.Build.0 = Release|Any CPU
{13AC62C7-D492-40B2-8231-B9A2545D7388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13AC62C7-D492-40B2-8231-B9A2545D7388}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13AC62C7-D492-40B2-8231-B9A2545D7388}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13AC62C7-D492-40B2-8231-B9A2545D7388}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -104,6 +110,7 @@ Global
{D02B1059-583A-42FD-8D7F-4BFBBBE439D7} = {2835EE7C-9F76-45A2-9754-E86902623A81}
{5FB0464B-DD43-4C4F-8F03-C0F8CEEB520E} = {E03F942D-C1C1-4847-BA7D-5186A6CEAEE1}
{F3F24657-983C-46FF-B928-ADD03557C562} = {F86CB7CC-4C0C-40AA-ABF0-282D7B15B38E}
{13AC62C7-D492-40B2-8231-B9A2545D7388} = {2835EE7C-9F76-45A2-9754-E86902623A81}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {73D6AEFA-1477-4119-9F85-0DA27E35BDB8}
Expand Down
2 changes: 1 addition & 1 deletion src/WPF/Demo/Antelcat.I18N.WPF.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows10.0.22621.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
Expand Down

0 comments on commit 446b07f

Please sign in to comment.