Skip to content

[RGen] Allow to generate a 'new' syntax using a known type. #23028

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 3 commits into from
Jun 12, 2025

Conversation

mandel-macaque
Copy link
Member

There are some types that are known and we want to create a new instance for using new rather than GetINativeObject/GetNSObject. Add a new
overload of the New method that allows to pass directly a TypeSyntax.

mandel-macaque and others added 2 commits June 11, 2025 16:27
There are some types that are known and we want to create a new instance
for using new rather than GetINativeObject/GetNSObject. Add a new
  overload of the New method that allows to pass directly a TypeSyntax.
@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 #b5ab1b8] Build passed (Build packages) ✅

Pipeline on Agent
Hash: b5ab1b8ef03ab7087910f8310b9ee380fc28a946 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: b5ab1b8ef03ab7087910f8310b9ee380fc28a946 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@mandel-macaque mandel-macaque requested a review from Copilot June 11, 2025 21:23
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 adds support for directly generating object creation syntax from a known TypeSyntax rather than TypeInfo, introduces two new known type entries, and covers this new path with a unit test.

  • Introduce a New(TypeSyntax, ImmutableArray<ArgumentSyntax>) overload in BindingSyntaxFactory.Runtime.
  • Add AudioBuffers and CMSampleBuffer to BindingSyntaxFactory.KnownTypes.
  • Add NewTestsKnownType to verify the new overload with a known type.

Reviewed Changes

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

File Description
tests/.../BindingSyntaxFactoryRuntimeTests.cs Added a test (NewTestsKnownType) for generating new from a known type
src/.../BindingSyntaxFactory.Runtime.cs Added New overload accepting TypeSyntax and updated docs
src/.../BindingSyntaxFactory.KnownTypes.cs Defined AudioBuffers and CMSampleBuffer as reusable TypeSyntax
Comments suppressed due to low confidence (3)

src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Runtime.cs:500

  • The <param name="type"> description refers to TypeInfo but this overload accepts a TypeSyntax. Please update the description to reflect that it represents the syntax node for the type.
/// <param name="type">The information of the type of object to be created.</param>

tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryRuntimeTests.cs:525

  • [nitpick] The test name NewTestsKnownType deviates from the existing NewTests naming convention. Consider renaming it to NewTests_KnownType or similar to match the suite.
void NewTestsKnownType ()

src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.KnownTypes.cs:161

  • You added a CMSampleBuffer known type but didn't include a corresponding unit test. Consider adding a test similar to NewTestsKnownType to cover this new entry.
/// <summary>

@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: b5ab1b8ef03ab7087910f8310b9ee380fc28a946 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: b5ab1b8ef03ab7087910f8310b9ee380fc28a946 [PR build]

@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 #b5ab1b8] Tests on macOS X64 - Mac Sonoma (14) passed 💻

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

Pipeline on Agent
Hash: b5ab1b8ef03ab7087910f8310b9ee380fc28a946 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: b5ab1b8ef03ab7087910f8310b9ee380fc28a946 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: b5ab1b8ef03ab7087910f8310b9ee380fc28a946 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: b5ab1b8ef03ab7087910f8310b9ee380fc28a946 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #7747cec] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 115 tests passed 🎉

Tests counts

✅ 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 (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
✅ windows: All 3 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: 7747ceca6c0c0d898664bb47a4cb661bf285f85e [PR build]

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mandel-macaque mandel-macaque merged commit a6fbf55 into main Jun 12, 2025
5 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/allow-new-with-typesyntax branch June 12, 2025 15:28
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