Skip to content

Commit 3d38524

Browse files
committed
avoid null reference
1 parent 7e53f0d commit 3d38524

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public static FileInfo FindSingleProjectOrSolution(
1717
ILogger? logger = null
1818
)
1919
{
20+
if (directory is null)
21+
throw new ArgumentNullException(nameof(directory));
22+
2023
logger?.LogDebug("finding project or solution from directory '{Directory}'", directory.FullName);
2124

2225
var solutionAndProjectFiles = directory

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-FileCopyrightText: 2021 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3+
using System;
34
using System.CommandLine;
45
using System.CommandLine.Parsing;
56

@@ -27,7 +28,7 @@ public static LogLevel ParseLogLevel(string[] args)
2728
}
2829

2930
public static LogLevel ParseLogLevel(ParseResult parseResult)
30-
=> parseResult.ValueForOption(Option) switch {
31+
=> (parseResult ?? throw new ArgumentNullException(nameof(parseResult))).ValueForOption(Option) switch {
3132
#pragma warning disable IDE0055
3233
"q" or "quiet" => LogLevel.Information,
3334
"m" or "minimal" => LogLevel.Information,
@@ -49,7 +50,7 @@ public static LoggerVerbosity ParseLoggerVerbosity(string[] args)
4950
}
5051

5152
public static LoggerVerbosity ParseLoggerVerbosity(ParseResult parseResult)
52-
=> parseResult.ValueForOption(Option) switch {
53+
=> (parseResult ?? throw new ArgumentNullException(nameof(parseResult))).ValueForOption(Option) switch {
5354
#pragma warning disable IDE0055
5455
"q" or "quiet" => LoggerVerbosity.Quiet,
5556
"m" or "minimal" => LoggerVerbosity.Minimal,

0 commit comments

Comments
 (0)