KEMBAR78
[RGen] Fix bug where we converted a bool to a byte when we needed the opposite. by mandel-macaque · Pull Request #22891 · dotnet/macios · GitHub
Skip to content

Conversation

@mandel-macaque
Copy link
Member

The argument conversions is from low level to high level, therefore we need to look for a bool parameter and convert the byte to a bool. Not the otherway around.

mandel-macaque and others added 2 commits May 23, 2025 18:02
… opposite.

The argument conversions is from low level to high level, therefore we
need to look for a bool parameter and convert the byte to a bool. Not
the otherway around.
@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 #be1d187] Build passed (Build packages) ✅

Pipeline on Agent
Hash: be1d187f1284c31c671a45f589a0150d58958702 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: be1d187f1284c31c671a45f589a0150d58958702 [PR build]

@mandel-macaque mandel-macaque requested a review from Copilot May 23, 2025 22:35
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

This PR fixes a conversion bug by ensuring that boolean values are properly converted from a byte to a bool instead of the incorrect conversion from bool to byte.

  • Updated test expectation to compare "boolParameter != 0" instead of a ternary byte cast.
  • Refactored the trampoline emitter to invoke CastToBool.
  • Introduced a new helper method CastToBool in the ObjCRuntime emitter to perform the byte-to-bool conversion.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryTrampolineTests.cs Updated test assertion for bool conversion
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.Trampoline.cs Fixed conversion by using CastToBool instead of CastToByte
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.ObjCRuntime.cs Added new CastToBool helper function with documentation

Comment on lines +143 to +145
/// <param name="typeInfo">The type information of the variable.</param>
/// <returns>A binary expression that casts a byte to a bool.</returns>
internal static BinaryExpressionSyntax CastToBool (string variableName, in TypeInfo typeInfo)
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

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

The 'typeInfo' parameter is not used in the function body; consider either utilizing it for additional type-based logic or removing it to simplify the method signature.

Suggested change
/// <param name="typeInfo">The type information of the variable.</param>
/// <returns>A binary expression that casts a byte to a bool.</returns>
internal static BinaryExpressionSyntax CastToBool (string variableName, in TypeInfo typeInfo)
/// <returns>A binary expression that casts a byte to a bool.</returns>
internal static BinaryExpressionSyntax CastToBool (string variableName)

Copilot uses AI. Check for mistakes.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@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: be1d187f1284c31c671a45f589a0150d58958702 [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
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 942854b03d0b84e85cd927876f34da3c82332f00 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: be1d187f1284c31c671a45f589a0150d58958702 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: be1d187f1284c31c671a45f589a0150d58958702 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: be1d187f1284c31c671a45f589a0150d58958702 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: be1d187f1284c31c671a45f589a0150d58958702 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #be1d187] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 11 tests failed, 108 tests passed.

Failures

❌ monotouch tests (MacCatalyst)

11 tests failed, 0 tests passed.
  • monotouch-test/Mac Catalyst/Debug: Failed (Test run failed.
    Tests run: 3205 Passed: 3071 Inconclusive: 13 Failed: 1 Ignored: 133)
  • monotouch-test/Mac Catalyst/Debug (managed static registrar): Failed (Test run failed.
    Tests run: 3202 Passed: 3070 Inconclusive: 13 Failed: 1 Ignored: 131)
  • monotouch-test/Mac Catalyst/Debug (static registrar): Failed (Test run failed.
    Tests run: 3202 Passed: 3070 Inconclusive: 13 Failed: 1 Ignored: 131)
  • monotouch-test/Mac Catalyst/Release (managed static registrar): Failed (Test run failed.
    Tests run: 3202 Passed: 3064 Inconclusive: 13 Failed: 1 Ignored: 137)
  • monotouch-test/Mac Catalyst/Release (managed static registrar, all optimizations): Failed (Test run failed.
    Tests run: 3202 Passed: 3064 Inconclusive: 13 Failed: 1 Ignored: 137)
  • monotouch-test/Mac Catalyst/Release (NativeAOT): Failed (Test run failed.
    Tests run: 3202 Passed: 3054 Inconclusive: 13 Failed: 1 Ignored: 147)
  • monotouch-test/Mac Catalyst/Release (NativeAOT, x64): Failed (Test run failed.
    Tests run: 3202 Passed: 3054 Inconclusive: 13 Failed: 1 Ignored: 147)
  • monotouch-test/Mac Catalyst/Release (static registrar): Failed (Test run failed.
    Tests run: 3202 Passed: 3064 Inconclusive: 13 Failed: 1 Ignored: 137)
  • monotouch-test/Mac Catalyst/Release (static registrar, all optimizations): Failed (Test run failed.
    Tests run: 3202 Passed: 3064 Inconclusive: 13 Failed: 1 Ignored: 137)
  • monotouch-test/Mac Catalyst/Debug (interpreter): Failed (Test run failed.
    Tests run: 3205 Passed: 3069 Inconclusive: 13 Failed: 1 Ignored: 135)
  • monotouch-test/Mac Catalyst/Release (interpreter): Failed (Test run failed.
    Tests run: 3202 Passed: 3062 Inconclusive: 13 Failed: 1 Ignored: 139)

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 (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
✅ 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: be1d187f1284c31c671a45f589a0150d58958702 [PR build]

@mandel-macaque
Copy link
Member Author

Failing tests are unrelated to code changes.

@mandel-macaque mandel-macaque merged commit 860369d into main May 27, 2025
36 of 40 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/fix-byte-to-bool branch May 27, 2025 01:02
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