KEMBAR78
[RGen] Add factory method to return a smart enum value from a NSString. by mandel-macaque · Pull Request #23027 · dotnet/macios · GitHub
Skip to content

Conversation

@mandel-macaque
Copy link
Member

Add a factory method that will return the expression needed to get a SmartEnum from a NSString value.

Add a factory method that will return the expression needed to get a
SmartEnum from a NSString value.
@mandel-macaque mandel-macaque requested a review from Copilot June 11, 2025 16:42
Copy link
Contributor

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

The PR introduces a new factory method to generate syntax for converting an NSString into a SmartEnum value, along with a corresponding unit test.

  • Added GetSmartEnunFromNSString in BindingSyntaxFactory.ObjCRuntime.cs to emit an invocation of the SmartEnum extension’s GetValue method.
  • Documented the new method with XML comments (including an exception tag).
  • Added GetSmartEnunFromNSStringTest to verify the generated syntax string.

Reviewed Changes

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

File Description
tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryObjCRuntimeTests.cs Added a test verifying the syntax emitted by the new factory method.
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.ObjCRuntime.cs Implemented GetSmartEnunFromNSString and its XML documentation.
Comments suppressed due to low confidence (3)

src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.ObjCRuntime.cs:654

  • [nitpick] There's a typo in the method name: GetSmartEnunFromNSString should be GetSmartEnumFromNSString to reflect 'Enum' correctly.
internal static InvocationExpressionSyntax GetSmartEnunFromNSString (in TypeInfo typeInfo, ArgumentSyntax argument)

tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryObjCRuntimeTests.cs:972

  • [nitpick] The test name repeats the typo from the factory method. Consider renaming to GetSmartEnumFromNSStringTest for consistency.
void GetSmartEnunFromNSStringTest ()

src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.ObjCRuntime.cs:653

  • The documentation mentions an ArgumentException but the method does not validate typeInfo or throw. Either implement the validation or remove/update the exception tag.
/// <exception cref="ArgumentException">Thrown if <paramref name="typeInfo"/> is not a smart enum.</exception>

@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

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

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

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 #74cc81c] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 74cc81c9ab236c143913fef57fccac8e45b62bad [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #74cc81c] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 74cc81c9ab236c143913fef57fccac8e45b62bad [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 74cc81c9ab236c143913fef57fccac8e45b62bad [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 74cc81c9ab236c143913fef57fccac8e45b62bad [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 74cc81c9ab236c143913fef57fccac8e45b62bad [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 74cc81c9ab236c143913fef57fccac8e45b62bad [PR build]

@mandel-macaque mandel-macaque changed the title [RGen] Add factory method to return a smart enum value form a NSString. [RGen] Add factory method to return a smart enum value from a NSString. Jun 12, 2025
@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #74cc81c] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 0 tests failed, 120 tests passed.

Failures

❌ 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 (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 6 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 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: 74cc81c9ab236c143913fef57fccac8e45b62bad [PR build]

@mandel-macaque
Copy link
Member Author

Windows tests are unrelated to the code changes.

@mandel-macaque mandel-macaque merged commit 510a0d8 into main Jun 12, 2025
42 of 44 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/smart-enum-from-string branch June 12, 2025 18:45
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