-
-
Notifications
You must be signed in to change notification settings - Fork 226
System.Drawing.Point instead of POINT? #420
Comments
Yes: the System.Windows.Forms itself also defines |
Actually, I have tried declaring The reason it works is that from what I've seen, With that in mind, all having a separate |
The managed Point class lacks the struct attribute to enforce field layout, so in fact whole it might work in your test, the CLR reserves the right to break it in release builds, or on x64, or in a servicing release of the runtime. When used for native interop, the field layout is critical. |
We could add an implicit conversion operator to our type so that it automatically converts to and from the windows forms type. |
I very much doubt that's likely to change since backward compatibility is a top priority for the Framework. |
Whoa. I had no idea. Cool. :) |
Confirmed. Sequential is default in C#. That said, we target .NET Standard and PCL profiles with this library, so a WinForms dependency would be incompatible with those targets. I think an implicit conversion operator pair would probably alleviate the pain you're experience though. Do you agree? |
System.Drawing.Point isn't actually in Windows Forms. Aside from the .NET Framework it's available in .NET Core from 1.0 and .NET Standard from 2.0. I couldn't tell whether the PCL profiles include it (EDIT: actually from the table at the bottom here it looks like they don't). That being said, wouldn't having the conversion operators just introduce the same dependency? |
It wouldn't be quite the same dependency, since That said, as you say, apparently the .NET type is defined as far back as netstandard1.6, so that looks promising. |
Would it be acceptable to conditionally define |
Good point about the implicit conversion still requiring intermediate locals. Conditionally defining public API is restricted to only adding API as you move to higher target framework versions or from .NET Standard to compatible target platform, so that folks don't get MissingMethodException at runtime. That may be an option here, I don't know. I'll have to look more into it. |
Is there a specific reason
System.Drawing.Point
isn't being used instead ofPOINT
?It seems logical to use an existing type when one is available and works just as well.
The text was updated successfully, but these errors were encountered: