Skip to content

[API Proposal]: Consider support for IEquatable<Uri> on System.Uri #97940

Closed
@dahlia

Description

@dahlia

Edited by @MihaZupan on 2024-02-16

Background and motivation

For a long time, the System.Uri type has provided equality comparison operations via the object.Equals(object?) method and the operator ==() & operator !=() operators. Therefore, there is no reason not to further implement the IEquatable<Uri> interface.

API Proposal

namespace System;

-public partial class Uri : ISpanFormattable, ISerializable
+public partial class Uri : ISpanFormattable, ISerializable, IEquatable<Uri>
{
    // Existing
    public override bool Equals(object? comparand);

+   public bool Equals(Uri? other);
}

API Usage

IEquatable<Uri> a = new Uri("https://example.com/a");
IEquatable<Uri> b = new Uri("https://example.com/b");
Console.WriteLine("Equals? {0}", a.Equals(b));

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Netin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions