-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove nullable disable warnings #48846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable disable warnings | ||
|
||
namespace Microsoft.DotNet.Cli.Commands.Run.LaunchSettings; | ||
|
||
public class LaunchSettingsApplyResult(bool success, string? failureReason, ProjectLaunchSettingsModel launchSettings = null) | ||
public class LaunchSettingsApplyResult(bool success, string? failureReason, ProjectLaunchSettingsModel? launchSettings = null) | ||
{ | ||
public bool Success { get; } = success; | ||
|
||
public string FailureReason { get; } = failureReason; | ||
public string? FailureReason { get; } = failureReason; | ||
|
||
public ProjectLaunchSettingsModel LaunchSettings { get; } = launchSettings; | ||
public ProjectLaunchSettingsModel? LaunchSettings { get; } = launchSettings; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
namespace Microsoft.DotNet.Cli.Commands.Run; | ||
|
||
internal record RunProperties(string? RunCommand, string? RunArguments, string? RunWorkingDirectory) | ||
internal record RunProperties(string RunCommand, string? RunArguments, string? RunWorkingDirectory) | ||
jaredpar marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is another place where having arguments, specifically |
||
{ | ||
internal static RunProperties FromProjectAndApplicationArguments(ProjectInstance project, string[] applicationArgs, bool fallbackToTargetPath) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +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 disable warnings | ||
|
||
using System.CommandLine; | ||
using System.Diagnostics; | ||
using Microsoft.Build.Construction; | ||
using Microsoft.Build.Exceptions; | ||
using Microsoft.Build.Execution; | ||
|
@@ -39,7 +38,7 @@ private static bool IsSolutionFolderPathInDirectoryScope(string relativePath) | |
|
||
public SolutionAddCommand(ParseResult parseResult) : base(parseResult) | ||
{ | ||
_fileOrDirectory = parseResult.GetValue(SolutionCommandParser.SlnArgument); | ||
_fileOrDirectory = parseResult.GetValue(SolutionCommandParser.SlnArgument)!; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We chatted about this briefly but the main gap here is that the S.CL library enforces the arity of an option/argument but there's no way for that Arity to influence the return type of this method. |
||
_projects = (IReadOnlyCollection<string>)(parseResult.GetValue(SolutionAddCommandParser.ProjectPathArgument) ?? []); | ||
_inRoot = parseResult.GetValue(SolutionAddCommandParser.InRootOption); | ||
_solutionFolderPath = parseResult.GetValue(SolutionAddCommandParser.SolutionFolderOption); | ||
|
@@ -75,12 +74,13 @@ public override int Execute() | |
return null; | ||
} | ||
|
||
string relativeSolutionFolderPath = string.Empty; | ||
string? relativeSolutionFolderPath = string.Empty; | ||
|
||
if (string.IsNullOrEmpty(_solutionFolderPath)) | ||
{ | ||
// Generate the solution folder path based on the project path | ||
relativeSolutionFolderPath = Path.GetDirectoryName(relativeProjectPath); | ||
Debug.Assert(relativeSolutionFolderPath is not null); | ||
|
||
// If the project is in a folder with the same name as the project, we need to go up one level | ||
if (relativeSolutionFolderPath.Split(Path.DirectorySeparatorChar).LastOrDefault() == Path.GetFileNameWithoutExtension(relativeProjectPath)) | ||
|
@@ -108,6 +108,7 @@ public override int Execute() | |
private async Task AddProjectsToSolutionAsync(IEnumerable<string> projectPaths, CancellationToken cancellationToken) | ||
{ | ||
SolutionModel solution = SlnFileFactory.CreateFromFileOrDirectory(_solutionFileFullPath); | ||
Debug.Assert(solution.SerializerExtension is not null); | ||
ISolutionSerializer serializer = solution.SerializerExtension.Serializer; | ||
|
||
// set UTF8 BOM encoding for .sln | ||
|
@@ -138,9 +139,9 @@ private async Task AddProjectsToSolutionAsync(IEnumerable<string> projectPaths, | |
await serializer.SaveAsync(_solutionFileFullPath, solution, cancellationToken); | ||
} | ||
|
||
private void AddProject(SolutionModel solution, string fullProjectPath, ISolutionSerializer serializer = null) | ||
private void AddProject(SolutionModel solution, string fullProjectPath, ISolutionSerializer? serializer = null) | ||
{ | ||
string solutionRelativeProjectPath = Path.GetRelativePath(Path.GetDirectoryName(_solutionFileFullPath), fullProjectPath); | ||
string solutionRelativeProjectPath = Path.GetRelativePath(Path.GetDirectoryName(_solutionFileFullPath)!, fullProjectPath); | ||
|
||
// Open project instance to see if it is a valid project | ||
ProjectRootElement projectRootElement; | ||
|
@@ -193,14 +194,14 @@ private void AddProject(SolutionModel solution, string fullProjectPath, ISolutio | |
foreach (var solutionPlatform in solution.Platforms) | ||
{ | ||
var projectPlatform = projectInstancePlatforms.FirstOrDefault( | ||
platform => platform.Replace(" ", string.Empty) == solutionPlatform.Replace(" ", string.Empty), projectInstancePlatforms.FirstOrDefault()); | ||
platform => platform.Replace(" ", string.Empty) == solutionPlatform.Replace(" ", string.Empty), projectInstancePlatforms.FirstOrDefault()!); | ||
Comment on lines
201
to
+202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lacking the |
||
project.AddProjectConfigurationRule(new ConfigurationRule(BuildDimension.Platform, "*", solutionPlatform, projectPlatform)); | ||
} | ||
|
||
foreach (var solutionBuildType in solution.BuildTypes) | ||
{ | ||
var projectBuildType = projectInstanceBuildTypes.FirstOrDefault( | ||
buildType => buildType.Replace(" ", string.Empty) == solutionBuildType.Replace(" ", string.Empty), projectInstanceBuildTypes.FirstOrDefault()); | ||
buildType => buildType.Replace(" ", string.Empty) == solutionBuildType.Replace(" ", string.Empty), projectInstanceBuildTypes.FirstOrDefault()!); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
project.AddProjectConfigurationRule(new ConfigurationRule(BuildDimension.BuildType, solutionBuildType, "*", projectBuildType)); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having
Args
be potentiallynull
seems suspicious, I considered changing this to the following but don't know enough about the code base to say if that is okay