-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[API Implementation]: Expose System.Drawing.Graphics.NativeGraphics
.
#63058
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-system-drawing Issue DetailsProposal implementation of dotnet/winforms#8833 (closes dotnet/winforms#8833) Proposalnamespace System.Drawing
{
public partial class Graphics
{
public IntPtr Handle { get; }
public static Graphics FromHandle(IntPtr handle);
}
public partial class Brush
{
public IntPtr Handle { get; }
public static Brush FromHandle(IntPtr handle);
}
public partial class Pen
{
public IntPtr Handle { get; }
public static Pen FromHandle(IntPtr handle);
}
public partial class Image
{
public IntPtr Handle { get; }
public static Image FromHandle(IntPtr handle);
}
public partial class Region
{
public IntPtr Handle { get; }
public static Region FromHandle(IntPtr handle);
}
}
namespace System.Drawing.Drawing2D
{
public partial class Matrix
{
public IntPtr Handle { get; }
public static Matrix FromHandle(IntPtr handle);
}
public partial class GraphicsPath
{
public IntPtr Handle { get; }
public static GraphicsPath FromHandle(IntPtr handle);
}
} Current state of implementation
/cc @danmoseley
|
We do (or should) test all public API even pass throughs - the code will exist for years, refactoring happens over time and can introduce some issue or another. Plus, it ekes out a little more code coverage when we scan for missing coverage. |
@danmoseley Why is there still a build pipeline for NET Framework (which fails)? I thought that is officially not supported anymore? |
@deeprobin, System.Drawing.Common tests are executed on both .NET Framework and modern .NET to ensure behavioral compatibility between the two editions of the same library. |
@deeprobin how's this one going? do you need help? You have removed some entries from the ref, which creates a breaking change for code building against the non-netcoreapp target framework, eg., for .NET Standard. Existing API should stay in there. New API can go in the ref/...netcoreapp.cs file. If possible, please use https://github.com/dotnet/runtime/blob/4679edc6be3eb91263a7acfe542dfd30b53ed2bf/docs/coding-guidelines/updating-ref-source.md#for-most-assemblies-within-libraries -- it doesn't understand multiple ref files, but you can copy/paste the result to try to get formatting like the tool would create. |
Oh yes, I think I fixed that. CI is now failing: How would you construct a test for this? Creating 2 Handle-objects and swapping the |
Not sure of your question. If you're asking - how would we construct a test that expected a fatal error like a segfault? - we do not test for fatal errors, except possibly in some exceptional cases (and then by using RemoteExecutor.Invoke). |
@danmoseley I have looked at the tests again. The CI throws gdiplus errors.
This seems to be similar #22221 (comment) to this run https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-63058-merge-14bfe203df1a49fb92/System.Drawing.Common.Tests/1/console.8315be5d.log?sv=2019-07-07&se=2022-01-29T01%3A01%3A45Z&sr=c&sp=rl&sig=4Q5rnTbBhb3SPBRrdJgUCw9sB3Ep9GaNa6i17znSJX8%3D
|
@qmfrederik @eerhardt Can you perhaps give some thoughts on this, since you were involved in #22221? |
I have already implemented the change with the ActiveIssueAttribute. In case of doubt we can also revert this. https://github.com/deeprobin/runtime/tree/f39d2a3aeef9da389e9de5da7c77ad798e6461f1 |
@deeprobin your tests are causing a double-dispose, eg: public void FromHandle()
{
var region = new Region();
var expectedHandle = region.Handle;
var actualRegion = Region.FromHandle(expectedHandle);
IntPtr actualHandle = actualRegion.Handle;
Assert.Equal(expectedHandle, actualHandle);
// Do not dispose `region` because it is the same handle
actualRegion.Dispose();
} Here you're disposing The fix is likely to change Because you've got 8 PR's active at this time, I'm going to close this one. Please reactivate when you believe all the tests should be passing again. Thanks. |
public System.IntPtr Handle { get { throw null; } } | ||
public static System.Drawing.Graphics FromHandle(System.IntPtr handle) { throw null; } | ||
} | ||
|
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.
Our goal is to either generate these files (as discussed earlier) or make it look like the generator created it. The generator won't insert blank lines like this as we would in normal code.
/// <summary> | ||
/// The underlying graphics path handle | ||
/// </summary> | ||
public IntPtr Handle => _nativePath; |
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.
We try to order fields then properties then methods, with public before private. I'm surprised the editorconfig isn't flagging this for you.
Proposal implementation of dotnet/winforms#8833 (closes dotnet/winforms#8833)
Proposal
Current state of implementation
/cc @danmoseley