A strongly-typed implementation of IEqualityComparer<T> for IRef<T> that compares references based on RefComparison semantics.
Namespace: Metalama.Framework.Code.Comparers
Assembly: Metalama.Framework.dll
Syntax
public sealed class RefEqualityComparer<T> : IEqualityComparer<IRef<T>?>, IRefEqualityComparer where T : class, ICompilationElementType Parameters
| Name | Description |
|---|---|
| T | The type of compilation element referenced, such as IMethod, IProperty, INamedType, or any other ICompilationElement. |
Remarks
This is the strongly-typed variant of RefEqualityComparer. It allows using IRef<T> instances as keys in dictionaries or elements in hash sets while maintaining type safety.
Use the appropriate static property to obtain a comparer with the desired comparison strategy:
- Default: Fast comparison within the same compilation, ignores nullability.
- IncludeNullability: Same compilation, considers nullable annotations.
- Structural: Cross-compilation comparison, ignores nullability.
- StructuralIncludeNullability: Cross-compilation, considers nullable annotations.
Properties
| Name | Description |
|---|---|
| Default | Gets the default equality comparer that uses Default semantics. This is the fastest comparer and is suitable for comparing references within the same compilation. |
| IncludeNullability | Gets an equality comparer that uses IncludeNullability semantics. Use when nullable reference type annotations should affect equality. |
| Structural | Gets an equality comparer that uses Structural semantics. Use when comparing references across different compilation versions. |
| StructuralIncludeNullability | Gets an equality comparer that uses StructuralIncludeNullability semantics. Use when comparing references across different compilations and nullable annotations matter. |
Methods
| Name | Description |
|---|---|
| Equals(IRef<T>?, IRef<T>?) | |
| GetHashCode(IRef<T>) |