Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add null check in VSTestConsoleLocator.GetTestPlatformVersion
Co-authored-by: Youssef1313 <[email protected]>
  • Loading branch information
Copilot and Youssef1313 committed Nov 7, 2025
commit 0e82bc017890ca72e7dc49f90d6329d049bcc287
6 changes: 5 additions & 1 deletion test/Utilities/Automation.CLI/VSTestConsoleLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

private static string GetNugetPackageFolder()
{
string nugetPackagesFolderPath = Environment.GetEnvironmentVariable("NUGET_PACKAGES");

Check failure on line 46 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L46

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(46,42): error CS8600: (NETCORE_ENGINEERING_TELEMETRY=Build) Converting null literal or possible null value to non-nullable type.

Check failure on line 46 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L46

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(46,42): error CS8600: (NETCORE_ENGINEERING_TELEMETRY=Build) Converting null literal or possible null value to non-nullable type.

Check failure on line 46 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L46

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(46,42): error CS8600: (NETCORE_ENGINEERING_TELEMETRY=Build) Converting null literal or possible null value to non-nullable type.

Check failure on line 46 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L46

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(46,42): error CS8600: (NETCORE_ENGINEERING_TELEMETRY=Build) Converting null literal or possible null value to non-nullable type.
if (!string.IsNullOrEmpty(nugetPackagesFolderPath))
{
Assert.IsTrue(Directory.Exists(nugetPackagesFolderPath), $"Found environment variable 'NUGET_PACKAGES' and NuGet package folder '{nugetPackagesFolderPath}' should exist");
Expand All @@ -51,8 +51,8 @@
return nugetPackagesFolderPath;
}

string userProfile = Environment.GetEnvironmentVariable("USERPROFILE");

Check failure on line 54 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L54

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(54,30): error CS8600: (NETCORE_ENGINEERING_TELEMETRY=Build) Converting null literal or possible null value to non-nullable type.

Check failure on line 54 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L54

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(54,30): error CS8600: (NETCORE_ENGINEERING_TELEMETRY=Build) Converting null literal or possible null value to non-nullable type.

Check failure on line 54 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L54

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(54,30): error CS8600: (NETCORE_ENGINEERING_TELEMETRY=Build) Converting null literal or possible null value to non-nullable type.
nugetPackagesFolderPath = Path.Combine(userProfile, ".nuget", "packages");

Check failure on line 55 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L55

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(55,48): error CS8604: (NETCORE_ENGINEERING_TELEMETRY=Build) Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check failure on line 55 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L55

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(55,48): error CS8604: (NETCORE_ENGINEERING_TELEMETRY=Build) Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.

Check failure on line 55 in test/Utilities/Automation.CLI/VSTestConsoleLocator.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs#L55

test/Utilities/Automation.CLI/VSTestConsoleLocator.cs(55,48): error CS8604: (NETCORE_ENGINEERING_TELEMETRY=Build) Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2, string path3)'.
Assert.IsTrue(Directory.Exists(nugetPackagesFolderPath), $"NuGet package folder '{nugetPackagesFolderPath}' should exist");

return nugetPackagesFolderPath;
Expand All @@ -68,7 +68,11 @@
var cpmXml = new XmlDocument();
cpmXml.Load(xmlTextReader);

XmlNode testSdkVersion = cpmXml.DocumentElement.SelectSingleNode("PropertyGroup/MicrosoftNETTestSdkVersion");
XmlNode? testSdkVersion = cpmXml.DocumentElement?.SelectSingleNode("PropertyGroup/MicrosoftNETTestSdkVersion");
if (testSdkVersion is null)
{
throw new InvalidOperationException($"Could not find MicrosoftNETTestSdkVersion in {cpmFilePath}");
}

return testSdkVersion.InnerText;
}
Expand Down
Loading