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

[Xamarin.Android.Build.Tasks] Use marshal-ilgen component #7260

Merged
merged 1 commit into from
Aug 17, 2022

Conversation

jonpryor
Copy link
Member

Fixes: #7249

Context: dotnet/runtime#71203
Context: dotnet/runtime#60639
Context: dotnet/runtime#61685

Mono introduced a new marshal-ilgen component in
dotnet/runtime@de32c446 which needs to be used when
non-blittable type is required.

string marshaling is a form of non-blittable marshaling.

Eventually the idea is that assemblies should migrate to use the
DllImport Generator for non-blittable marshaling purposes,
then [assembly:DisableRuntimeMarshallingAttribute] can be
applied to the assembly, and -- if no assemblies in an Android app
require non-blittable marshaling -- then the marshal-ilgen
component can be omitted from the .apk, reducing app size.

That's a fair number of ifs; this won't be happening soon.

In the meantime, we need to start including the marshal-ilgen
component in all .NET 7 RC1+ builds so that our existing DllImport
declarations continue to work.

Update @(_MonoComponent) to add marshal-ilgen.

In order to facilitate future testing, allow the marshal-ilgen
component to be excluded if the
$(_AndroidExcludeMarshalIlgenComponent) property is True.

Fixes: dotnet#7249

Context: dotnet/runtime#71203
Context: dotnet/runtime#60639
Context: dotnet/runtime#61685

Mono introduced a new `marshal-ilgen` component in
dotnet/runtime@de32c446 which needs to be used when
*non-blittable type* is required.

`string` marshaling is a form of non-blittable marshaling.

Eventually the idea is that assemblies should migrate to use the
[`DllImport Generator`][0] for non-blittable marshaling purposes,
then [`[assembly:DisableRuntimeMarshallingAttribute]`][1] can be
applied to the assembly, and -- if no assemblies in an Android app
require non-blittable marshaling -- then the `marshal-ilgen`
component can be omitted from the `.apk`, reducing app size.

That's a fair number of `if`s; this won't be happening soon.

In the meantime, we need to start including the `marshal-ilgen`
component in all .NET 7 RC1+ builds so that our existing `DllImport`
declarations continue to work.

Update `@(_MonoComponent)` to add `marshal-ilgen`.

In order to facilitate future testing, allow the `marshal-ilgen`
component to be *excluded* if the
`$(_AndroidExcludeMarshalIlgenComponent)` property is True.

[0]: https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator
[1]: dotnet/runtime#60639
@jonathanpeppers
Copy link
Member

Was this a cherry-pick of 303f41f?

@jonpryor
Copy link
Member Author

@jonathanpeppers asked:

Was this a cherry-pick of 303f41f?

I did not know that commit existed, so no.

I hadn't appropriately read Issue #7249, and did not notice the mention of commit 303f41f.

Should we merge this separately? Or leave it as part of #7255?

@jonathanpeppers
Copy link
Member

@jonpryor we can merge this separately, you might just incorporate the crash in the commit message from 303f41f?

I think the name of the MSBuild property you chose seems better than mine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

marshal-ilgen component must be included
3 participants