Skip to content

Conversation

davidnguyen-tech
Copy link
Member

@davidnguyen-tech davidnguyen-tech commented Jul 23, 2025

Description

In this PR we add support for ALL runtime configuration options for the CoreCLR Android test host by doing the following:

  • Parse runtime config from runtimeconfig.json.
  • Apply the config: set AppContext keys/values when rendering the monodroid-coreclr.c template.

Why it works

  • According to docs, all runtime config settings are generated into a [appname].runtimeconfig.json file when building the app
  • We assume that the .json generation works properly

Changes

  • Add placeholders in monodroid-coreclr.c template
  • In ApkBuilder.cs, when rendering the monodroid-coreclr.c template, we parse runtimeconfig.json and apply it by replacing the template placeholders to set actual AppContext keys and values
  • Remove setting env variables for runtime switches in AndroidBuild.props (became redundant)
  • Enable newly non-failing tests

Newly non-failing tests with execution results

  • System.Runtime.InvariantTimezone.Tests.csproj
    • Tests run: 36 Passed: 35 Inconclusive: 0 Failed: 0 Ignored: 0 Skipped: 1
  • System.Diagnostics.DiagnosticSource.Switches.Tests.csproj
    • Tests run: 4 Passed: 4 Inconclusive: 0 Failed: 0 Ignored: 0 Skipped: 0
  • System.IO.FileSystem.DisabledFileLocking.Tests.csproj
    • Tests run: 1591 Passed: 1536 Inconclusive: 0 Failed: 0 Ignored: 36 Skipped: 19
  • System.Text.Encoding.Tests.csproj
    • Tests run: 14698 Passed: 14695 Inconclusive: 0 Failed: 0 Ignored: 3 Skipped: 0

Related issues

@Copilot Copilot AI review requested due to automatic review settings July 23, 2025 13:08
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 23, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements runtime configuration support for the Android CoreCLR test host by parsing runtimeconfig.json files and applying the configuration through AppContext keys/values. The change replaces the previous approach of setting environment variables with a more robust template-based system that dynamically generates C code with the appropriate runtime configuration.

Key changes:

  • Replaced hardcoded AppContext properties with template placeholders in the CoreCLR C template
  • Added JSON parsing logic to extract runtime configuration properties and generate corresponding C code
  • Removed redundant environment variable settings from the Android build configuration
  • Re-enabled previously failing tests that now pass with proper runtime configuration support

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tasks/AndroidAppBuilder/Templates/monodroid-coreclr.c Converted hardcoded AppContext arrays to template placeholders for dynamic generation
src/tasks/AndroidAppBuilder/ApkBuilder.cs Added JSON parsing and template replacement logic to process runtimeconfig.json
src/mono/msbuild/android/build/AndroidBuild.props Removed obsolete environment variable definitions for runtime switches
src/libraries/tests.proj Re-enabled three test projects that now pass with proper runtime config support
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/DisabledFileLockingTests/DisabledFileLockingSwitchTests.cs Removed ActiveIssue attribute from a test that now works

@davidnguyen-tech davidnguyen-tech added area-Infrastructure-coreclr os-android and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jul 23, 2025
Copy link
Contributor

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

@davidnguyen-tech
Copy link
Member Author

/azp run runtime-android,runtime-androidemulator

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@kotlarmilos kotlarmilos left a comment

Choose a reason for hiding this comment

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

Thanks!

@davidnguyen-tech
Copy link
Member Author

/azp run runtime-android,runtime-androidemulator

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@davidnguyen-tech
Copy link
Member Author

/azp run runtime-android,runtime-androidemulator

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@davidnguyen-tech
Copy link
Member Author

/azp run runtime-android,runtime-androidemulator

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@davidnguyen-tech davidnguyen-tech enabled auto-merge (squash) July 25, 2025 15:12
@davidnguyen-tech davidnguyen-tech merged commit c87888a into dotnet:main Jul 28, 2025
167 of 170 checks passed
@davidnguyen-tech davidnguyen-tech deleted the issue-117919 branch August 13, 2025 11:23
@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Android][CoreCLR] Add runtimeconfig.json support for test host [Android] System.Runtime.InvariantTimezone.Tests.csproj fails on CoreCLR Android

4 participants