Skip to content

Conversation

@rolfbjarne
Copy link
Member

Use an autorelease pool to ensure object lifetime is consistent, and thus asserts work as expected.

…o have consistent results.

Use an autorelease pool to ensure object lifetime is consistent, and thus asserts work as expected.
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

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 releaseInfo callback behavior after the pool is drained.

Comment on lines 35 to 50
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");
Copy link

Copilot AI Jan 28, 2026

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).

Copilot uses AI. Check for mistakes.
@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 #a505d7b] Build passed (Build packages) ✅

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #a505d7b] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [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
✅ 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. [attempt 2] 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 9 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 9 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: a505d7bca4dbfe5be544f9d076b0d2d34a933952 [PR build]

@rolfbjarne rolfbjarne marked this pull request as ready for review January 30, 2026 11:43
@rolfbjarne rolfbjarne enabled auto-merge (squash) January 30, 2026 11:44
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.

3 participants