Skip to content

Commit 5a5206f

Browse files
committed
Nullable-enable RunCommand.cs
1 parent 9f51756 commit 5a5206f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/Cli/dotnet/commands/dotnet-run/RunCommand.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
#nullable enable
5+
46
using System.Diagnostics;
57
using Microsoft.Build.Evaluation;
68
using Microsoft.Build.Exceptions;
@@ -275,6 +277,8 @@ private void EnsureProjectIsBuilt(out Func<ProjectCollection, ProjectInstance>?
275277
}
276278
else
277279
{
280+
Debug.Assert(ProjectFileFullPath is not null);
281+
278282
projectFactory = null;
279283
buildResult = new RestoringCommand(
280284
RestoreArgs.Prepend(ProjectFileFullPath),
@@ -336,9 +340,14 @@ static ProjectInstance EvaluateProject(string? projectFilePath, Func<ProjectColl
336340
AddUserPassedProperties(globalProperties, restoreArgs);
337341

338342
var collection = new ProjectCollection(globalProperties: globalProperties, loggers: binaryLogger is null ? null : [binaryLogger], toolsetDefinitionLocations: ToolsetDefinitionLocations.Default);
339-
return projectFilePath is not null
340-
? collection.LoadProject(projectFilePath).CreateProjectInstance()
341-
: projectFactory(collection);
343+
344+
if (projectFilePath is not null)
345+
{
346+
return collection.LoadProject(projectFilePath).CreateProjectInstance();
347+
}
348+
349+
Debug.Assert(projectFactory is not null);
350+
return projectFactory(collection);
342351
}
343352

344353
static void ValidatePreconditions(ProjectInstance project)
@@ -608,9 +617,10 @@ private static void ThrowUnableToRunError(ProjectInstance project)
608617

609618
private static string? DiscoverProjectFilePath(string? projectFileOrDirectoryPath, ref string[] args, out string? entryPointFilePath)
610619
{
611-
bool emptyProjectOption = string.IsNullOrWhiteSpace(projectFileOrDirectoryPath);
612-
if (emptyProjectOption)
620+
bool emptyProjectOption = false;
621+
if (string.IsNullOrWhiteSpace(projectFileOrDirectoryPath))
613622
{
623+
emptyProjectOption = true;
614624
projectFileOrDirectoryPath = Directory.GetCurrentDirectory();
615625
}
616626

0 commit comments

Comments
 (0)