Open sandboxFocus

Interface IRecordFacet

Represents the structure of a record: the members that the compiler synthesizes for it.

Namespace: Metalama.Framework.Code.Types
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
[InternalImplement]
public interface IRecordFacet : ITypeFacet
Remarks

The facet is reached through Record, as in type.Facets.Record?.PrintMembersMethod. It is null for a type that IsRecord reports as not being a record.

One interface describes a record class and a record struct. A record struct has no equality contract, no clone method and no copy constructor, so these three properties are null for it.

The members that the compiler adds to a record and that are not specific to a record are not part of the facet: Equals, GetHashCode, ToString, and the == and != operators are reached through the member collections of INamedType like any other member. The primary constructor is reached through PrimaryConstructor, because a primary constructor is not specific to a record since C# 12.

Properties

Name Description
CloneMethod

Gets the clone method, whose metadata name is <Clone>$, or null when the type is a record struct, which has none. The with expression of a record class calls this method.

CopyConstructor

Gets the copy constructor, which the clone method calls, or null when the type is a record struct, which has none.

DeconstructMethod

Gets the Deconstruct method, or null when the record is not positional, that is, when it declares no parameter list.

EqualityContractProperty

Gets the EqualityContract property, or null when the type is a record struct, which has none.

PositionalProperties

Gets the properties that the positional parameters of the record declare, in the order of the parameters, or an empty list when the record is not positional. A positional parameter that declares no property, because the record or one of its base records declares a member of that name itself, contributes no element.

PrintMembersMethod

Gets the PrintMembers method, which appends the members of the record to the string that ToString returns.

Extension Methods

See Also