Skip to content

Commit 12ee199

Browse files
committed
Remove '!' operators
1 parent 596d00c commit 12ee199

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

test/Microsoft.NET.Build.Containers.IntegrationTests/EndToEndTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,14 @@ public async Task EndToEnd_NoAPI_ProjectType(string projectType, bool addPackage
328328

329329
(string? packagePath, string? packageVersion) = ToolsetUtils.GetContainersPackagePath();
330330

331-
new DotnetCommand(_testOutput, "nuget", "add", "source", Path.GetDirectoryName(packagePath), "--name", "local-temp")
331+
new DotnetCommand(_testOutput, "nuget", "add", "source", Path.GetDirectoryName(packagePath) ?? string.Empty, "--name", "local-temp")
332332
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
333333
.WithWorkingDirectory(newProjectDir.FullName)
334334
.Execute()
335335
.Should().Pass();
336336

337337
// Add package to the project
338-
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "-f", ToolsetInfo.CurrentTargetFramework, "-v", packageVersion)
338+
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "-f", ToolsetInfo.CurrentTargetFramework, "-v", packageVersion ?? string.Empty)
339339
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
340340
.WithWorkingDirectory(newProjectDir.FullName)
341341
.Execute()
@@ -499,14 +499,14 @@ public void EndToEnd_NoAPI_Console()
499499

500500
(string? packagePath, string? packageVersion) = ToolsetUtils.GetContainersPackagePath();
501501

502-
new DotnetCommand(_testOutput, "nuget", "add", "source", Path.GetDirectoryName(packagePath), "--name", "local-temp")
502+
new DotnetCommand(_testOutput, "nuget", "add", "source", Path.GetDirectoryName(packagePath) ?? string.Empty, "--name", "local-temp")
503503
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
504504
.WithWorkingDirectory(newProjectDir.FullName)
505505
.Execute()
506506
.Should().Pass();
507507

508508
// Add package to the project
509-
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "-f", ToolsetInfo.CurrentTargetFramework, "-v", packageVersion)
509+
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "-f", ToolsetInfo.CurrentTargetFramework, "-v", packageVersion ?? string.Empty)
510510
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
511511
.WithWorkingDirectory(newProjectDir.FullName)
512512
.Execute()

test/Microsoft.NET.TestFramework/Commands/DotnetCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace Microsoft.NET.TestFramework.Commands
55
{
66
public class DotnetCommand : TestCommand
77
{
8-
public DotnetCommand(ITestOutputHelper log, params string?[] args) : base(log)
8+
public DotnetCommand(ITestOutputHelper log, params string[] args) : base(log)
99
{
10-
Arguments.AddRange(args!);
10+
Arguments.AddRange(args);
1111
}
1212

1313
protected override SdkCommandSpec CreateCommand(IEnumerable<string> args)

test/Microsoft.NET.TestFramework/OutputPathCalculator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public string GetPublishDirectory(string? targetFramework = null, string configu
236236

237237
if (IncludeProjectNameInArtifactsPaths)
238238
{
239-
return Path.Combine(ArtifactsPath ?? string.Empty, "publish", Path.GetFileNameWithoutExtension(ProjectPath)!, pivot);
239+
return Path.Combine(ArtifactsPath ?? string.Empty, "publish", Path.GetFileNameWithoutExtension(ProjectPath) ?? string.Empty, pivot);
240240
}
241241
else
242242
{

test/Microsoft.NET.TestFramework/TestAsset.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public TestAsset ReplacePackageVersionVariable(string targetName, string targetV
133133
{
134134
if (project.Root is not null)
135135
{
136-
var ns = project.Root!.Name.Namespace;
136+
var ns = project.Root.Name.Namespace;
137137
foreach (var PropertyName in PropertyNames)
138138
{
139139
var packageReferencesToUpdate =
@@ -234,7 +234,7 @@ public TestAsset WithProjectChanges(Action<string, XDocument> xmlAction)
234234
{
235235
FindProjectFiles();
236236
}
237-
foreach (var projectFile in _projectFiles!)
237+
foreach (var projectFile in _projectFiles ?? new())
238238
{
239239
var project = XDocument.Load(projectFile);
240240

test/Microsoft.NET.TestFramework/TestAssetsManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public TestAsset CreateTestProjects(
110110

111111
foreach (var testProject in testProjects)
112112
{
113-
new DotnetCommand(Log, "sln", "add", testProject.Name)
113+
new DotnetCommand(Log, "sln", "add", testProject.Name?? string.Empty)
114114
.WithWorkingDirectory(testDestinationDirectory)
115115
.Execute()
116116
.Should()

0 commit comments

Comments
 (0)