-
Notifications
You must be signed in to change notification settings - Fork 555
[tests] Fix CGRenderingBufferProviderTest.SizeProperty_DoesNotThrow to have consistent results. #24574
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
base: main
Are you sure you want to change the base?
Conversation
…o have consistent results. Use an autorelease pool to ensure object lifetime is consistent, and thus asserts work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Stabilizes CGRenderingBufferProviderTest.SizeProperty_DoesNotThrow by making native object lifetime more deterministic so the assertions behave consistently across runs.
Changes:
- Wraps provider creation/usage in an
NSAutoreleasePool. - Updates the expected
releaseInfocallback behavior after the pool is drained.
| using (var pool = new NSAutoreleasePool ()) { | ||
| var provider = CGRenderingBufferProvider.Create ((nint) 0x0ee1f00d, (nuint) size, | ||
| lockPointer: (info) => { | ||
| calledOnLockPointer = true; | ||
| var rv = Marshal.AllocHGlobal (size); | ||
| return rv; | ||
| }, | ||
| unlockPointer: (info, pointer) => { | ||
| calledOnUnlockPointer = true; | ||
| Marshal.FreeHGlobal (pointer); | ||
| }, | ||
| releaseInfo: (info) => { | ||
| calledOnReleaseInfo = true; | ||
| }); | ||
| Assert.That (provider, Is.Not.Null, "provider"); | ||
| Assert.That (provider.Size, Is.EqualTo ((nuint) size), "size"); |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provider is created inside the autorelease pool but never disposed. Since CGRenderingBufferProvider inherits NativeObject, the native handle is only released deterministically when Dispose is called; otherwise releaseInfo may or may not run before the assertions (depends on GC/finalization), which can keep this test flaky. Wrap the provider in using/using var (inside the pool) so its lifetime is deterministic, and then keep the calledOnReleaseInfo assertion outside the pool (similar to BitmapContextTest.cs's CreateAdaptive_4).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #a505d7b] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #a505d7b] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #a505d7b] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #a505d7b] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #a505d7b] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #a505d7b] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #a505d7b] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #a505d7b] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #a505d7b] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 117 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Use an autorelease pool to ensure object lifetime is consistent, and thus asserts work as expected.