-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-DependencyModel
Milestone
Description
Background and motivation
The current implementation looks like
namespace Microsoft.Extensions.DependencyModel
{
public struct Dependency
{
// for readonly proposal
public string Name { get; }
public string Version { get; }
// for IEquatable<> proposal
public bool Equals(Dependency other);
public override bool Equals(object obj); // common pattern with is T t && Equals(t)
public override int GetHashCode();
}
}So, all required members for IEquatable<> exist and properties aren't settable
API Proposal
namespace Microsoft.Extensions.DependencyModel
{
- public struct Dependency {}
+ public readonly struct Dependency : IEquatable<Dependency> {}
}The main point here is that nothing will be changed in the implementation as it already satisfied for these changes
API Usage
There are already some usages in HashSet<> where new EqualityComparer will be used
runtime/src/libraries/Microsoft.Extensions.DependencyModel/src/DependencyContextWriter.cs
Line 266 in 57bfe47
| var dependencies = new HashSet<Dependency>(); |
and some in dotnet/sdk
Also Dependency is public, so it might be useful for someone else 😄
Risks
None?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-DependencyModel