Skip to content

Rect.Contains(double x, double y) returns true for points on both right and bottom edges #11041

@lfmissonb

Description

@lfmissonb

Description

Rect.Contains(double x, double y) returns true for points on both right and bottom edges

Reproduction Steps

Console.WriteLine(new Rect(0, 0, 1, 1).Contains(0, 0));
Console.WriteLine(new Rect(0, 0, 1, 1).Contains(0, 1));
Console.WriteLine(new Rect(0, 0, 1, 1).Contains(1, 0));
Console.WriteLine(new Rect(0, 0, 1, 1).Contains(1, 1));

Expected behavior

output:
True
False
False
False

Actual behavior

output:
True
True
True
True

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Rect.cs#L763

            return ((x >= _x) && (x - _width <= _x) &&
                    (y >= _y) && (y - _height <= _y));

expected:

            return ((x >= _x) && (x - _width < _x) &&
                    (y >= _y) && (y - _height < _y));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions