-
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-System.Runtimecode-analyzerMarks an issue that suggests a Roslyn analyzerMarks an issue that suggests a Roslyn analyzer
Description
Background and motivation
RuntimeTypeHandle is often used as a key in a dictionary. See hits on github: https://grep.app/search?q=dictionary%3Cruntimetypehandle. The search results include high profile libraries such a CsWinRt.
The runtime handles already implement strongly typed Equals(XXXHandle other) methods, but without the interfaces, dictionaries are going to use the Equals(object other) implementations instead, needlessly boxing the argument, unless a custom comparer is provided (it isn't in the above search results...).
API Proposal
namespace System
{
public struct RuntimeTypeHandle : IEquatable<RuntimeTypeHandle>
{
// bool Equals(RuntimeTypeHandle) already exists
}
public struct RuntimeMethodHandle : IEquatable<RuntimeMethodHandle>
{
// bool Equals(RuntimeMehtodHandle) already exists
}
public struct RuntimeFieldHandle : IEquatable<RuntimeFieldHandle>
{
// bool Equals(RuntimeFieldHandle) already exists
}
}API Usage
No boxing.
Alternative Designs
No response
Risks
No response
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-System.Runtimecode-analyzerMarks an issue that suggests a Roslyn analyzerMarks an issue that suggests a Roslyn analyzer