-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add PropertyItem tests #46794
Add PropertyItem tests #46794
Conversation
Tagging subscribers to this area: @safern, @tannergooding Issue DetailsNot committing the refactoring yet as I need to baseline the test failures on mac :)
|
Ok most of these tests fail on libgdiplus but will be fixed in mono/libgdiplus#683. I'll disable them on mac soon |
80b7e2b
to
ec4a1b5
Compare
Test failures unrelated - System.Speech problems |
ec4a1b5
to
905a9ed
Compare
905a9ed
to
440b283
Compare
I may need to actually disable the tests - so tests will probably fail again then I will baseline the failures |
Sounds good. Let me know when/if this is ready for review 😄 |
1ed8bb1
to
3102772
Compare
OK I've made the following changes that are actually quite positive. Basically, I converted PropertyItemInternal into a blittable struct. Now, instead of marshalling lots of data we can just pin the I also avoided an allocation of an array of one element in the code for I also took advantage of This will have some perf wins and also shortens the code! Winning! |
3102772
to
77e3558
Compare
Have run the tests on macOS with my locally built libgdiplus (enabling the property item tests that fail but are fixed in mono/libgdiplus#683). So this should be now ready for review!
|
77e3558
to
a51f503
Compare
// sdkinc\imaging.h | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal sealed class PropertyItemInternal : IDisposable | ||
#pragma warning disable CS0649 |
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.
Maybe just put it around the uninitialized field?
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.
Updated
item.Value = value; | ||
Assert.Same(value, item.Value); | ||
|
||
// Set same. |
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.
What is this exercising? I mean double setting to the same value?
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.
Its something we do in winforms where we test setting a property to the same value to make sure things are idempotent.
Removed
a51f503
to
03bf0fc
Compare
@JeremyKuhne also may be worth taking a look as you've done something similar here recently |
03bf0fc
to
8e40c51
Compare
if (size == 0 || count == 0) | ||
return Array.Empty<PropertyItem>(); | ||
|
||
PropertyItemInternal* propdata = (PropertyItemInternal*)Marshal.AllocHGlobal((int)size); |
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.
Can you change this to rent a byte array from the ArrayPool and pin that for the buffer please? It would be good to get rid of the AllocHGlobal. :)
if (size == 0) | ||
return null; | ||
|
||
PropertyItemInternal* propdata = (PropertyItemInternal*)Marshal.AllocHGlobal((int)size); |
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.
Rent a byte buffer from the ArrayPool
here too.
8e40c51
to
b3b0287
Compare
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.
Thanks!
I'll close and re-open as the build is 3 weeks old already. |
I hit the wrong button 😄 (twice). I'll keep an eye on the build |
No description provided.