An implementation of IEqualityComparer<T> for IRef that compares references based on RefComparison semantics.
Namespace: Metalama.Framework.Code.Comparers
Assembly: Metalama.Framework.dll
Syntax
public sealed class RefEqualityComparer : IEqualityComparer<IRef>, IRefEqualityComparerRemarks
This comparer allows using IRef instances as keys in dictionaries or elements in hash sets. 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?, IRef?) | |
| GetHashCode(IRef) |