-
Notifications
You must be signed in to change notification settings - Fork 511
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
[Phase] Implement Xcode 16.0 beta 1-6 changes. #21156
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8c39190
[Phase] Implement Xcode 16.0 beta 1-6 changes.
rolfbjarne f636cc2
Auto-format source code
571f2e2
Merge remote-tracking branch 'origin/xcode16' into dev/rolf/xcode16-b…
rolfbjarne 65a3fe6
Skip legacy
rolfbjarne e2cc439
Merge remote-tracking branch 'origin/xcode16' into dev/rolf/xcode16-b…
rolfbjarne d9849da
Improve documentation.
rolfbjarne be1e778
Make 'readonly ref' to limit usage.
rolfbjarne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
#if !__WATCHOS__ | ||
#if NET | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
using AudioToolbox; | ||
using Foundation; | ||
|
||
using ObjCRuntime; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace MonoTouchFixtures.AudioToolbox { | ||
|
||
[TestFixture] | ||
[Preserve (AllMembers = true)] | ||
public class AudioBufferListTest { | ||
[Test] | ||
public unsafe void Usage () | ||
{ | ||
var buffer = new byte [1024]; | ||
fixed (byte* ptr = buffer) { | ||
var list = (AudioBufferList*) ptr; | ||
Assert.AreEqual (0, list->Count, "Count"); | ||
Assert.Throws<ArgumentOutOfRangeException> (() => list->GetBuffer (0), "Item 0"); | ||
Assert.Throws<ArgumentOutOfRangeException> (() => list->GetBuffer (-1), "Item -1"); | ||
Assert.Throws<ArgumentOutOfRangeException> (() => list->GetBuffer (1), "Item 1"); | ||
|
||
*(int*) ptr = 3; | ||
Assert.AreEqual (3, list->Count, "Count B"); | ||
for (var i = 0; i < 3; i++) { | ||
Assert.AreEqual (0, list->GetBuffer (i)->NumberChannels, $"NumberChannels B#{i}"); | ||
Assert.AreEqual (0, list->GetBuffer (i)->DataByteSize, $"DataByteSize B#{i}"); | ||
Assert.AreEqual ((nint) 0, list->GetBuffer (i)->Data, $"Data B#{i}"); | ||
|
||
list->GetBuffer (i)->NumberChannels = (i + 1) * 10; | ||
list->GetBuffer (i)->DataByteSize = (i + 1) * 100; | ||
list->GetBuffer (i)->Data = new IntPtr ((i + 1) * 1000); | ||
} | ||
Assert.Throws<ArgumentOutOfRangeException> (() => list->GetBuffer (-1), "Item -1 B"); | ||
Assert.Throws<ArgumentOutOfRangeException> (() => list->GetBuffer (3), "Item 3 B"); | ||
|
||
int* iptr = (int*) ptr; | ||
Assert.AreEqual (10, iptr [2 + 0 * 4], "10"); // NumberChannels | ||
Assert.AreEqual (100, iptr [2 + 0 * 4 + 1], "20"); // DataByteSize | ||
Assert.AreEqual (20, iptr [2 + 1 * 4], "20"); // NumberChannels | ||
Assert.AreEqual (200, iptr [2 + 1 * 4 + 1], "40"); // DataByteSize | ||
Assert.AreEqual (30, iptr [2 + 2 * 4], "30"); // NumberChannels | ||
Assert.AreEqual (300, iptr [2 + 2 * 4 + 1], "60"); // DataByteSize | ||
|
||
nint* nptr = (nint*) ptr; | ||
Assert.AreEqual ((nint) 1000, nptr [1 + 0 * 2 + 1], "1000"); // Data | ||
Assert.AreEqual ((nint) 2000, nptr [1 + 1 * 2 + 1], "2000"); // Data | ||
Assert.AreEqual ((nint) 3000, nptr [1 + 2 * 2 + 1], "3000"); // Data | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif // NET | ||
#endif // !__WATCHOS__ |
19 changes: 0 additions & 19 deletions
19
tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-PHASE.todo
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is using
ref
appropriate here, it constrains the usage of this struct pretty heavily, especially around async/await and lambdas.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.
Is it possible for us to implement a public ctor that throws and exception in DEBUG builds, but is optimized out for Release builds?
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.
I can't think of any example where it would cause a problem, having in mind that this struct is supposed to be used as a pointer only.
Also it's easier to "unref" later on if we find out we were wrong than it is to add it back.
Technically yes, with some help from the linker.
That said, using this struct in the wrong way is still safe, because if you create it like this:
you'd get an AudioBufferList with 0 buffers (
Count
would return 0, andGetBuffer
would always throw an IndexOutOfRangeException).So I think going through a lot of trouble to add a public ctor that throws an exception for DEBUG builds is a bit more work than this problem warrants (also because a struct's public ctor won't always be called).