Skip to content

[RGen] Factory method for the method signature of Invoke for the NI* classes. #22950

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 30, 2025

Conversation

mandel-macaque
Copy link
Member

Create the signature based on the information from the delegate.

…classes.

Create the signature based on the information from the delegate.
@mandel-macaque mandel-macaque requested a review from Copilot May 29, 2025 22:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new factory method to generate native trampoline invoke signatures from delegate metadata and verifies it with a comprehensive set of unit tests.

  • Introduce GetTrampolineNativeInvokeSignature in BindingSyntaxFactory.Trampoline.cs
  • Add TestDataGetTrampolineNativeInvokeSignature and corresponding theory test in BindingSyntaxFactoryTrampolineTests.cs

Reviewed Changes

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

File Description
tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryTrampolineTests.cs Add TestDataGetTrampolineNativeInvokeSignature data class and test
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Trampoline.cs Implement GetTrampolineNativeInvokeSignature with XML doc comments
Comments suppressed due to low confidence (2)

src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Trampoline.cs:872

  • [nitpick] The loop variable currentParameter could be shortened or made more descriptive (e.g., param or delegateParam) for brevity and clarity.
foreach (var currentParameter in delegateTypeInfo.Delegate!.Parameters) {

tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryTrampolineTests.cs:3310

  • All existing cases cover single-parameter delegates; consider adding one or more multi-parameter delegate scenarios to ensure the signature generation handles multiple parameters correctly.
class TestDataGetTrampolineNativeInvokeSignature : IEnumerable<object []> {

var modifiers = TokenList (
Token (SyntaxKind.UnsafeKeyword));
// the parameters are the exact same as the delegate parameters, we are not going to low level them
var parameterBucket = ImmutableArray.CreateBuilder<ParameterSyntax> (delegateTypeInfo.Delegate!.Parameters.Length);
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

[nitpick] The variable name parameterBucket is vague—consider renaming it to something like parametersBuilder or parameterListBuilder to clarify its purpose.

Suggested change
var parameterBucket = ImmutableArray.CreateBuilder<ParameterSyntax> (delegateTypeInfo.Delegate!.Parameters.Length);
var parametersBuilder = ImmutableArray.CreateBuilder<ParameterSyntax> (delegateTypeInfo.Delegate!.Parameters.Length);

Copilot uses AI. Check for mistakes.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #2c8ca3c] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 2c8ca3c619e4ab44c23687374d8eed207d13e695 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [CI Build #2c8ca3c] Tests on macOS X64 - Mac Sonoma (14) failed ❌

Failed tests are:

  • monotouch-test

Pipeline on Agent
Hash: 2c8ca3c619e4ab44c23687374d8eed207d13e695 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #2c8ca3c] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 2c8ca3c619e4ab44c23687374d8eed207d13e695 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #2c8ca3c] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 2c8ca3c619e4ab44c23687374d8eed207d13e695 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #2c8ca3c] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 2c8ca3c619e4ab44c23687374d8eed207d13e695 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: dfb3618f0579ec1bb6c9b947f0374445ab130b2a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #2c8ca3c] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 1 tests failed, 105 tests passed.

Failures

❌ monotouch tests (macOS)

🔥 Failed catastrophically on VSTS: test results - monotouch_macos (no summary found).

Html Report (VSDrops) Download

❌ windows tests

1 tests failed, 0 tests passed.

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 10 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 2c8ca3c619e4ab44c23687374d8eed207d13e695 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #36c163b] Build failed (Build packages) 🔥

Build failed for the job 'Build packages' (with job status 'Failed')

Pipeline on Agent
Hash: 36c163b4f2bf77dbbc464b7b6e354f0222a282c8 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [PR Build #36c163b] Build failed (Detect API changes) 🔥

Build failed for the job 'Detect API changes' (with job status 'Failed')

Pipeline on Agent
Hash: 36c163b4f2bf77dbbc464b7b6e354f0222a282c8 [PR build]

@mandel-macaque mandel-macaque merged commit 275e65e into main May 30, 2025
5 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/factory-native-invoke-declaration branch May 30, 2025 15:12
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.

4 participants