-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[generator] Avoid C#11 delegate cache overhead. (#1053)
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
- Loading branch information
Showing
61 changed files
with
167 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.