Why is RectangleF.IsEmpty implementation different than .NET?

ShawnCastrianniShawnCastrianni USBeta ✭✭✭

The Mono version of RectangleF.IsEmpty is coded to use (width <= 0 || height <= 0) which is NOT what the docs state nor what the .NET implementation does (I think). How can we possibly leverage a common C# code base across multiple platforms if the underlying C# runtime (whether .NET or Mono) behave differently? Looking at the history of the RectangleF.cs file, it used to be correct a long time ago but got changed.

Posts

  • ShawnCastrianniShawnCastrianni USBeta ✭✭✭

    Also interesting is that SizeF is correct and uses == 0. That means I will get different answers if I do RectangleF.IsEmpty versus RectangleF.Size.IsEmpty. That really seems like bad behavior.

  • ShawnCastrianniShawnCastrianni USBeta ✭✭✭

    I tracked the change to Sebastien Pouliot with revision 77435 on 2007-05-15. The comment is:

    A rectangle with a negative width or height is also empty.

    Why?

  • RolfBjarneKvingeRolfBjarneKvinge USXamarin Team Xamurai

    Don't assume the documentation is correct.

    Try an example with both Mono and .NET and see if it really is a difference in behavior.

  • SebastienPouliotSebastienPouliot CAXamarin Team Xamurai

    @ShawnCastrianni that was a long time ago - but I already had the habit to add unit tests for such changes. I do not have Windows around right now but I doubt it changed from .NET 2.0 times...

    git revision 9c1a165623df710d676399506a38f9dd05583d53

Sign In or Register to comment.