Skip to content

Commit 48f2e31

Browse files
committed
simplify null check
1 parent 68b5a86 commit 48f2e31

File tree

2 files changed

+3
-9
lines changed
  • src/Smdn.Reflection.ReverseGenerating.ListApi

2 files changed

+3
-9
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ private static string GetMSBuildExePath(out string? sdkVersion)
8383
#if true
8484
sdkVersion = default;
8585

86-
var sdkBasePath = GetSdkBasePath(out sdkVersion);
87-
88-
if (sdkBasePath is null)
89-
throw new InvalidOperationException("could not get SDK base path");
90-
86+
var sdkBasePath = GetSdkBasePath(out sdkVersion) ?? throw new InvalidOperationException("could not get SDK base path");
9187
var msbuildExePath = JoinPath(
9288
sdkBasePath,
9389
"MSBuild.dll" // .NET SDK always ships MSBuild executables with the extension 'dll'

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ public static FileInfo FindSingleProjectOrSolution(
3232
if (1 < solutionAndProjectFiles.Count())
3333
throw new InvalidOperationException($"multiple solution or project file found in directory '{directory.FullName}'");
3434

35-
var first = solutionAndProjectFiles.FirstOrDefault();
36-
37-
if (first is null)
38-
throw new FileNotFoundException($"no solution or project file found in directory '{directory.FullName}'");
35+
var first = solutionAndProjectFiles.FirstOrDefault()
36+
?? throw new FileNotFoundException($"no solution or project file found in directory '{directory.FullName}'");
3937

4038
logger?.LogDebug("found '{ProjectOrSolutionPath}'", first.FullName);
4139

0 commit comments

Comments
 (0)