Skip to content

Commit

Permalink
Add summary for resx enum
Browse files Browse the repository at this point in the history
  • Loading branch information
qhy040404 committed Nov 3, 2024
1 parent de2bd92 commit ba28226
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ internal partial class {{className}}
""");

StringBuilder enumBuilder = new($$"""
}
internal enum {{className}}Name
{
""");

foreach (ResxEntry? entry in entries.OrderBy(e => e.Name, StringComparer.Ordinal))
{
if (string.IsNullOrEmpty(entry.Name))
Expand Down Expand Up @@ -302,6 +309,12 @@ internal partial class {{className}}
}
""");

enumBuilder.AppendLine($"""
/// {comment}
{ToCSharpNameIdentifier(entry.Name!)},
""");

if (entry.Values.FirstOrDefault() is string value)
{
Expand Down Expand Up @@ -340,25 +353,7 @@ internal partial class {{className}}
}
}

sb.AppendLine($$"""
}
internal enum {{className}}Name
{
""");

foreach (ResxEntry entry in entries)
{
if (string.IsNullOrEmpty(entry.Name))
{
continue;
}

sb.AppendLine($$"""
{{ToCSharpNameIdentifier(entry.Name!)}},
""");
}

sb.AppendLine(enumBuilder.ToString());
sb.AppendLine("}");

return sb.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<PropertyGroup>
<PackageId>Snap.Hutao.SourceGeneration</PackageId>
<Version>1.1.27</Version>
<Version>1.1.28</Version>
<Authors>DGP Studio</Authors>
<IncludeBuildOutput>false</IncludeBuildOutput>
<DevelopmentDependency>true</DevelopmentDependency>
Expand Down

0 comments on commit ba28226

Please sign in to comment.