RecordDeclaration Class

Represents a record declaration.

public class RecordDeclaration : ClassOrStructDeclaration

Example

var record = new RecordDeclaration("Person");

// An accessor without statements is auto-implemented
record.Members.Add(new PropertyDeclaration("Name", typeof(string)) { Getter = new PropertyAccessorDeclaration { Statements = null } });
record.Members.Add(new PropertyDeclaration("Age", typeof(int)) { Getter = new PropertyAccessorDeclaration { Statements = null } });

Assert.Equal("""
    record Person
    {
        string Name
        {
            get;
        }

        int Age
        {
            get;
        }
    }

    """, record.ToCsharpString());
Inheritance
ClassOrStructDeclaration RecordDeclaration

Constructors

NameDescription
RecordDeclaration()
RecordDeclaration(string?)Initializes a new instance of the RecordDeclaration class with the specified name.

RecordDeclaration overloads

RecordDeclaration()

RecordDeclaration.cs
public RecordDeclaration()

No documentation is available.

RecordDeclaration(string?)

RecordDeclaration.cs

Initializes a new instance of the RecordDeclaration class with the specified name.

public RecordDeclaration(string? name)
Parameters
name string?
The record name.

Properties

NameDescription
BaseType
public TypeReference? BaseType { get; set; }

Property value

TypeReference?

No documentation is available.