Skip to content

[native] Remove unused C++ helpers - #13341

Merged
simonrozsival merged 1 commit into
mainfrom
simonrozsival-getifaddrs-usage
Oct 31, 2026
Merged

simonrozsival merged 1 commit into
mainfrom
simonrozsival-getifaddrs-usage

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Context: #10385

Investigating whether xamarin_getifaddrs.cc was still needed showed that it had already been removed along with the obsolete System.AndroidPlatform hooks. A follow-up audit found other native code which has outlived its callers.

strings.hh is no longer included anywhere, and its custom string types have no remaining consumers. HostUtil::get_class_from_runtime_field() is still compiled, but both callers use the equivalent RuntimeUtil implementation. The APK mapping helpers and descriptor-based DsoLoader::load() overload are also unused: assembly-store discovery now uses dlopen()/dlsym(), and current DSO loading uses paths rather than APK file descriptors and offsets.

Remove these implementations and their build/include references, along with the unused filesystem helpers, search overloads, JNI wrapper accessor, and C++ utility templates. Keep the active RuntimeUtil, path-based DSO loader, and stateless Search::lower_bound() unchanged. Replace the removed utilities' <memory> include with <functional> for the remaining std::invoke usage.

No exported entry points are removed, and no runtime behavior change is intended.

Validation

Local SDK/native builds on macOS:

  • make prepare — passed.
  • make all — initially blocked by the missing Android CMake 4.1.2 executable. Retrying with -p:AndroidCmakeVersionPath=3.30.3 exposed the old Ninja path in the generated presets; regenerated the ignored local src/native/CMakePresets.json to pick up the override. No toolchain configuration changes are committed.
  • ./dotnet-local.sh build src/native/native-clr.csproj --no-restore -p:AndroidCmakeVersionPath=3.30.3 -v minimal — passed; native Debug/Release for armeabi-v7a, arm64-v8a, and x86_64.
  • ./dotnet-local.sh build src/native/native-nativeaot.csproj --no-restore -p:AndroidCmakeVersionPath=3.30.3 -v minimal — passed; the same native configurations and ABIs.
  • make leeroy MSBUILD_ARGS='-p:AndroidCmakeVersionPath=3.30.3' — passed, including extra API levels and local workload configuration.
  • ./dotnet-local.sh test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --no-build --filter 'FullyQualifiedName~NativeAotSystemPropertiesTests' -v minimal — passed, 18 tests.

CoreCLR Debug on the ARM64 emulator — build/install passed; 28 JavaList tests passed, none failed or skipped:

./dotnet-local.sh build -t:Install -c Debug -p:RuntimeIdentifier=android-arm64 -p:AndroidRuntime=CoreCLR -p:IncludeCategories=JavaList tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -v minimal
(
  cd tests/Mono.Android-Tests/Mono.Android-Tests
  ../../../dotnet-local.sh test Mono.Android.NET-Tests.csproj --no-build -c Debug -p:RuntimeIdentifier=android-arm64 -p:AndroidRuntime=CoreCLR -p:IncludeCategories=JavaList --report-trx --results-directory ../../../bin/TestDebug/TestResults/dead-code-coreclr
)

NativeAOT Release on the ARM64 emulator — build/install passed; 28 JavaList tests passed, none failed or skipped:

./dotnet-local.sh build -t:Install -c Release -p:RuntimeIdentifier=android-arm64 -p:PublishAot=true -p:IncludeCategories=JavaList tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -v minimal
(
  cd tests/Mono.Android-Tests/Mono.Android-Tests
  ../../../dotnet-local.sh test Mono.Android.NET-Tests.csproj --no-build -c Release -p:RuntimeIdentifier=android-arm64 -p:PublishAot=true -p:IncludeCategories=JavaList --report-trx --results-directory ../../../bin/TestRelease/TestResults/dead-code-nativeaot
)

Native builds emitted integer-conversion warnings, and the NativeAOT test build emitted trim/AOT-analysis warnings; all completed without errors. Device coverage was limited to ARM64 and the JavaList category, not the full runtime suite.

Remove the unreferenced custom string implementation and HostUtil helper,
along with unused mapping, DSO loading, filesystem, search, JNI wrapper,
and C++ utility helpers.  Remove obsolete build and include references.

Keep the active RuntimeUtil, path-based DSO loading, and stateless
lower_bound implementations unchanged.  Include <functional> directly for
the remaining std::invoke usage instead of relying on <memory>.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the removal of unused native runtime helpers.

No open issues 🎉

What changed in this PR

Removes unused C++ helpers from the .NET for Android native runtime, reducing maintenance overhead without intentionally changing runtime behavior or exported entry points.

Changes:

  • Deletes the custom string implementation, duplicate HostUtil, and unused filesystem, APK mapping, search, and JNI helpers.
  • Removes obsolete CMake and include references; adds <functional> directly for std::invoke.
  • Preserves active RuntimeUtil, path-based DSO loading, and stateless Search::lower_bound.
File Description
src/​native/​common/​include/​shared/​cpp-util.hh Removes unused utilities and directly includes <functional>.
src/​native/​common/​include/​runtime-base/​strings.hh Deletes the unused custom string implementation.
src/​native/​common/​include/​runtime-base/​search.hh Removes unused search overloads.
src/​native/​common/​include/​runtime-base/​jni-wrappers.hh Removes unused hasValue().
src/​native/​common/​include/​runtime-base/​dso-loader.hh Removes descriptor-based DSO loading.
src/​native/​clr/​runtime-base/​util.cc Removes unused filesystem helper implementations.
src/​native/​clr/​include/​runtime-base/​util.hh Removes unused declarations, mapping helpers, and supporting state.
src/​native/​clr/​include/​host/​host-util.hh Deletes the unused HostUtil declaration.
src/​native/​clr/​host/​host.cc Removes the obsolete HostUtil include.
src/​native/​clr/​host/​host-util.cc Deletes the unused HostUtil implementation.
src/​native/​clr/​host/​CMakeLists.txt Removes host-util.cc from the build sources.

Review effort: Balanced

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Oct 30, 2026
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13341

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ LGTM — no actionable code findings

Findings: 0 errors, 0 warnings, 0 suggestions.

Reviewed all 11 changed files, including the complete deleted implementations, and checked remaining callers and build references. The removed helpers have no remaining consumers in the checked-out tree. The active RuntimeUtil implementation, path-based DSO loading, and stateless Search::lower_bound() remain unchanged. Removing host-util.cc from CMake alongside its implementation is consistent, and replacing <memory> with <functional> supplies the direct dependency for the retained std::invoke usage. This supports the stated no-behavior-change intent.

CI: All 42 GitHub checks for the PR head report success, including the aggregate dotnet-android check for Azure build 1655983. Direct Azure build/timeline verification could not be completed: the build query required authentication, and the timeline query failed during CLI initialization. Pipeline internals and non-gating test results were therefore not independently verified. No local builds or device tests were run as part of this review.

No inline comments were added because this mechanical dead-code cleanup revealed no actionable concern on the changed lines.

Generated by Android PR Reviewer for #13341 · copilot · gpt61 · 26.2 AIC · ⌖ 4.25 AIC · ⊞ 20K
Comment /review to run again

@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto review

@simonrozsival
simonrozsival enabled auto-merge (squash) October 31, 2026 11:02

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the complete native-helper removal, retained JNI/search/DSO consumers, native build routing, exports and affected target integration. No blocking issues found. This was a read-only source review.

@simonrozsival
simonrozsival merged commit d9e6311 into main Oct 31, 2026
42 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-getifaddrs-usage branch October 31, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants