Skip to content

Commit

Permalink
Nullable-enable RunCommand.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Feb 20, 2025
1 parent 9f51756 commit 5a5206f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Cli/dotnet/commands/dotnet-run/RunCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable

using System.Diagnostics;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Exceptions;
Expand Down Expand Up @@ -275,6 +277,8 @@ private void EnsureProjectIsBuilt(out Func<ProjectCollection, ProjectInstance>?
}
else
{
Debug.Assert(ProjectFileFullPath is not null);

projectFactory = null;
buildResult = new RestoringCommand(
RestoreArgs.Prepend(ProjectFileFullPath),
Expand Down Expand Up @@ -336,9 +340,14 @@ static ProjectInstance EvaluateProject(string? projectFilePath, Func<ProjectColl
AddUserPassedProperties(globalProperties, restoreArgs);

var collection = new ProjectCollection(globalProperties: globalProperties, loggers: binaryLogger is null ? null : [binaryLogger], toolsetDefinitionLocations: ToolsetDefinitionLocations.Default);
return projectFilePath is not null
? collection.LoadProject(projectFilePath).CreateProjectInstance()
: projectFactory(collection);

if (projectFilePath is not null)
{
return collection.LoadProject(projectFilePath).CreateProjectInstance();
}

Debug.Assert(projectFactory is not null);
return projectFactory(collection);
}

static void ValidatePreconditions(ProjectInstance project)
Expand Down Expand Up @@ -608,9 +617,10 @@ private static void ThrowUnableToRunError(ProjectInstance project)

private static string? DiscoverProjectFilePath(string? projectFileOrDirectoryPath, ref string[] args, out string? entryPointFilePath)
{
bool emptyProjectOption = string.IsNullOrWhiteSpace(projectFileOrDirectoryPath);
if (emptyProjectOption)
bool emptyProjectOption = false;
if (string.IsNullOrWhiteSpace(projectFileOrDirectoryPath))
{
emptyProjectOption = true;
projectFileOrDirectoryPath = Directory.GetCurrentDirectory();
}

Expand Down

0 comments on commit 5a5206f

Please sign in to comment.