terrafx / terrafx.interop.windows

Interop bindings for Windows.
MIT License
242 stars 31 forks source link

[IMPL] Add implicit conversion from RECT -> System.Drawing.Rectangle. #388

Open AraHaan opened 4 months ago

AraHaan commented 4 months ago

Proposal Implementation

Adds an implicit conversion operator from RECT -> Rectangle with an explicit operator from Rectangle back to RECT when the rectangle needs converted to an RECT for calls into Windows APIs that requires it. Also with operators handling these conversions programmers would worry less on if they got their conversion between RECT <-> Rectangle correct or not by eliminating all the guess work from it. Unit tests of the operators will come soon. As such I opened this pull request as a draft.

Implements/Fixes https://github.com/terrafx/terrafx.interop.windows/issues/387.

tannergooding commented 4 months ago

Same general feedback as given on the issue. I'm not particularly a fan of this, as its potentially lossy and brings in a new dependency.

This really seems like something where a user could provide extension methods for their own library to solve the need.