Skip to content

Commit f8055a3

Browse files
committed
fix warning CA2254
1 parent 0f34373 commit f8055a3

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/Smdn.Reflection.ReverseGenerating.ListApi/Smdn.Reflection.ReverseGenerating.ListApi.Build/MSBuildExePath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public static void EnsureSetEnvVar(ILogger logger = null)
140140
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(MSBUILD_EXE_PATH)))
141141
Environment.SetEnvironmentVariable(MSBUILD_EXE_PATH, GetMSBuildExePath(out _));
142142

143-
logger?.LogDebug($"{MSBUILD_EXE_PATH}: {Environment.GetEnvironmentVariable(MSBUILD_EXE_PATH)}");
143+
logger?.LogDebug("{MSBUILD_EXE_PATH}: {ENVVAR_MSBUILD_EXE_PATH}", MSBUILD_EXE_PATH, Environment.GetEnvironmentVariable(MSBUILD_EXE_PATH));
144144
}
145145
}
146146
#endif

src/Smdn.Reflection.ReverseGenerating.ListApi/Smdn.Reflection.ReverseGenerating.ListApi.Build/ProjectBuilder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public static IEnumerable<FileInfo> Build(
5353
globalProps["RuntimeIdentifier"] = options.RuntimeIdentifier;
5454

5555
logger?.LogDebug("Build requested");
56-
logger?.LogDebug($" project: {projectFile}");
56+
logger?.LogDebug(" project: {ProjectFile}", projectFile);
5757

58-
logger?.LogDebug($" targets: {string.Join(";", options.TargetsToBuild)}");
58+
logger?.LogDebug(" targets: {Targets}", string.Join(";", options.TargetsToBuild));
5959

6060
logger?.LogDebug(" global properties:");
6161

6262
foreach (var globalProp in globalProps) {
63-
logger?.LogDebug($" {globalProp.Key}: '{globalProp.Value}'");
63+
logger?.LogDebug(" {GlobalPropKey}: '{GlobalPropValue}'", globalProp.Key, globalProp.Value);
6464
}
6565

6666
var proj = new Project(
@@ -102,7 +102,7 @@ public static IEnumerable<FileInfo> Build(
102102
.Select(static item => item.GetMetadataValue("Identity"));
103103

104104
foreach (var innerOutputFullPath in innerOutputFullPaths) {
105-
logger?.LogDebug($"build output file: {innerOutputFullPath}");
105+
logger?.LogDebug("build output file: {InnerOutputFullPath}", innerOutputFullPath);
106106

107107
yield return new FileInfo(innerOutputFullPath);
108108
}
@@ -116,7 +116,7 @@ public static IEnumerable<FileInfo> Build(
116116
.Select(static item => item.GetMetadata("Identity"));
117117

118118
foreach (var buildOutputFullPath in buildOutputFullPaths) {
119-
logger?.LogDebug($"build output file: {buildOutputFullPath}");
119+
logger?.LogDebug("build output file: {BuildOutputFullPath}", buildOutputFullPath);
120120

121121
yield return new FileInfo(buildOutputFullPath);
122122
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static FileInfo FindSingleProjectOrSolution(
1515
ILogger logger = null
1616
)
1717
{
18-
logger?.LogDebug($"finding project or solution from directory '{directory.FullName}'");
18+
logger?.LogDebug("finding project or solution from directory '{Directory}'", directory.FullName);
1919

2020
var solutionAndProjectFiles = directory
2121
.GetFiles("*.*", SearchOption.TopDirectoryOnly)
@@ -32,7 +32,7 @@ public static FileInfo FindSingleProjectOrSolution(
3232
if (first is null)
3333
throw new FileNotFoundException($"no solution or project file found in directory '{directory.FullName}'");
3434

35-
logger?.LogDebug($"found '{first.FullName}'");
35+
logger?.LogDebug("found '{ProjectOrSolutionPath}'", first.FullName);
3636

3737
return first;
3838
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,14 @@ private static DirectoryInfo GetOutputDirectory(ParseResult parseResult)
153153

154154
private void CommandMain(ParseResult parseResult, IConsole console)
155155
{
156+
#pragma warning disable CA2254
156157
logger?.LogDebug(parseResult.ToString());
158+
#pragma warning restore CA2254
157159

158160
// ref: https://docs.microsoft.com/en-us/dotnet/core/dependency-loading/default-probing
159-
logger?.LogDebug($"APP_PATHS={AppContext.GetData("APP_PATHS")}");
160-
logger?.LogDebug($"APP_CONTEXT_DEPS_FILES={AppContext.GetData("APP_CONTEXT_DEPS_FILES")}");
161-
logger?.LogDebug($"TRUSTED_PLATFORM_ASSEMBLIES={AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES")}");
161+
logger?.LogDebug("APP_PATHS={AppContext_APP_PATHS}", AppContext.GetData("APP_PATHS"));
162+
logger?.LogDebug("APP_CONTEXT_DEPS_FILES={AppContext_APP_CONTEXT_DEPS_FILES}", AppContext.GetData("APP_CONTEXT_DEPS_FILES"));
163+
logger?.LogDebug("TRUSTED_PLATFORM_ASSEMBLIES={AppContext_TRUSTED_PLATFORM_ASSEMBLIES}", AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES"));
162164

163165
var options = GetApiListWriterOptions(parseResult);
164166
var outputDirectory = GetOutputDirectory(parseResult);
@@ -192,8 +194,8 @@ private void CommandMain(ParseResult parseResult, IConsole console)
192194
writer.WriteAssemblyInfoHeader();
193195
writer.WriteExportedTypes();
194196

195-
arg.logger?.LogDebug($"generated API list {outputFilePath}");
196-
arg.logger?.LogInformation($"{assm.Location} -> {outputFilePath}");
197+
arg.logger?.LogDebug("generated API list {OutputFilePath}", outputFilePath);
198+
arg.logger?.LogInformation("{AssemblyFilePath} -> {OutputFilePath}", assm.Location, outputFilePath);
197199

198200
return outputFilePath;
199201
}
@@ -324,7 +326,7 @@ private IEnumerable<FileInfo> GetInputAssemblyFiles(ParseResult parseResult)
324326
throw new CommandOperationNotSupportedException($"unsupported input: {input}");
325327
}
326328

327-
logger?.LogDebug($"input file: '{inputFile.FullName}'");
329+
logger?.LogDebug("input file: '{InputFilePath}'", inputFile.FullName);
328330

329331
IEnumerable<FileInfo> inputAssemblyFiles = null;
330332

@@ -358,7 +360,7 @@ private IEnumerable<FileInfo> GetInputAssemblyFiles(ParseResult parseResult)
358360
#endif
359361
}
360362
else {
361-
logger?.LogWarning($"unknown type of file: {inputFile}");
363+
logger?.LogWarning("unknown type of file: {InputFilePath}", inputFile);
362364

363365
// try process as an assembly file
364366
inputAssemblyFiles = Enumerable.Repeat(inputFile, 1);

0 commit comments

Comments
 (0)