diff --git a/TestPlatform.sln b/TestPlatform.sln
index adc8df88c0..3a6da5e5cb 100644
--- a/TestPlatform.sln
+++ b/TestPlatform.sln
@@ -1039,6 +1039,7 @@ Global
src\Microsoft.TestPlatform.Nullability\Microsoft.TestPlatform.Nullability.projitems*{61f7f446-9ef3-4768-b33a-4d75f60e1059}*SharedItemsImports = 5
src\Microsoft.TestPlatform.Nullability\Microsoft.TestPlatform.Nullability.projitems*{65a25d6e-c9cc-4f45-8925-04087ac82634}*SharedItemsImports = 5
src\Microsoft.TestPlatform.Nullability\Microsoft.TestPlatform.Nullability.projitems*{68adc720-316e-4895-9f8e-c3ccadd262be}*SharedItemsImports = 5
+ src\Microsoft.TestPlatform.Nullability\Microsoft.TestPlatform.Nullability.projitems*{6f5ec38c-4a11-40d3-827c-f607b90beff0}*SharedItemsImports = 5
src\Microsoft.TestPlatform.Execution.Shared\Microsoft.TestPlatform.Execution.Shared.projitems*{71cb42ff-e750-4a3b-9c3a-ac938853cc89}*SharedItemsImports = 5
src\Microsoft.TestPlatform.Nullability\Microsoft.TestPlatform.Nullability.projitems*{76d4bb7e-d981-42d5-be96-6fad8def9a4a}*SharedItemsImports = 5
src\Microsoft.TestPlatform.Execution.Shared\Microsoft.TestPlatform.Execution.Shared.projitems*{7f26eda3-c8c4-4b7f-a9b6-d278c2f40a13}*SharedItemsImports = 13
diff --git a/src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs b/src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs
index 704dc54703..8d9f22b6b5 100644
--- a/src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs
+++ b/src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs
@@ -4,8 +4,6 @@
using System;
using System.Text;
-#nullable disable
-
namespace Microsoft.TestPlatform.Build.Utils;
public static class ArgumentEscaper
diff --git a/src/Microsoft.TestPlatform.Build/BannedSymbols.txt b/src/Microsoft.TestPlatform.Build/BannedSymbols.txt
new file mode 100644
index 0000000000..c3370ddb45
--- /dev/null
+++ b/src/Microsoft.TestPlatform.Build/BannedSymbols.txt
@@ -0,0 +1,4 @@
+M:System.Diagnostics.Debug.Assert(System.Boolean); Use 'TPDebug.Assert' instead
+M:System.Diagnostics.Debug.Assert(System.Boolean,System.String); Use 'TPDebug.Assert' instead
+M:System.String.IsNullOrEmpty(System.String); Use 'StringUtils.IsNullOrEmpty' instead
+M:System.String.IsNullOrWhiteSpace(System.String); Use 'StringUtils.IsNullOrWhiteSpace' instead
diff --git a/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.Build.csproj b/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.Build.csproj
index bd6b731556..da48eefad1 100644
--- a/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.Build.csproj
+++ b/src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.Build.csproj
@@ -3,6 +3,7 @@
..\..\
+
2.0.0
@@ -10,6 +11,7 @@
netstandard2.0
net6.0
false
+ true
@@ -37,6 +39,7 @@
+
diff --git a/src/Microsoft.TestPlatform.Build/PublicAPI/PublicAPI.Shipped.txt b/src/Microsoft.TestPlatform.Build/PublicAPI/PublicAPI.Shipped.txt
index 9cd80864ae..7dc5c58110 100644
--- a/src/Microsoft.TestPlatform.Build/PublicAPI/PublicAPI.Shipped.txt
+++ b/src/Microsoft.TestPlatform.Build/PublicAPI/PublicAPI.Shipped.txt
@@ -1,70 +1 @@
-Microsoft.TestPlatform.Build.Tasks.VSTestForwardingApp
-Microsoft.TestPlatform.Build.Tasks.VSTestForwardingApp.Cancel() -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestForwardingApp.Execute() -> int
-Microsoft.TestPlatform.Build.Tasks.VSTestForwardingApp.VSTestForwardingApp(string vsTestExePath, System.Collections.Generic.IEnumerable argsToForward) -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask
-Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.LogType.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.LogType.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.ProjectFilePath.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.ProjectFilePath.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.VSTestLogsTask() -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.Cancel() -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.TestFileFullPath.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.TestFileFullPath.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlame.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlame.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrash.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrash.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrashCollectAlways.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrashCollectAlways.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrashDumpType.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrashDumpType.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHang.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHang.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHangDumpType.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHangDumpType.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHangTimeout.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHangTimeout.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestCLIRunSettings.get -> string[]
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestCLIRunSettings.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestCollect.get -> string[]
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestCollect.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestConsolePath.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestConsolePath.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestDiag.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestDiag.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestFramework.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestFramework.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestListTests.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestListTests.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestLogger.get -> string[]
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestLogger.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestNoLogo.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestNoLogo.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestArtifactsProcessingMode.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestArtifactsProcessingMode.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestSessionCorrelationId.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestSessionCorrelationId.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestPlatform.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestPlatform.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestResultsDirectory.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestResultsDirectory.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestSetting.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestSetting.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTask() -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTestAdapterPath.get -> string[]
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTestAdapterPath.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTestCaseFilter.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTestCaseFilter.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTraceDataCollectorDirectoryPath.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTraceDataCollectorDirectoryPath.set -> void
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestVerbosity.get -> string
-Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestVerbosity.set -> void
-Microsoft.TestPlatform.Build.Trace.Tracing
-Microsoft.TestPlatform.Build.Utils.ArgumentEscaper
-override Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.Execute() -> bool
-override Microsoft.TestPlatform.Build.Tasks.VSTestTask.Execute() -> bool
-static Microsoft.TestPlatform.Build.Trace.Tracing.Trace(string message) -> void
-static Microsoft.TestPlatform.Build.Trace.Tracing.traceEnabled -> bool
-static Microsoft.TestPlatform.Build.Utils.ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(string arg) -> string
+#nullable enable
diff --git a/src/Microsoft.TestPlatform.Build/PublicAPI/PublicAPI.Unshipped.txt b/src/Microsoft.TestPlatform.Build/PublicAPI/PublicAPI.Unshipped.txt
index e69de29bb2..54a3746cfc 100644
--- a/src/Microsoft.TestPlatform.Build/PublicAPI/PublicAPI.Unshipped.txt
+++ b/src/Microsoft.TestPlatform.Build/PublicAPI/PublicAPI.Unshipped.txt
@@ -0,0 +1,70 @@
+Microsoft.TestPlatform.Build.Tasks.VSTestForwardingApp
+Microsoft.TestPlatform.Build.Tasks.VSTestForwardingApp.Cancel() -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestForwardingApp.Execute() -> int
+Microsoft.TestPlatform.Build.Tasks.VSTestForwardingApp.VSTestForwardingApp(string! vsTestExePath, System.Collections.Generic.IEnumerable! argsToForward) -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask
+Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.LogType.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.LogType.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.ProjectFilePath.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.ProjectFilePath.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.VSTestLogsTask() -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.Cancel() -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.TestFileFullPath.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.TestFileFullPath.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestArtifactsProcessingMode.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestArtifactsProcessingMode.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlame.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlame.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrash.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrash.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrashCollectAlways.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrashCollectAlways.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrashDumpType.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameCrashDumpType.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHang.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHang.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHangDumpType.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHangDumpType.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHangTimeout.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestBlameHangTimeout.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestCLIRunSettings.get -> string![]?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestCLIRunSettings.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestCollect.get -> string![]?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestCollect.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestConsolePath.get -> string!
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestConsolePath.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestDiag.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestDiag.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestFramework.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestFramework.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestListTests.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestListTests.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestLogger.get -> string![]?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestLogger.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestNoLogo.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestNoLogo.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestPlatform.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestPlatform.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestResultsDirectory.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestResultsDirectory.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestSessionCorrelationId.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestSessionCorrelationId.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestSetting.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestSetting.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTask() -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTestAdapterPath.get -> string![]?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTestAdapterPath.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTestCaseFilter.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTestCaseFilter.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTraceDataCollectorDirectoryPath.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestTraceDataCollectorDirectoryPath.set -> void
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestVerbosity.get -> string?
+Microsoft.TestPlatform.Build.Tasks.VSTestTask.VSTestVerbosity.set -> void
+Microsoft.TestPlatform.Build.Trace.Tracing
+Microsoft.TestPlatform.Build.Utils.ArgumentEscaper
+override Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask.Execute() -> bool
+override Microsoft.TestPlatform.Build.Tasks.VSTestTask.Execute() -> bool
+static Microsoft.TestPlatform.Build.Trace.Tracing.Trace(string! message) -> void
+static Microsoft.TestPlatform.Build.Trace.Tracing.traceEnabled -> bool
+static Microsoft.TestPlatform.Build.Utils.ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(string! arg) -> string!
diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs
index 46da877e92..618cdf342c 100644
--- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs
+++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs
@@ -8,8 +8,6 @@
using Microsoft.TestPlatform.Build.Trace;
using Microsoft.TestPlatform.Build.Utils;
-#nullable disable
-
namespace Microsoft.TestPlatform.Build.Tasks;
public class VSTestForwardingApp
@@ -58,7 +56,7 @@ public void Cancel()
}
catch (ArgumentException ex)
{
- Tracing.Trace(string.Format("VSTest: Killing process throws ArgumentException with the following message {0}. It may be that process is not running", ex));
+ Tracing.Trace($"VSTest: Killing process throws ArgumentException with the following message {ex}. It may be that process is not running");
}
}
}
diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestLogsTask.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestLogsTask.cs
index 5b3d30acef..d5dfe8c7db 100644
--- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestLogsTask.cs
+++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestLogsTask.cs
@@ -1,28 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
-#nullable disable
-
namespace Microsoft.TestPlatform.Build.Tasks;
public class VSTestLogsTask : Task
{
- public string LogType
- {
- get;
- set;
- }
+ public string? LogType { get; set; }
- public string ProjectFilePath
- {
- get;
- set;
- }
+ public string? ProjectFilePath { get; set; }
public override bool Execute()
{
diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs
index 6364c8cc31..429cfc45dd 100644
--- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs
+++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs
@@ -11,175 +11,78 @@
using Microsoft.Build.Utilities;
using Microsoft.TestPlatform.Build.Trace;
using Microsoft.TestPlatform.Build.Utils;
-
-#nullable disable
+using Microsoft.VisualStudio.TestPlatform;
namespace Microsoft.TestPlatform.Build.Tasks;
public class VSTestTask : Task, ICancelableTask
{
// The process which is invoking vstest.console
- private VSTestForwardingApp _vsTestForwardingApp;
+ private VSTestForwardingApp? _vsTestForwardingApp;
private const string VsTestAppName = "vstest.console.dll";
private const string CodeCovergaeString = "Code Coverage";
- public string TestFileFullPath
- {
- get;
- set;
- }
+ public string? TestFileFullPath { get; set; }
- public string VSTestSetting
- {
- get;
- set;
- }
+ public string? VSTestSetting { get; set; }
- public string[] VSTestTestAdapterPath
- {
- get;
- set;
- }
+ public string[]? VSTestTestAdapterPath { get; set; }
- public string VSTestFramework
- {
- get;
- set;
- }
+ public string? VSTestFramework { get; set; }
- public string VSTestPlatform
- {
- get;
- set;
- }
+ public string? VSTestPlatform { get; set; }
- public string VSTestTestCaseFilter
- {
- get;
- set;
- }
- public string[] VSTestLogger
- {
- get;
- set;
- }
+ public string? VSTestTestCaseFilter { get; set; }
- public string VSTestListTests
- {
- get;
- set;
- }
+ public string[]? VSTestLogger { get; set; }
- public string VSTestDiag
- {
- get;
- set;
- }
+ public string? VSTestListTests { get; set; }
- public string[] VSTestCLIRunSettings
- {
- get;
- set;
- }
+ public string? VSTestDiag { get; set; }
+
+ public string[]? VSTestCLIRunSettings { get; set; }
[Required]
- public string VSTestConsolePath
- {
- get;
- set;
- }
+ // Initialized to empty string to allow declaring as non-nullable, the property is marked as
+ // required so we can ensure that the property is set to non-null before the task is executed.
+ public string VSTestConsolePath { get; set; } = "";
- public string VSTestResultsDirectory
- {
- get;
- set;
- }
+ public string? VSTestResultsDirectory { get; set; }
- public string VSTestVerbosity
- {
- get;
- set;
- }
+ public string? VSTestVerbosity { get; set; }
- public string[] VSTestCollect
- {
- get;
- set;
- }
+ public string[]? VSTestCollect { get; set; }
- public string VSTestBlame
- {
- get;
- set;
- }
+ public string? VSTestBlame { get; set; }
- public string VSTestBlameCrash
- {
- get;
- set;
- }
+ public string? VSTestBlameCrash { get; set; }
- public string VSTestBlameCrashDumpType
- {
- get;
- set;
- }
+ public string? VSTestBlameCrashDumpType { get; set; }
- public string VSTestBlameCrashCollectAlways
- {
- get;
- set;
- }
+ public string? VSTestBlameCrashCollectAlways { get; set; }
- public string VSTestBlameHang
- {
- get;
- set;
- }
+ public string? VSTestBlameHang { get; set; }
- public string VSTestBlameHangDumpType
- {
- get;
- set;
- }
- public string VSTestBlameHangTimeout
- {
- get;
- set;
- }
+ public string? VSTestBlameHangDumpType { get; set; }
- public string VSTestTraceDataCollectorDirectoryPath
- {
- get;
- set;
- }
+ public string? VSTestBlameHangTimeout { get; set; }
- public string VSTestNoLogo
- {
- get;
- set;
- }
+ public string? VSTestTraceDataCollectorDirectoryPath { get; set; }
- public string VSTestArtifactsProcessingMode
- {
- get;
- set;
- }
+ public string? VSTestNoLogo { get; set; }
- public string VSTestSessionCorrelationId
- {
- get;
- set;
- }
+ public string? VSTestArtifactsProcessingMode { get; set; }
+
+ public string? VSTestSessionCorrelationId { get; set; }
public override bool Execute()
{
var traceEnabledValue = Environment.GetEnvironmentVariable("VSTEST_BUILD_TRACE");
- Tracing.traceEnabled = !string.IsNullOrEmpty(traceEnabledValue) && traceEnabledValue.Equals("1", StringComparison.OrdinalIgnoreCase);
+ Tracing.traceEnabled = !traceEnabledValue.IsNullOrEmpty() && traceEnabledValue.Equals("1", StringComparison.OrdinalIgnoreCase);
var debugEnabled = Environment.GetEnvironmentVariable("VSTEST_BUILD_DEBUG");
- if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal))
+ if (!debugEnabled.IsNullOrEmpty() && debugEnabled.Equals("1", StringComparison.Ordinal))
{
Console.WriteLine("Waiting for debugger attach...");
@@ -200,7 +103,7 @@ public override bool Execute()
allowfailureWithoutError?.SetValue(BuildEngine, true);
_vsTestForwardingApp = new VSTestForwardingApp(VSTestConsolePath, CreateArgument());
- if (!string.IsNullOrEmpty(VSTestFramework))
+ if (!VSTestFramework.IsNullOrEmpty())
{
Console.WriteLine(Resources.Resources.TestRunningSummary, TestFileFullPath, VSTestFramework);
}
@@ -211,7 +114,7 @@ public override bool Execute()
public void Cancel()
{
Tracing.Trace("VSTest: Killing the process...");
- _vsTestForwardingApp.Cancel();
+ _vsTestForwardingApp?.Cancel();
}
internal IEnumerable CreateArgument()
@@ -244,7 +147,7 @@ private List AddArgs()
var allArgs = new List();
// TODO log arguments in task
- if (!string.IsNullOrEmpty(VSTestSetting))
+ if (!VSTestSetting.IsNullOrEmpty())
{
isRunSettingsEnabled = true;
allArgs.Add("--settings:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestSetting));
@@ -258,18 +161,18 @@ private List AddArgs()
}
}
- if (!string.IsNullOrEmpty(VSTestFramework))
+ if (!VSTestFramework.IsNullOrEmpty())
{
allArgs.Add("--framework:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestFramework));
}
// vstest.console only support x86 and x64 for argument platform
- if (!string.IsNullOrEmpty(VSTestPlatform) && !VSTestPlatform.Contains("AnyCPU"))
+ if (!VSTestPlatform.IsNullOrEmpty() && !VSTestPlatform.Contains("AnyCPU"))
{
allArgs.Add("--platform:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestPlatform));
}
- if (!string.IsNullOrEmpty(VSTestTestCaseFilter))
+ if (!VSTestTestCaseFilter.IsNullOrEmpty())
{
allArgs.Add("--testCaseFilter:" +
ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestTestCaseFilter));
@@ -288,23 +191,23 @@ private List AddArgs()
}
}
- if (!string.IsNullOrEmpty(VSTestResultsDirectory))
+ if (!VSTestResultsDirectory.IsNullOrEmpty())
{
allArgs.Add("--resultsDirectory:" +
ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestResultsDirectory));
}
- if (!string.IsNullOrEmpty(VSTestListTests))
+ if (!VSTestListTests.IsNullOrEmpty())
{
allArgs.Add("--listTests");
}
- if (!string.IsNullOrEmpty(VSTestDiag))
+ if (!VSTestDiag.IsNullOrEmpty())
{
allArgs.Add("--Diag:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestDiag));
}
- if (string.IsNullOrEmpty(TestFileFullPath))
+ if (TestFileFullPath.IsNullOrEmpty())
{
Log.LogError("Test file path cannot be empty or null.");
}
@@ -314,7 +217,7 @@ private List AddArgs()
}
// Console logger was not specified by user, but verbosity was, hence add default console logger with verbosity as specified
- if (!string.IsNullOrWhiteSpace(VSTestVerbosity) && !isConsoleLoggerSpecifiedByUser)
+ if (!VSTestVerbosity.IsNullOrWhiteSpace() && !isConsoleLoggerSpecifiedByUser)
{
var normalTestLogging = new List() { "n", "normal", "d", "detailed", "diag", "diagnostic" };
var quietTestLogging = new List() { "q", "quiet" };
@@ -332,9 +235,9 @@ private List AddArgs()
allArgs.Add("--logger:Console;Verbosity=" + vsTestVerbosity);
}
- var blameCrash = !string.IsNullOrEmpty(VSTestBlameCrash);
- var blameHang = !string.IsNullOrEmpty(VSTestBlameHang);
- if (!string.IsNullOrEmpty(VSTestBlame) || blameCrash || blameHang)
+ var blameCrash = !VSTestBlameCrash.IsNullOrEmpty();
+ var blameHang = !VSTestBlameHang.IsNullOrEmpty();
+ if (!VSTestBlame.IsNullOrEmpty() || blameCrash || blameHang)
{
var blameArgs = "--Blame";
@@ -344,12 +247,12 @@ private List AddArgs()
if (blameCrash)
{
dumpArgs.Add("CollectDump");
- if (!string.IsNullOrEmpty(VSTestBlameCrashCollectAlways))
+ if (!VSTestBlameCrashCollectAlways.IsNullOrEmpty())
{
dumpArgs.Add($"CollectAlways={VSTestBlameCrashCollectAlways}");
}
- if (!string.IsNullOrEmpty(VSTestBlameCrashDumpType))
+ if (!VSTestBlameCrashDumpType.IsNullOrEmpty())
{
dumpArgs.Add($"DumpType={VSTestBlameCrashDumpType}");
}
@@ -359,12 +262,12 @@ private List AddArgs()
{
dumpArgs.Add("CollectHangDump");
- if (!string.IsNullOrEmpty(VSTestBlameHangDumpType))
+ if (!VSTestBlameHangDumpType.IsNullOrEmpty())
{
dumpArgs.Add($"HangDumpType={VSTestBlameHangDumpType}");
}
- if (!string.IsNullOrEmpty(VSTestBlameHangTimeout))
+ if (!VSTestBlameHangTimeout.IsNullOrEmpty())
{
dumpArgs.Add($"TestTimeout={VSTestBlameHangTimeout}");
}
@@ -406,7 +309,7 @@ private List AddArgs()
// 2. Impact of adding adapter path always is minimal. (worst case: loads additional data collector assembly in datacollector process.)
// This is required due to currently trace datacollector not ships with dotnet sdk, can be remove once we have
// go code coverage x-plat.
- if (!string.IsNullOrEmpty(VSTestTraceDataCollectorDirectoryPath))
+ if (!VSTestTraceDataCollectorDirectoryPath.IsNullOrEmpty())
{
allArgs.Add("--testAdapterPath:" +
ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(
@@ -423,17 +326,17 @@ private List AddArgs()
}
}
- if (!string.IsNullOrWhiteSpace(VSTestNoLogo))
+ if (!VSTestNoLogo.IsNullOrWhiteSpace())
{
allArgs.Add("--nologo");
}
- if (!string.IsNullOrEmpty(VSTestArtifactsProcessingMode) && VSTestArtifactsProcessingMode.Equals("collect", StringComparison.OrdinalIgnoreCase))
+ if (!VSTestArtifactsProcessingMode.IsNullOrEmpty() && VSTestArtifactsProcessingMode.Equals("collect", StringComparison.OrdinalIgnoreCase))
{
allArgs.Add("--artifactsProcessingMode-collect");
}
- if (!string.IsNullOrEmpty(VSTestSessionCorrelationId))
+ if (!VSTestSessionCorrelationId.IsNullOrEmpty())
{
allArgs.Add("--testSessionCorrelationId:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(VSTestSessionCorrelationId));
}
diff --git a/src/Microsoft.TestPlatform.Build/Tracing.cs b/src/Microsoft.TestPlatform.Build/Tracing.cs
index 79d052b30d..1cb8b3f8e6 100644
--- a/src/Microsoft.TestPlatform.Build/Tracing.cs
+++ b/src/Microsoft.TestPlatform.Build/Tracing.cs
@@ -3,8 +3,6 @@
using System;
-#nullable disable
-
namespace Microsoft.TestPlatform.Build.Trace;
public static class Tracing