[CoreCLR] Analysis shows no unused native code to remove #10260
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR provides a comprehensive analysis of the CoreCLR native code in
src/native/clr/to identify unused functions as requested in issue #10259.Analysis Summary
After thorough examination of all header files (
.hh) and source files (.cc) in the CoreCLR directory, no unused functions were found that can be safely removed.Detailed Findings
P/Invoke Functions (20 functions)
All functions declared in
RuntimeNativeMethods.csare called by managed code and must be preserved:monodroid_free,_monodroid_gref_get,_monodroid_max_gref_get_monodroid_gref_log*,_monodroid_lref_log*,_monodroid_weak_gref_*clr_typemap_*,monodroid_TypeManager_get_java_class_name_monodroid_detect_cpu_and_architecture,_monodroid_getifaddrs,_monodroid_timezone_get_default_idmonodroid_log,monodroid_timing_*,monodroid_unhandled_exceptionInternal Helper Functions
All static functions in source files are used within their respective implementation units:
OSBridgeclass methods: Used by host initialization and P/Invoke wrappersxamarin_getifaddrs.cc: Used internally by_monodroid_getifaddrscpu-arch-detect.cc: Used by architecture detection APImonodroid-dl.hh: Used by P/Invoke override systemAPI Compatibility Functions
Some functions have disabled implementations but are kept for API compatibility:
_monodroid_gref_log_delete: Temporarily disabled due to test crashes, but still exported_monodroid_gc_wait_for_bridge_processing: Placeholder for future GC bridge implementationDebug Functions
Functions under
#if DEBUGblocks are conditionally compiled for debugging purposes and should be preserved.Conclusion
The CoreCLR native codebase is well-maintained with no dead code. All functions serve specific purposes:
Removing any functions would either break functionality or violate API contracts.
Fixes #10259.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.