Skip to content

Commit 530e69f

Browse files
committed
modify to use ToolCommandName as a logger category name
1 parent 7672d3b commit 530e69f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/Smdn.Reflection.ReverseGenerating.ListApi/Smdn.Reflection.ReverseGenerating.ListApi.csproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ SPDX-License-Identifier: MIT
1414
<RootNamespace/> <!-- empty the root namespace so that the namespace is determined only by the directory name, for code style rule IDE0030 -->
1515
<Nullable>enable</Nullable>
1616
<NoWarn>CS1591;$(NoWarn)</NoWarn> <!-- CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' -->
17+
<NoWarn>CS2002;$(NoWarn)</NoWarn> <!-- see target 'WriteConstantsFile' -->
1718
<EnableFeature_BuildProjectFile Condition=" '$(Configuration)' != 'Release' ">true</EnableFeature_BuildProjectFile>
1819
<APIListEnableGenerating>false</APIListEnableGenerating>
1920
<GeneratePackageReadmeFile>false</GeneratePackageReadmeFile>
@@ -55,4 +56,27 @@ SPDX-License-Identifier: MIT
5556
<PackageReference Include="NuGet.ProjectModel" Version="5.11.0" />
5657
<PackageReference Include="Smdn.Fundamental.Shell" Version="3.0.0" />
5758
</ItemGroup>
59+
60+
<Target Name="WriteConstantsFile" BeforeTargets="BeforeBuild">
61+
<ItemGroup>
62+
<SourceLines Include="internal static class Constants {" />
63+
<SourceLines Include="public const string ToolCommandName = &quot;$(ToolCommandName)&quot;$([MSBuild]::Escape(';'))" />
64+
<SourceLines Include="}" />
65+
</ItemGroup>
66+
67+
<PropertyGroup>
68+
<ConstantsFilePath>$(IntermediateOutputPath)Constants.g.cs</ConstantsFilePath>
69+
</PropertyGroup>
70+
71+
<WriteLinesToFile
72+
File="$(ConstantsFilePath)"
73+
Overwrite="true"
74+
Lines="@(SourceLines)"
75+
/>
76+
77+
<ItemGroup>
78+
<!-- XXX: This causes compiler warning CS2002. -->
79+
<Compile Include="$(ConstantsFilePath)" />
80+
</ItemGroup>
81+
</Target>
5882
</Project>

src/Smdn.Reflection.ReverseGenerating.ListApi/Smdn.Reflection.ReverseGenerating.ListApi/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Smdn.Reflection.ReverseGenerating.ListApi;
1313

1414
internal sealed class Program {
15-
internal static string LoggerCategoryName => typeof(Program).Assembly.GetName().Name!;
15+
internal static string LoggerCategoryName => Constants.ToolCommandName;
1616

1717
private static int Main(string[] args)
1818
{

0 commit comments

Comments
 (0)