Skip to content

Equality Check Fails when Encapsulated Value is an Array #19

@MooVC

Description

@MooVC

Describe the bug
Equality Check Fails when Encapsulated Value is an Array

To Reproduce
Define a type that encapsulates an array type e.g.

[Monify(Type = typeof(ImmutableArray<Segment>))]
public partial class Qualifier

Define a test that checks for equality:

[Fact]
public void GivenSameArrayTwiceThenInstancesAreEqualButNotSameReference()
{
    // Arrange
    Segment[] values = [alpha, beta];

    // Act
    Qualifier first = values;
    Qualifier second = values;

    // Assert
    ReferenceEquals(first, second).ShouldBeFalse();
    (first == second).ShouldBeTrue();
    first.Equals(second).ShouldBeTrue();
}

Expected behavior
First and Second should be deemed equal, even though they are different references

Environment (please complete the following information):

  • Monify Version: 1.1.2
  • .NET Version (Your Project): .NET Standard 2.0
  • IDE: Visual Studio 2022 v17.14.16

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions