Skip to content

record struct equality problem #1330

@bnayae

Description

@bnayae

When I check Equals on record struct I got unexpected result.

you can see it with the following code snippets:

    public enum S3EnvironmentConvention
    {
        None,
        BucketPrefix,
        PathPrefix
    }

    public record struct S3Options
    {
        public string? Bucket { get; init; }
        public string? BasePath { get; init; }
        public S3EnvironmentConvention EnvironmentConvension { get; init; } = S3EnvironmentConvention.None;
    }

TEST

        [Fact]
        public void S3Options_Equals_Test()
        {
            var x = new S3Options { BasePath = "p/a/t/h", Bucket = "root" };
            var y = new S3Options { BasePath = "p/a/t/h" };
            Assert.False(x.Equals(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