dotnet / dotnet/wpf

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

Open
#11,041 18 comments 1 reaction 0 assignees View on GitHub
:mailbox_with_no_mail: waiting-author-feedback
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### 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](url)
```
return ((x >= _x) && (x - _width <= _x) &&
(y >= _y) && (y - _height <= _y));
```
expected:
```
return ((x >= _x) && (x - _width < _x) &&
(y >= _y) && (y - _height < _y));
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.