Skip to content

fix(android): replace non-compiling JNI constructor with [DynamicDependency] - #322

Merged
winnerspiros merged 2 commits into
masterfrom
copilot/fix-last-build-failure-79f63928-1be3-45ca-8069-e9060f122ff1
May 9, 2026
Merged

fix(android): replace non-compiling JNI constructor with [DynamicDependency]#322
winnerspiros merged 2 commits into
masterfrom
copilot/fix-last-build-failure-79f63928-1be3-45ca-8069-e9060f122ff1

Conversation

Copilot AI commented May 9, 2026

Copy link
Copy Markdown
  • Investigate CI failure: CS0592 - [DynamicDependency] not valid on class declarations, only on constructor/method/field
  • Move [DynamicDependency] attribute from class declaration to the parameterless constructor

…dency attribute

Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/0a6c506c-c593-40ea-8768-bf1f2f842808

Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
@gitar-bot

gitar-bot Bot commented May 9, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

…id on class declarations)

Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/171d847e-6009-4492-b2b0-9c391c67af5d

Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
Copilot AI requested a review from winnerspiros May 9, 2026 08:08
@winnerspiros
winnerspiros marked this pull request as ready for review May 9, 2026 08:33
Copilot AI review requested due to automatic review settings May 9, 2026 08:33
@winnerspiros
winnerspiros merged commit 8242283 into master May 9, 2026
22 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes an Android build/CI failure by relocating the [DynamicDependency] attribute to a valid target, while keeping the linker-trimming protection for JNI activation paths in place.

Changes:

  • Add System.Diagnostics.CodeAnalysis import and apply [DynamicDependency] to OsuGameActivity() (constructor) instead of the class.
  • Remove the previously-added explicit JNI activation constructor that didn’t compile.
  • Update Linker.xml documentation to describe the new “additional defence” approach.

Reviewed changes

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

File Description
osu.Android/OsuGameActivity.cs Moves [DynamicDependency] onto the parameterless constructor and removes the non-compiling JNI constructor attempt.
osu.Android/Linker.xml Updates the explanatory comment describing the trimming/linker defence strategy for JNI constructors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +92 to +96
// Preserve AndroidGameActivity's (IntPtr, JniHandleOwnership) JNI-activation constructor.
// The [assembly: preserve="all"] descriptor for osu.Framework.Android in Linker.xml is deferred
// (IL2007) because the framework assembly is not yet in ILLink's search path at descriptor time.
// Placing [DynamicDependency] on this constructor (which lives in osu.Android — always resolvable)
// roots the AndroidGameActivity constructor in ILLink's walk before it can be trimmed away.
// Placing [DynamicDependency] on this constructor (which lives in osu.Android — always resolvable)
// roots the AndroidGameActivity constructor in ILLink's walk before it can be trimmed away.
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors,
"osu.Framework.Android.AndroidGameActivity", "osu.Framework.Android")]
Comment thread osu.Android/Linker.xml
Comment on lines +108 to +116
attribute that explicitly roots AndroidGameActivity's constructors from the
osu.Android assembly. Because osu.Android is unambiguously preserve="all" and is
always resolvable at descriptor-processing time, ILLink processes this root
reference before it can trim the JNI-activation constructor, regardless of whether
the IL2007-deferred rule for osu.Framework.Android is honoured. This supersedes
the v2026.508.227 approach (explicit OsuGameActivity(IntPtr, JniHandleOwnership)
constructor) which did not compile because AndroidGameActivity does not expose an
explicit (IntPtr, JniHandleOwnership) constructor — only its SDLActivity grandparent
does, and C# base() invocations resolve only against the direct parent class. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants