CommunityToolkit / CommunityToolkit/dotnet

`Guard.IsReferenceEqualTo` should accept `T?`

Open
#943 0 comments 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

Currently it seems that `Guard.IsReferenceEqualTo` requires the parameters to be non-null. I believe the signature should be changed to permit nullable types because I believe that comparison to null values is a reasonable expectation and it is supported by the underlying call to `object.ReferenceEquals`

### Regression

_No response_

### Steps to reproduce

```text
object x = null;
object y = new Object();

Guard.IsReferenceEqualTo(x,y); //produces CS8634
```

### Expected behavior

No CS8634

### Screenshots

_No response_

### IDE and version

VS 2022 Preview

### IDE version

_No response_

### Nuget packages

- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [ ] CommunityToolkit.Mvvm (aka MVVM Toolkit)

### Nuget package version(s)

8.2.2

### Additional context

_No response_

### Help us help you

Yes, I'd like to be assigned to work on this item

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.