Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 19, 2025

The Android designer has been removed from Visual Studio, but we still had code in the product supporting it. This PR removes all the desktop-specific functionality as it's no longer needed.

Changes Made

C++ Changes

  • Removed isRunningOnDesktop field from JnienvInitializeArgs struct in managed-interface.hh
  • Removed assignments to this field in monodroid-glue.cc and host.cc

C# Changes

  • Removed IsRunningOnDesktop static field from JNIEnvInit class
  • Removed initialization code and __XA_PACKAGE_NAMING_POLICY__ environment variable handling
  • Inlined conditionals in TypeManager.cs assuming desktop is always false
  • Inlined conditionals in AndroidRuntime.cs removing desktop-specific type lookups
  • Removed desktop-specific error message from SyncContext.cs

Build Changes

  • Removed __XA_PACKAGE_NAMING_POLICY__ environment variable generation from MSBuild targets
  • Updated test to no longer expect this environment variable

Key Points

  • All if (IsRunningOnDesktop) statements have been inlined/deleted assuming the condition is always false
  • The $(AndroidPackageNamingPolicy) MSBuild property remains as-is since it's still used within the codebase
  • The __XA_PACKAGE_NAMING_POLICY__ environment variable has been removed as it was only used within desktop blocks
  • Minimal changes: 9 files modified, 37 lines removed, 4 lines changed

Verification

  • Zero references to IsRunningOnDesktop remain in C# source files
  • Zero references to isRunningOnDesktop remain in C++ source files
  • Zero references to __XA_PACKAGE_NAMING_POLICY__ remain in source files
  • The compile-time is_running_on_desktop constant in monodroid-glue-internal.hh is also removed

Fixes #10233.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Remove IsRunningOnDesktop for the Android designer Remove IsRunningOnDesktop for the Android designer Jun 19, 2025
Copilot AI requested a review from jonathanpeppers June 19, 2025 22:19
…est list initialization, and remove remaining is_running_on_desktop usage from C++ code

Co-authored-by: jonathanpeppers <[email protected]>
Copilot AI requested a review from jonathanpeppers June 19, 2025 22:53
@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 20, 2025 13:29
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

I still see more instances of is_running_on_desktop that can be removed:

static constexpr bool is_running_on_desktop = false;

Then there are several usages in src\native\mono\monodroid\monodroid-glue.cc.

Copy link
Contributor Author

Copilot AI commented Jun 20, 2025

I still see more instances of is_running_on_desktop that can be removed:
https://github.com/dotnet/android/blob/c25595518479edfa6f215a82f948ae7ba7780484/src/native/mono/monodroid/monodroid-glue-int...

Fixed in 6f46321. Removed the unused is_running_on_desktop constant from the MonodroidRuntime class. There are now zero references to is_running_on_desktop in any source files.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

@grendello should review the changes to native code.

FileAssert.Exists (environment);
var values = new List<string> {
$"__XA_PACKAGE_NAMING_POLICY__={packageNamingPolicy}"
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how this is relevant to the removal of desktop support


<Target Name="_GenerateEnvironmentFiles">
<ItemGroup>
<_GeneratedAndroidEnvironment Include="__XA_PACKAGE_NAMING_POLICY__=$(AndroidPackageNamingPolicy)" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how this is relevant to the removal of desktop support

Copy link
Member

Choose a reason for hiding this comment

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

This spot seemed to be the only place that actually reads the env var:

if (IsRunningOnDesktop) {
var packageNamingPolicy = Environment.GetEnvironmentVariable ("__XA_PACKAGE_NAMING_POLICY__");
if (Enum.TryParse (packageNamingPolicy, out PackageNamingPolicy pnp)) {
JavaNativeTypeManager.PackageNamingPolicy = pnp;
}
}

$(AndroidPackageNamingPolicy) is still left in, which embeds a value in libxamarin-app.so.

@grendello
Copy link
Contributor

The C++ changes look fine

@jonathanpeppers jonathanpeppers merged commit 3f45767 into main Jun 23, 2025
59 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-10233 branch June 23, 2025 13:18
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 2025
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.

Remove IsRunningOnDesktop for the Android designer

3 participants