Skip to content

Commit ccdf229

Browse files
[xamarin] fix Mono runtime version detection (#1429)
Context: https://github.com/mono/mono/blob/0a37eeadece5c2cec8a6e1f43a94f0b323a22513/mcs/class/corlib/Mono/Runtime.cs#L68-L73 `Mono.Runtime.GetDisplayName` is `public` on Xamarin platforms, and so we need to include `BindingFlags.Public` to call it via reflection. I updated the screenshot in the documentation to reflect what the value looks like running on Xamarin.Android in VS 2019 16.5. I also took an attempt at fixing the documentation for Xamarin, I think the link is just missing. Hopefully this URL will work now: https://benchmarkdotnet.org/articles/samples/IntroXamarin.html
1 parent e37c021 commit ccdf229

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

docs/articles/samples/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,6 @@
111111
- name: IntroTailcall
112112
href: IntroTailcall.md
113113
- name: IntroUnicode
114-
href: IntroUnicode.md
114+
href: IntroUnicode.md
115+
- name: IntroXamarin
116+
href: IntroXamarin.md

docs/images/xamarin-screenshot.png

5.33 KB
Loading

src/BenchmarkDotNet/Portability/RuntimeInformation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ internal static string GetRuntimeVersion()
121121
if (IsMono)
122122
{
123123
var monoRuntimeType = Type.GetType("Mono.Runtime");
124-
var monoDisplayName = monoRuntimeType?.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
124+
var monoDisplayName = monoRuntimeType?.GetMethod("GetDisplayName", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
125125
if (monoDisplayName != null)
126126
{
127127
string version = monoDisplayName.Invoke(null, null)?.ToString();

0 commit comments

Comments
 (0)