Repository navigation
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for C# records, which were treated as ordinary classes and structs.
ToString,Deconstruct, the copy constructor, and so on) are no longer listed inCompositeTypeModelor 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.CSharp.FormatDefinitionnow writes records as they are declared, such aspublic record Point(int X, int Y)orpublic readonly record struct Pair(int A, int B).ICompositeTypegainsIsRecordandPrimaryConstructor, both with default implementations.Each commit builds without warnings and passes the full test suite on its own. The commit messages list the behavior changes.