Skip to content

Mono.Android.dll IL Size increase in .NET 7 Preview 7 & RC 1 #62832

@jonathanpeppers

Description

@jonathanpeppers

Version Used:

Happens in both:

  • .NET 7.0.100-rc.1.22368.2 SDK
  • .NET 7.0.100-preview.7.22370.3 SDK

Noticed this here: dotnet/android#7170

Steps to Reproduce:

  1. Build xamarin-android
  2. Observe the size of Mono.Android.dll. This is a C# "binding" of every Android API.
34502656 Mono.Android.net7.rc1.dll
32999936 Mono.Android.xa.main.dll

When I rain monodis --typedef, I noticed a bunch of new types generated, such as:

[CompilerGenerated]
private static class <>O
{
	public static _JniMarshal_PP_L <0>__n_Sink;

	public static _JniMarshal_PP_L <1>__n_Source;
}

I tried to use ILSpy to understand how these are used:

private static Delegate GetSinkHandler()
{
	if ((object)cb_sink == null)
	{
		cb_sink = JNINativeWrapper.CreateDelegate(new _JniMarshal_PP_L(n_Sink));
	}
	return cb_sink;
}

In this case, the above method is called once and would only allocate a _JniMarshal_PP_L once. Are we paying extra file size for something that will only be called once?

Is there some flag to turn off this feature? (at least for this assembly) Thanks!

Here is before & after, and the monodis output: Mono.Android.zip

Expected Behavior:

Updating the .NET SDK, shouldn't increase the size of Mono.Android.dll noticeably.

Actual Behavior:

Updating the .NET SDK, increases the size of Mono.Android.dll.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions