You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Repository navigation
Commit 8e18c90
Browse filesBrowse the repository at this point in the historyBrowse files
Fixes: #1034
Context: dotnet/roslyn#62832 (comment)
Context:
Context: dotnet/android@938b2cb
[The C#11 compiler was updated][0] so that "method group conversions"
are now cached:
> The C# 11 compiler caches the delegate object created from a method
> group conversion and reuses that single delegate object.
Our marshal method infrastructure uses method group conversions,
e.g. the cast to `(_JniMarshal_PP_L)` is a method group conversion:
static Delegate GetGetActionBarHandler ()
{
if (cb_getActionBar == null)
cb_getActionBar = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_L) n_GetActionBar);
return cb_getActionBar;
}
This C# 11 compiler change resulted in `Mono.Android.dll` and
.NET Android apps being ~4.5% *larger*.
This was worked around in dotnet/android@938b2cbe by setting
`$(LangVersion)`=10 (i.e. "don't use C# 11").
Update `generator` output to avoid use of method group conversion
for delegate types. This allows us to use C# 11 without increasing
the size of `Mono.Android.dll` and .NET Android apps:
static Delegate GetGetActionBarHandler ()
{
if (cb_getActionBar == null)
cb_getActionBar = JNINativeWrapper.CreateDelegate (new _JniMarshal_PP_L (n_GetActionBar));
return cb_getActionBar;
}
[0]: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11#improved-method-group-conversion-to-delegate
Copy file name to clipboardExpand all lines: tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/Common/WriteInterfaceRedeclaredDefaultMethod.txt
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
39
-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface2"));
46
+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface2'.");
40
47
return handle;
41
48
}
42
-
49
+
43
50
protected override void Dispose (bool disposing)
44
51
{
45
52
if (this.class_ref != IntPtr.Zero)
46
53
JNIEnv.DeleteGlobalRef (this.class_ref);
47
54
this.class_ref = IntPtr.Zero;
48
55
base.Dispose (disposing);
49
56
}
50
-
57
+
51
58
public IMyInterface2Invoker (IntPtr handle, JniHandleOwnership transfer) : base (Validate (handle), transfer)
Copy file name to clipboardExpand all lines: tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteMethodWithCharSequenceArrays.txt
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ public partial class MyClass : Java.Lang.Object {
Copy file name to clipboardExpand all lines: tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDefaultInterfaceMethodInvoker.txt
0 commit comments