Skip to content

Commit 73049a7

Browse files
committed
Update the code based on the feedback
1 parent 2709f62 commit 73049a7

File tree

10 files changed

+16
-14
lines changed

10 files changed

+16
-14
lines changed

test/HelixTasks/TarGzFileCreateFromDirectory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public sealed class TarGzFileCreateFromDirectory : ToolTask
3333
/// <summary>
3434
/// An item group of regular expressions for content to exclude from the archive.
3535
/// </summary>
36-
public ITaskItem[]? ExcludePatterns { get; set; }
36+
public ITaskItem[]? ExcludePatterns { get; set; }
3737

3838
public bool IgnoreExitCode { get; set; }
3939

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public override CommandResult Execute(IEnumerable<string> args)
1717
{
1818
List<string> newArgs = new();
1919
newArgs.Add("add");
20-
if (_projectName is not null && !string.IsNullOrEmpty(_projectName))
20+
if (!string.IsNullOrEmpty(_projectName))
2121
{
2222
newArgs.Add(_projectName);
2323
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public DotnetPublishCommand(ITestOutputHelper log, params string[] args) : base(
1616
protected override SdkCommandSpec CreateCommand(IEnumerable<string> args)
1717
{
1818
List<string> newArgs = new(args);
19-
if (_runtime is not null && !string.IsNullOrEmpty(_runtime))
19+
if (!string.IsNullOrEmpty(_runtime))
2020
{
2121
newArgs.Add("-r");
2222
newArgs.Add(_runtime);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public override CommandResult Execute(IEnumerable<string> args)
1717
{
1818
List<string> newArgs = new();
1919
newArgs.Add("list");
20-
if (_projectName is not null && !string.IsNullOrEmpty(_projectName))
20+
if (!string.IsNullOrEmpty(_projectName))
2121
{
2222
newArgs.Add(_projectName);
2323
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public override CommandResult Execute(IEnumerable<string> args)
1717
{
1818
List<string> newArgs = new();
1919
newArgs.Add("list");
20-
if (_projectName != null && !string.IsNullOrEmpty(_projectName))
20+
if (!string.IsNullOrEmpty(_projectName))
2121
{
2222
newArgs.Add(_projectName);
2323
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public override CommandResult Execute(IEnumerable<string> args)
1717
{
1818
List<string> newArgs = new();
1919
newArgs.Add("remove");
20-
if (_projectName is not null && !string.IsNullOrEmpty(_projectName))
20+
if (!string.IsNullOrEmpty(_projectName))
2121
{
2222
newArgs.Add(_projectName);
2323
}

test/Microsoft.NET.TestFramework/ProjectConstruction/TestProject.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ internal void Create(TestAsset targetTestAsset, string testProjectsSourceFolder,
160160
}
161161
var ns = projectXml.Root.Name.Namespace;
162162

163-
if (projectXml.Root.Attribute("Sdk") is not null && ProjectSdk != null)
163+
var sdkAttribute = projectXml.Root.Attribute("Sdk");
164+
if (sdkAttribute is not null && ProjectSdk != null)
164165
{
165-
projectXml.Root.Attribute("Sdk")!.Value = ProjectSdk;
166+
sdkAttribute.Value = ProjectSdk;
166167
}
167168

168169
var propertyGroup = projectXml.Root?.Elements(ns + "PropertyGroup").First();

test/Microsoft.NET.TestFramework/TestAsset.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ public TestAsset ReplacePackageVersionVariable(string targetName, string targetV
138138
{
139139
var packageReferencesToUpdate =
140140
project.Root.Descendants(ns + PropertyName)
141-
.Where(p => p.Attribute("Version") != null && p.Attribute("Version")!.Value.Equals($"$({targetName})", StringComparison.OrdinalIgnoreCase));
142-
foreach (var packageReference in packageReferencesToUpdate)
141+
.Select(p => p.Attribute("Version"))
142+
.Where(va => va is not null && va.Value.Equals($"$({targetName})", StringComparison.OrdinalIgnoreCase));
143+
foreach (var versionAttribute in packageReferencesToUpdate)
143144
{
144-
if(packageReference.Attribute("Version") is not null)
145+
if(versionAttribute is not null)
145146
{
146-
packageReference.Attribute("Version")!.Value = targetValue;
147+
versionAttribute.Value = targetValue;
147148
}
148149
}
149150
}

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?? string.Empty)
113+
new DotnetCommand(Log, "sln", "add", testProject.Name ?? string.Empty)
114114
.WithWorkingDirectory(testDestinationDirectory)
115115
.Execute()
116116
.Should()

test/Microsoft.NET.TestFramework/ToolsetInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public void AddTestEnvironmentVariables(IDictionary<string, string> environment)
195195
environment.Add("DOTNET_ROOT(x86)", DotNetRoot);
196196
}
197197

198-
if (CliHomePath is not null && !string.IsNullOrEmpty(CliHomePath))
198+
if (!string.IsNullOrEmpty(CliHomePath))
199199
{
200200
environment.Add("DOTNET_CLI_HOME", CliHomePath);
201201
}

0 commit comments

Comments
 (0)