Skip to content

Relax or adjust NUnit2040 to handle nullable value types #971

@stevenaw

Description

@stevenaw

NUnit2040 helps guide for correct usage of the SameAs constraint by alerting to value types passed in as value types can't be reference-equal. It will raise an error if it detects these.

One edge case is around nullable value types. The below code will alert an error by the analyzer but the assertion itself will pass.


            int? index = default;
            Assert.That(index, Is.SameAs(index));

A few options I could think of:

  • Do not alert at all for nullable value types
  • Raise a warning instead of an error for nullable value types

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