Skip to content

Release 3.2.0 - #14

Merged
kampute merged 4 commits into
mainfrom
v3.2.0
Oct 14, 2026
Merged

kampute merged 4 commits into
mainfrom
v3.2.0

Conversation

@kampute

@kampute kampute commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Adds support for C# records, which were treated as ordinary classes and structs.

  • Audit and models: members the compiler generates for a record (equality members, ToString, Deconstruct, the copy constructor, and so on) are no longer listed in CompositeTypeModel or reported by the documentation audit as undocumented. A member that replaces a generated one in source code is still listed and audited. The metadata layer is unchanged.
  • Declarations: CSharp.FormatDefinition now writes records as they are declared, such as public record Point(int X, int Y) or public readonly record struct Pair(int A, int B).
  • API: ICompositeType gains IsRecord and PrimaryConstructor, both with default implementations.
  • Version: 3.2.0.

Each commit builds without warnings and passes the full test suite on its own. The commit messages list the behavior changes.

The rule required a major version for any member added to a public
interface, including members with a default implementation, which do not
break existing implementers. The section heading is merged into
Conventions, keeping the rule about describing behavior changes in commit
messages.
The synthesized members of a record, such as its equality members,
ToString, Deconstruct, and copy constructor, carry CompilerGeneratedAttribute
and have no source declaration to document. CompositeTypeModel listed them
like user-authored members, so the documentation audit reported them as
undocumented and renderers listed them on type pages.

CompositeTypeModel now leaves compiler-generated members out of its member
collections, and XmlDocExtensions.Inspect reports no issues for them. A
member that overrides or replaces a synthesized member in source code is
still listed and inspected. The metadata layer is unchanged.

Behavior changes:
- The member collections of CompositeTypeModel included compiler-generated
  members. They now exclude them, and FindMember returns null for them.
- Inspect and InspectDocumentations reported issues for compiler-generated
  members. They now report none.
- A compiler-generated overload counted as an overload for the Overloads
  check and the OmitImplicitlyCreatedConstructors option. It no longer
  counts, so the implicit default constructor of a nominal record, whose
  only other constructor is the synthesized copy constructor, is omitted
  from the model and from the audit like that of any other type.
The C# formatter wrote a record as a class or struct that implements
IEquatable<T> of itself, which is not how it is declared.

ICompositeType gains IsRecord and PrimaryConstructor, both with default
implementations. Metadata does not mark records, so a record is recognized
by its compiler-generated equality operator, which source code cannot
declare in a record. The primary constructor is the user-declared
constructor whose parameters match those of the compiler-generated
Deconstruct method.

Behavior changes:
- FormatDefinition wrote "public class Point : IEquatable<Point>" for
  "public record Point(int X, int Y)". It now writes the record declaration,
  with record or record struct, the parameter list of the primary
  constructor, and without the implied IEquatable<T>. The arguments passed
  to a base record are not available in metadata and are not written.
- A record without a parameter list, or a positional record whose
  Deconstruct method is declared in source code, is written without a
  parameter list.
@kampute
kampute merged commit a943865 into main Oct 14, 2026
1 check passed
@kampute
kampute deleted the v3.2.0 branch October 14, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants