Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse "Mono Unity IL2CPP" correctly in platform runtime name #1742

Merged
merged 12 commits into from
Sep 1, 2022
3 changes: 2 additions & 1 deletion src/Sentry/PlatformAbstractions/RuntimeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace Sentry.PlatformAbstractions
// https://github.com/dotnet/corefx/issues/17452
internal static class RuntimeInfo
{
private static readonly Regex RuntimeParseRegex = new("^(?<name>[^\\d]*)(?<version>(\\d+\\.)+[^\\s]+)",
private static readonly Regex RuntimeParseRegex = new(
@"^(?<name>(?:[A-Za-z.]\S*\s?)*)(?:\s|^|$)(?<version>\d\S*)?",
RegexOptions.Compiled | RegexOptions.CultureInvariant);

/// <summary>
Expand Down
19 changes: 17 additions & 2 deletions test/Sentry.Tests/PlatformAbstractions/RuntimeInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public static IEnumerable<object[]> ParseTestCases()
}};
yield return new object[] { new ParseTestCase
{
Raw = ".NET Framework For Windows Mobile 10"
Raw = ".NET Framework For Windows Mobile 10",
ExpectedName = ".NET Framework For Windows Mobile",
ExpectedVersion = "10"
}};
yield return new object[] { new ParseTestCase
{
Expand All @@ -126,7 +128,8 @@ public static IEnumerable<object[]> ParseTestCases()
}};
yield return new object[] { new ParseTestCase
{
Raw = "web"
Raw = "web",
ExpectedName = "web"
}};
yield return new object[] { new ParseTestCase
{
Expand All @@ -139,6 +142,18 @@ public static IEnumerable<object[]> ParseTestCases()
ExpectedName = null,
ExpectedVersion = null
}};
yield return new object[] { new ParseTestCase
{
Raw = "Mono 6.13.0 (explicit/88268f9e785)",
ExpectedName = "Mono",
ExpectedVersion = "6.13.0"
}};
yield return new object[] { new ParseTestCase
{
Raw = "Mono Unity IL2CPP (Jun 22 2022 18:13:02)",
ExpectedName = "Mono Unity IL2CPP",
ExpectedVersion = null
}};
}

public class ParseTestCase
Expand Down