Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[XABT] Add comprehensive documentation to marshal methods code#10436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
grendello merged 4 commits intomainfromcopilot/fix-10435
Aug 22, 2025

Conversation

Copy link
Contributor

CopilotAI commentedAug 22, 2025
edited
Loading

The marshal methods system is a critical performance optimization for Android applications that generates native code bridges between .NET and Java/JNI. However, the code lacked comprehensive documentation, making it difficult for developers to understand, maintain, and extend.

Changes Made

This PR adds extensive XML documentation and inline comments to the core marshal methods pipeline, covering:

🔍Classification & Analysis Layer

  • MarshalMethodsClassifier.cs - The core engine that analyzes .NET methods and determines marshal method compatibility

    • Documents complex signature matching logic and [UnmanagedCallersOnly] validation
    • Explains standard handler pattern recognition and connector method resolution
    • Details blittable type checking and workaround generation strategies
  • MarshalMethodsHelpers.cs - Utility methods for blittable type analysis with references to Microsoft documentation

📊Collection & Management Layer

  • MarshalMethodsCollection.cs - Orchestrates assembly scanning and method classification

    • Documents integration with JavaInterop type scanner
    • Explains special case handling for framework methods like TypeManager.n_Activate
    • Details Kotlin method filtering and inheritance scenarios
  • MarshalMethodsState.cs &ManagedMarshalMethodsLookupInfo.cs - State management and runtime lookup infrastructure

⚙️Build Task Orchestration

  • RewriteMarshalMethods.cs - MSBuild task that rewrites assemblies to use marshal methods

    • Documents assembly modification workflow and pipeline state management
    • Explains managed lookup table generation and ordering dependencies
  • GenerateNativeMarshalMethodSources.cs - MSBuild task that generates LLVM IR code

    • Documents runtime-specific code generation (MonoVM vs CoreCLR)
    • Explains multi-ABI support and P/Invoke preservation

Documentation Features

Comprehensive Coverage: Every public, protected, internal, and private member now has detailed XML documentation explaining purpose, parameters, return values, and exceptions

Complex Algorithm Explanations: Inline documentation within methods explains intricate logic flows and decision points

System Architecture: Clear explanations of component interactions and build pipeline integration

Error Handling: Documentation of error conditions, logging patterns, and debugging aids

Example

Before:

boolIsStandardHandler(TypeDefinitiontopType,ConnectorInfoconnector,MethodDefinitionregisteredMethod,MethodDefinitionimplementedMethod,stringjniName,stringjniSignature,[NotNullWhen(true)]outMarshalMethodEntry?marshalMethodEntry){// 50+ lines of complex logic with minimal comments}

After:

/// <summary>/// Determines whether a method follows the "standard handler" pattern and can be converted to a marshal method./// The standard handler pattern involves a native callback method, a connector method that returns a delegate,/// and optionally a delegate backing field. This method performs extensive validation to ensure all/// components exist and are compatible./// </summary>/// <param name="topType">The top-level type that owns this method.</param>/// <param name="connector">Information about the connector method parsed from the [Register] attribute.</param>/// <param name="registeredMethod">The method that was registered with the [Register] attribute.</param>/// <param name="implementedMethod">The actual method implementation.</param>/// <param name="jniName">The JNI method name from the [Register] attribute.</param>/// <param name="jniSignature">The JNI method signature from the [Register] attribute.</param>/// <param name="marshalMethodEntry">/// When this method returns true, contains the marshal method entry for the convertible method./// When this method returns false, this parameter is null./// </param>/// <returns>true if the method follows the standard handler pattern; false otherwise.</returns>boolIsStandardHandler(TypeDefinitiontopType,ConnectorInfoconnector,MethodDefinitionregisteredMethod,MethodDefinitionimplementedMethod,stringjniName,stringjniSignature,[NotNullWhen(true)]outMarshalMethodEntry?marshalMethodEntry){// Method body with detailed inline comments explaining each validation step}

This documentation significantly improves the maintainability and approachability of the marshal methods system, making it easier for developers to understand this critical Android optimization.

Fixes#10435.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

CopilotAIand others added3 commitsAugust 22, 2025 08:28
…er utilitiesCo-authored-by: grendello <184788+grendello@users.noreply.github.com>
Co-authored-by: grendello <184788+grendello@users.noreply.github.com>
Co-authored-by: grendello <184788+grendello@users.noreply.github.com>
CopilotAI changed the title[WIP] [XABT] Marshal methods code is not documented well[XABT] Add comprehensive documentation to marshal methods codeAug 22, 2025
CopilotAI requested a review fromgrendelloAugust 22, 2025 08:37
Copilot finished work on behalf ofgrendelloAugust 22, 2025 08:37
@grendellogrendello marked this pull request as ready for reviewAugust 22, 2025 09:16
@grendellogrendelloenabled auto-merge (squash)August 22, 2025 09:18
@grendello
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendellogrendello merged commitb1eb50a intomainAug 22, 2025
60 checks passed
@grendellogrendello deleted the copilot/fix-10435 branchAugust 22, 2025 12:14
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsSep 22, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@jonathanpeppersjonathanpeppersAwaiting requested review from jonathanpeppersjonathanpeppers is a code owner

1 more reviewer

@grendellogrendellogrendello approved these changes

Reviewers whose approvals may not affect merge requirements

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[XABT] Marshal methods code is not documented well

2 participants

@grendello

[8]ページ先頭

©2009-2025 Movatter.jp