Skip to content

Commit

Permalink
(#3526) Minor fixes for mono in the benchmarks and tests
Browse files Browse the repository at this point in the history
RuntimeInformation is shadowed by Mono which means that build breaks and
because all of the namespaces are the same under Mono's version, that
name is not usable in our build currently.

We can reuse our existing Platform.GetPlatform() helper here instead,
rather than trying to disentangle exactly why this build configuration
is not particularly functional.
  • Loading branch information
vexx32 committed Oct 31, 2024
1 parent 117cf17 commit b62b5e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/chocolatey.benchmark/helpers/PinvokeProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Security.Permissions;
using System.Security;
using chocolatey.infrastructure.information;
using chocolatey.infrastructure.platforms;

namespace chocolatey.benchmark.helpers
{
Expand Down Expand Up @@ -40,7 +41,7 @@ public static ProcessTree GetDocumentedProcessTree(Process process = null)

var tree = new ProcessTree(process.ProcessName);

if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Platform.GetPlatform() != PlatformType.Windows)
{
return tree;
}
Expand All @@ -65,7 +66,7 @@ public static ProcessTree GetDocumentedProcessTree(Process process = null)

public static string GetDocumentedParent(Process process = null)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Platform.GetPlatform() != PlatformType.Windows)
{
return null;
}
Expand Down Expand Up @@ -110,7 +111,7 @@ public static string GetDocumentedParent(Process process = null)

public static string GetDocumentedParentFiltered(Process process = null)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Platform.GetPlatform() != PlatformType.Windows)
{
return null;
}
Expand Down Expand Up @@ -195,7 +196,7 @@ public static ProcessTree GetUndocumentedProcessTree(Process process = null)

public static string GetUndocumentedParent(Process process = null)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Platform.GetPlatform() != PlatformType.Windows)
{
return null;
}
Expand Down Expand Up @@ -240,7 +241,7 @@ public static string GetUndocumentedParent(Process process = null)

public static string GetUndocumentedParentFiltered(Process process = null)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Platform.GetPlatform() != PlatformType.Windows)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void Should_set_user_agent_string()
// Change this when the NuGet version is updated.
//var expectedUserAgentRegexString = @"^{0}\/[\d\.]+(-[a-z\d\.-]+)? nunit-agent\/[\d\.]+(-[a-z\d\.-]+)? \([a-z\d\.]+(,[a-z\d\.]+)?\) via NuGet Client\/[\d\.]+".FormatWith(ApplicationParameters.UserAgent);
var currentProcess = Process.GetCurrentProcess();
var expectedUserAgentRegexString = @"^{0}\/[\d\.]+(-[A-za-z\d\.-]+)? {1}\/[\d\.]+(-[A-Za-z\d\.-]+)? \([A-za-z\d\.-]+(,[A-Za-z\d\.-]+)?\) via NuGet Client\/[\d\.]+".FormatWith(ApplicationParameters.UserAgent, currentProcess.ProcessName);
var expectedUserAgentRegexString = @"^{0}\/[\d\.]+(-[A-za-z\d\.-]+)? {1}\/[\d\.]+(-[A-Za-z\d\.-]+)? (\([A-za-z\d\.-]+(,[A-Za-z\d\.-]+)?\) )?via NuGet Client\/[\d\.]+".FormatWith(ApplicationParameters.UserAgent, currentProcess.ProcessName);
UserAgent.UserAgentString.Should().MatchRegex(expectedUserAgentRegexString);
}
}
Expand Down

0 comments on commit b62b5e0

Please sign in to comment.