Skip to content

Create / revise articles for classes, structs and records#52685

Merged
BillWagner merged 14 commits intodotnet:mainfrom
BillWagner:classes-structs-records-oh-my
Apr 3, 2026
Merged

Create / revise articles for classes, structs and records#52685
BillWagner merged 14 commits intodotnet:mainfrom
BillWagner:classes-structs-records-oh-my

Conversation

@BillWagner
Copy link
Copy Markdown
Member

@BillWagner BillWagner commented Mar 25, 2026

Reviewed classes.md, and about to embark on a large body of work for records.md
Reorder and make a number of content changes.
@BillWagner BillWagner marked this pull request as ready for review March 26, 2026 19:25
@BillWagner BillWagner requested a review from a team as a code owner March 26, 2026 19:25
Copilot AI review requested due to automatic review settings March 26, 2026 19:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the C# fundamentals type-system content by revising the classes and records articles, adding a new structs article, and aligning the accompanying snippet projects/examples.

Changes:

  • Add a new Structs fundamentals article and snippet project, and wire it into the C# TOC and type-system index.
  • Revise Classes and Records fundamentals articles with updated structure, guidance, and refreshed snippets.
  • Update snippet projects to target net10.0 and expand record snippets to include record-struct examples.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/csharp/toc.yml Adds the Structs article to the Type system section.
docs/csharp/fundamentals/types/index.md Updates the Structs link to point to the new fundamentals article.
docs/csharp/fundamentals/types/classes.md Rewrites the classes article and points to updated snippet IDs.
docs/csharp/fundamentals/types/records.md Rewrites the records article and expands coverage (record structs, with, equality, inheritance).
docs/csharp/fundamentals/types/structs.md Adds a new structs fundamentals article with referenced snippets.
docs/csharp/fundamentals/types/snippets/classes/classes.csproj Updates snippet project target framework to net10.0.
docs/csharp/fundamentals/types/snippets/classes/Program.cs Reworks class snippets (creation, reference semantics, required, initializers, inheritance).
docs/csharp/fundamentals/types/snippets/classes/Containers.cs Renames namespaces and adds a pragma to avoid snippet warnings.
docs/csharp/fundamentals/types/snippets/records/Records.csproj Updates snippet project target framework to net10.0.
docs/csharp/fundamentals/types/snippets/records/Program.cs Adds invocation of the new record-struct demo entry point.
docs/csharp/fundamentals/types/snippets/records/RecordStruct.cs Adds record struct declarations and demos (assignment semantics, with).
docs/csharp/fundamentals/types/snippets/records/FirstRecord.cs Expands record snippets (declaration, body, inheritance, deconstruction).
docs/csharp/fundamentals/types/snippets/records/ImmutableRecord.cs Updates with expression example.
docs/csharp/fundamentals/types/snippets/records/EqualityTest.cs Updates equality example and narrative outputs.
docs/csharp/fundamentals/types/snippets/structs/structs.csproj Adds a new structs snippet project targeting net10.0.
docs/csharp/fundamentals/types/snippets/structs/Program.cs Adds structs examples for value semantics, constructors/default, readonly, and auto-default behavior.

Comment thread docs/csharp/fundamentals/types/classes.md Outdated
Comment thread docs/csharp/fundamentals/types/classes.md Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BillWagner BillWagner requested a review from gewarren March 26, 2026 19:37
Comment thread docs/csharp/fundamentals/types/records.md Outdated
Comment thread docs/csharp/fundamentals/types/records.md Outdated
Comment thread docs/csharp/fundamentals/types/records.md Outdated
Comment thread docs/csharp/fundamentals/types/records.md Outdated
Comment thread docs/csharp/fundamentals/types/classes.md Outdated
Comment thread docs/csharp/fundamentals/types/classes.md Outdated
Comment thread docs/csharp/fundamentals/types/classes.md Outdated
Comment thread docs/csharp/fundamentals/types/classes.md Outdated
BillWagner and others added 6 commits April 3, 2026 16:47
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@BillWagner BillWagner enabled auto-merge (squash) April 3, 2026 20:53
@BillWagner BillWagner merged commit 0a1e8f4 into dotnet:main Apr 3, 2026
9 checks passed
@BillWagner BillWagner deleted the classes-structs-records-oh-my branch April 3, 2026 20:55
Copy link
Copy Markdown
Contributor

@adegeo adegeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, I didn't get to the structs article, but here were my comments in progress.

Comment thread docs/csharp/fundamentals/types/classes.md
Comment thread docs/csharp/fundamentals/types/classes.md
Comment thread docs/csharp/fundamentals/types/classes.md
Comment thread docs/csharp/fundamentals/types/classes.md
Comment thread docs/csharp/fundamentals/types/classes.md
Comment on lines +67 to +69
:::code language="csharp" source="snippets/records/ImmutableRecord.cs" ID="WithExpression":::

The following example defines a public record that uses positional parameters to declare and instantiate a record. It then prints the type name and property values:
:::code language="csharp" source="snippets/records/RecordStruct.cs" ID="RecordStructWith":::
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as the other back-to-back snippets. Get these into a single snippet.

Comment thread docs/csharp/fundamentals/types/snippets/records/EqualityTest.cs
Comment thread docs/csharp/fundamentals/types/structs.md
Comment on lines +55 to +57
:::code language="csharp" source="snippets/structs/Program.cs" ID="ReadonlyStruct":::

:::code language="csharp" source="snippets/structs/Program.cs" ID="UsingReadonly":::
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here, put something between these...

Comment on lines +61 to +63
:::code language="csharp" source="snippets/structs/Program.cs" ID="ReadonlyMembers":::

:::code language="csharp" source="snippets/structs/Program.cs" ID="UsingReadonlyMembers":::
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here, put something between these...

BillWagner added a commit to BillWagner/docs that referenced this pull request Apr 6, 2026
dotnet#52685 was merged while a review wasn't yet completed. Address those comments.
@BillWagner BillWagner mentioned this pull request Apr 6, 2026
BillWagner added a commit that referenced this pull request Apr 7, 2026
* Address comments

#52685 was merged while a review wasn't yet completed. Address those comments.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix warning.

* Apply suggestions from code review

Co-authored-by: Andy (Steve) De George <67293991+adegeo@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Andy (Steve) De George <67293991+adegeo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Everyday C#] Phase B, Task 4, Type system: class, struct, and records.

4 participants