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

[One .NET] *.runtimeconfig.json support #6009

Merged
merged 7 commits into from
Jun 14, 2021
Merged

[One .NET] *.runtimeconfig.json support #6009

merged 7 commits into from
Jun 14, 2021

Conversation

jonathanpeppers
Copy link
Member

WIP, I implemented the MSBuild side partially.

@@ -150,27 +151,32 @@ static ApplicationConfig ReadApplicationConfig (string envFile)
ret.jni_add_native_method_registration_attribute_present = ConvertFieldToBool ("jni_add_native_method_registration_attribute_present", envFile, i, field [1]);
break;

case 7: // bound_stream_io_exception_type: byte / .byte
case 7:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions:

  1. Elsewhere, there's a comment on the case line saying what field it's for. It's missing here. Should there be a comment?
  2. Why insert as "field [Xamarin.Android.Build.Tasks] Added missing files from commit 59ec488b #7" instead of appending as "field [README] Expand the Build Requirements section. #12"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanpeppers
Copy link
Member Author

The new tests here look OK:
image

It looks like something is going on with some build machines, where they have a newer Mono:

Could not load file or assembly 'Microsoft.NET.StringTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

@jonathanpeppers
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jonpryor
Copy link
Member

jonpryor commented Jun 14, 2021

Commit message:

Context: https://github.com/dotnet/runtime/blob/d95bfea59ed7d19e9b1db096c9d332005989296b/docs/design/mono/mobile-runtimeconfig-json.md

.NET allows including a [`runtimeconfig.json`][0] file in an
application, which can be used to control runtime configuration
options, provide "backing data" to [`AppContext.GetData()`][1],
control configuration values, and more.

Update the Xamarin.Android-for-.NET 6 build process to call the new
[`<RuntimeConfigParser/>` task][2], which will process the
`runtimeconfig.json` files into an efficient binary blob, which will
be added to the `.apk` as `assemblies/rc.bin`.

During process startup, `assemblies/rc.bin` will be proved to
`monovm_runtimeconfig_initialize()`, which will parse `rc.bin`.

Certain `runtimeconfig.json` properties are *reserved*: if they're
specified within `runtimeconfig.json`, then the
`<RuntimeConfigParser/>` task will throw an `ArgumentException`, and
the build will fail.  The reserved properties are controlled by the
`@(_RuntimeConfigReservedProperties)` item group, and are reserved
because the Xamarin.Android runtime needs to control the value of
these properties for proper app execution, e.g. `PINVOKE_OVERRIDE`
(cf84e1b9, 0cd890bd).

Co-authored-by: Marek Habersack <[email protected]>

[0]: https://docs.microsoft.com/en-us/dotnet/core/run-time-config/#runtimeconfigjson
[1]: https://docs.microsoft.com/en-us/dotnet/api/system.appcontext.getdata?view=net-5.0
[2]: https://github.com/dotnet/runtime/blob/01b7e73cd378145264a7cb7a09365b41ed42b240/src/tasks/RuntimeConfigParser/RuntimeConfigParser.cs

@jonpryor jonpryor merged commit a022f5d into main Jun 14, 2021
@jonpryor jonpryor deleted the runtimeconfig.json branch June 14, 2021 20:43
grendello pushed a commit to grendello/xamarin-android that referenced this pull request Jun 16, 2021
Context: https://github.com/dotnet/runtime/blob/d95bfea59ed7d19e9b1db096c9d332005989296b/docs/design/mono/mobile-runtimeconfig-json.md

.NET allows including a [`runtimeconfig.json`][0] file in an
application, which can be used to control runtime configuration
options, provide "backing data" to [`AppContext.GetData()`][1],
control configuration values, and more.

Update the Xamarin.Android-for-.NET 6 build process to call the new
[`<RuntimeConfigParser/>` task][2], which will process the
`runtimeconfig.json` files into an efficient binary blob, which will
be added to the `.apk` as `assemblies/rc.bin`.

During process startup, `assemblies/rc.bin` will be proved to
`monovm_runtimeconfig_initialize()`, which will parse `rc.bin`.

Certain `runtimeconfig.json` properties are *reserved*: if they're
specified within `runtimeconfig.json`, then the
`<RuntimeConfigParser/>` task will throw an `ArgumentException`, and
the build will fail.  The reserved properties are controlled by the
`@(_RuntimeConfigReservedProperties)` item group, and are reserved
because the Xamarin.Android runtime needs to control the value of
these properties for proper app execution, e.g. `PINVOKE_OVERRIDE`
(cf84e1b, 0cd890b).

Co-authored-by: Marek Habersack <[email protected]>

[0]: https://docs.microsoft.com/en-us/dotnet/core/run-time-config/#runtimeconfigjson
[1]: https://docs.microsoft.com/en-us/dotnet/api/system.appcontext.getdata?view=net-5.0
[2]: https://github.com/dotnet/runtime/blob/01b7e73cd378145264a7cb7a09365b41ed42b240/src/tasks/RuntimeConfigParser/RuntimeConfigParser.cs
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 2024
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.

4 participants