Skip to content

[RGen] Update the emitters to generate the trampoline static class. #22926

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 29, 2025

Conversation

mandel-macaque
Copy link
Member

This is the initial implementation of the trampoline emitter. It just focuses on the delegate and the static class. A generic class has been added but more tests will come per framework, we simply want to make the diff manageable for the team, so we have not added all the tests in a single PR.

This is the initial implementation of the trampoline emitter. It just
focuses on the delegate and the static class. A generic class has been
added but more tests will come per framework, we simply want to make the
diff manageable for the team, so we have not added all the tests in a
single PR.
@mandel-macaque mandel-macaque requested a review from Copilot May 28, 2025 15:40
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

This PR introduces the initial implementation of the trampoline emitter – generating internal delegate declarations and companion static classes to bridge native block callbacks – and updates the test suite and expected outputs accordingly.

  • Implements TryEmitInternalDelegate and TryEmitStaticClass in TrampolineEmitter to emit delegate types and static bridge classes.
  • Adds BlockLiteral to BindingSyntaxFactory, updates documentation, and adjusts test harness to locate generated trampolines under ObjCRuntime.
  • Extends generator tests with new property-based delegate scenarios and expands expected trampoline code files.

Reviewed Changes

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

Show a summary per file
File Description
tests/rgen/Microsoft.Macios.Generator.Tests/Microsoft.Macios.Generator.Tests.csproj Excludes and includes Trampolines\*.cs patterns for compile and None
tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/TrampolinePropertyTests.cs Adds various delegate-backed properties for trampoline testing
tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/ExpectedTrampolinePropertyTestsTrampolines.cs Updates expected static classes and delegates for all new trampolines
tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/ExpectedTrampolinePropertyTests.cs Updates expected binding code for new trampoline-backed properties
tests/rgen/Microsoft.Macios.Generator.Tests/BaseGeneratorTestClass.cs Adjusts the path filter to ObjCRuntime/Trampolines.g.cs
src/rgen/Microsoft.Macios.Generator/Emitters/TrampolineEmitter.cs Implements the core emitter logic for delegates and static trampoline classes
src/rgen/Microsoft.Macios.Generator/Emitters/Documentation.cs Adds TrampolineStaticClass helper to format doc comments
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.KnownTypes.cs Registers ObjCRuntime.BlockLiteral in known types
Comments suppressed due to low confidence (1)

tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/TrampolinePropertyTests.cs:40

  • There is an extraneous closing bracket ] at the end of this property declaration. Remove the extra ] to fix the syntax error.
public partial CIKernelRoiCallback KernelRoiCallback { get; set; }]


// Property using AVAssetImageGenerator.AsynchronouslyForTimeCompletionHandler
[Export<Property> ("imageGeneratorCompletionHandler", ArgumentSemantic.Copy)]
public partial AVAssetImageGenerateAsynchronouslyForTimeCompletionHandler ImageGeneratorCompletionHandler { get; set; }
Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

This property duplicates ImageGeneratorCompletionHandler and uses a mismatched delegate type name. Remove or consolidate the duplicate definition, and ensure the delegate type matches the intended AVAssetImageGenerator.AsynchronouslyForTimeCompletionHandler.

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

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

On purpose.

Comment on lines +350 to +370
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
public partial global::CoreImage.CIKernelRoiCallback KernelRoiCallback
{
get
{
global::CoreImage.CIKernelRoiCallback ret;
if (IsDirectBinding) {
ret = global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("kernelRoiCallback"));
} else {
ret = global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, global::ObjCRuntime.Selector.GetHandle ("kernelRoiCallback"));
}
GC.KeepAlive (this);
return ret;
}

set
{
throw new NotImplementedException();
}
}

This comment was marked as resolved.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #da210a1] Build passed (Build packages) ✅

Pipeline on Agent
Hash: da210a12c577adc7573a54fdd693e2b8ec71bd4a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #da210a1] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: da210a12c577adc7573a54fdd693e2b8ec71bd4a [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: da210a12c577adc7573a54fdd693e2b8ec71bd4a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #da210a1] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: da210a12c577adc7573a54fdd693e2b8ec71bd4a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #da210a1] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: da210a12c577adc7573a54fdd693e2b8ec71bd4a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: da210a12c577adc7573a54fdd693e2b8ec71bd4a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: da210a12c577adc7573a54fdd693e2b8ec71bd4a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: da210a12c577adc7573a54fdd693e2b8ec71bd4a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #da210a1] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 1 tests failed, 115 tests passed.

Failures

❌ dotnettests tests (Multiple platforms)

1 tests failed, 0 tests passed.
  • DotNet tests: Failed (Execution failed with exit code 1)

Html Report (VSDrops) Download

❌ windows tests

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

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 (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 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 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: da210a12c577adc7573a54fdd693e2b8ec71bd4a [PR build]

@mandel-macaque
Copy link
Member Author

Failing tests are unrelated to the code changes.

@mandel-macaque mandel-macaque merged commit d67db17 into main May 29, 2025
40 of 44 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/trampoline-static-class-emitter branch May 29, 2025 13:13
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