Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
PR fixes.
  • Loading branch information
Haplois committed Aug 22, 2022
commit d3c8cf01092ca1fbe1702d6a61557405ab7f1d84
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ private EventLogSessionContext GetEventLogSessionContext(DataCollectionContext d
eventLogContainerFound = ContextMap.TryGetValue(dataCollectionContext, out eventLogSessionContext);
}

if (eventLogContainerFound == false)
if (!eventLogContainerFound)
{
string msg = string.Format(
CultureInfo.CurrentCulture,
Expand Down
18 changes: 14 additions & 4 deletions src/Microsoft.TestPlatform.ObjectModel/TestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,23 @@ protected override void ProtectedSetPropertyValue(TestProperty property, object?
return;

case "TestCase.Id":
Id = value is Guid guid
? guid
if (value is Guid guid)
{
Id = guid;
}
else if (value is string guidString)
{
#if NET7_0_OR_GREATER
: Guid.Parse((value as string)!, CultureInfo.InvariantCulture);
Id = Guid.Parse(guidString, CultureInfo.InvariantCulture);
#else
: Guid.Parse((value as string)!);
Id = Guid.Parse(guidString);
#endif
}
else
{
Id = Guid.Empty;
}

return;

case "TestCase.LineNumber":
Expand Down
4 changes: 1 addition & 3 deletions src/Microsoft.TestPlatform.Utilities/ClientUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ public static void FixRelativePathsInRunSettings(XmlDocument xmlDocument, string

private static void AddRunSettingsDirectoryNode(XmlDocument doc, string path)
{
ValidateArg.NotNull(doc.DocumentElement, nameof(doc.DocumentElement));

var node = doc.CreateNode(XmlNodeType.Element, RunsettingsDirectory, string.Empty);
node.InnerXml = path;
doc.DocumentElement.AppendChild(node);
doc.DocumentElement!.AppendChild(node);
}

private static void FixNodeFilePath(XmlNode node, string root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ private static bool IsSettingIncompatible(Architecture sourcePlatform,
private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architecture targetPlatform)
{
return sourcePlatform is not Architecture.Default and not Architecture.AnyCPU
&& (targetPlatform == Architecture.X64 && !Is64BitOperatingSystem() || sourcePlatform != targetPlatform);
&& (targetPlatform == Architecture.X64 && !Is64BitOperatingSystem() || sourcePlatform != targetPlatform);

static bool Is64BitOperatingSystem()
{
Expand Down
10 changes: 9 additions & 1 deletion src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ internal static void AppendOrModifyChild(
var secureInnerXml = SecurityElement.Escape(innerXml);
#else
// fixing manually as we currently target to netcore 1.1 and we don't have default implementation for Escape functionality
var secureInnerXml = (innerXml ?? string.Empty).Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
string secureInnerXml;
if (innerXml.IsNullOrEmpty())
{
secureInnerXml = string.Empty;
}
else
{
secureInnerXml = innerXml.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
}
#endif
if (childNode == null)
{
Expand Down
16 changes: 8 additions & 8 deletions src/SettingsMigrator/Migrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,40 +161,40 @@ private static void MigrateTestSettingsNodesToRunSettings(string testSettingsPat
}

string? runTimeout = null;
if (testSettingsNodes.Timeout?.Attributes?[RunTimeoutAttributeName] != null)
if (testSettingsNodes?.Timeout?.Attributes?[RunTimeoutAttributeName] != null)
{
runTimeout = testSettingsNodes?.Timeout?.Attributes?[RunTimeoutAttributeName]?.Value;
}

string? parallelTestCount = null;
if (testSettingsNodes.Execution?.Attributes?[ParallelTestCountAttributeName] != null)
if (testSettingsNodes?.Execution?.Attributes?[ParallelTestCountAttributeName] != null)
{
parallelTestCount = testSettingsNodes?.Execution?.Attributes?[ParallelTestCountAttributeName]?.Value;
}

string? hostProcessPlatform = null;
if (testSettingsNodes.Execution?.Attributes?[HostProcessPlatformAttributeName] != null)
if (testSettingsNodes?.Execution?.Attributes?[HostProcessPlatformAttributeName] != null)
{
hostProcessPlatform = testSettingsNodes?.Execution?.Attributes?[HostProcessPlatformAttributeName]?.Value;
}

// WebTestRunConfiguration node.
if (testSettingsNodes.WebSettings != null)
if (testSettingsNodes?.WebSettings != null)
{
runSettingsXmlDoc?.DocumentElement?.AppendChild(runSettingsXmlDoc.ImportNode(testSettingsNodes.WebSettings, deep: true));
}

// LegacySettings node.
AddLegacyNodes(testSettingsNodes, testTimeout, parallelTestCount, hostProcessPlatform, runSettingsXmlDoc!);
AddLegacyNodes(testSettingsNodes!, testTimeout, parallelTestCount, hostProcessPlatform, runSettingsXmlDoc!);

// TestSessionTimeout node.
if (!runTimeout.IsNullOrEmpty())
{
AddRunTimeoutNode(runTimeout, runSettingsXmlDoc);
AddRunTimeoutNode(runTimeout, runSettingsXmlDoc!);
}

// DataCollectors node.
if (testSettingsNodes.Datacollectors != null && testSettingsNodes.Datacollectors.Count > 0)
if (testSettingsNodes?.Datacollectors != null && testSettingsNodes.Datacollectors.Count > 0)
{
AddDataCollectorNodes(testSettingsNodes.Datacollectors, runSettingsXmlDoc!);
}
Expand Down Expand Up @@ -229,7 +229,7 @@ private static TestSettingsNodes ReadTestSettingsNodes(string testSettingsPath)
}
}

return testSettingsNodes;
return testSettingsNodes!;
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/vstest.console/CommandLine/AssemblyMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public Architecture GetArchitecture(string assemblyPath)

var processorArchitecture =
#if NET7_0_OR_GREATER
// AssemblyName doesn't include ProcessorArchitecture in net7.
// It will always be ProcessorArchitecture.None.
ProcessorArchitecture.None;
#else
assemblyName.ProcessorArchitecture;
Expand Down