Skip to content

Conversation

gewarren
Copy link
Contributor

@gewarren gewarren commented Aug 25, 2025

@gewarren gewarren requested a review from a team as a code owner August 25, 2025 22:09
@dotnetrepoman dotnetrepoman bot added this to the August 2025 milestone Aug 25, 2025
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM overall. There's some nuances on primary constructors, records, and public properties that could be misleading for some readers. I had one suggestion. Feel free to reword so it flows in this article.


:::code language="csharp" source="./snippets/structured-output/Program.cs" id="InputOutputRecord":::

(This record type is defined using [primary constructor](../../csharp/programming-guide/classes-and-structs/instance-constructors.md#primary-constructors) syntax. Primary constructors, which are available in C# 12 and later versions, combine the class definition with the parameters that are necessary to instantiate any instance of the class. The C# compiler generates public properties for the primary constructor parameters.)
Copy link
Member

Choose a reason for hiding this comment

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

First, should this be a NOTE? Second, primary constructors on record types have been available since C# 9: C# 9 added record types (record class). C# 10 added record struct types. C# 12 allowed primary constructors on class and struct types that aren't records. And, primary constructor parameters generate public properties for record types only. That seems like a side quest in this article. So, maybe something like this:

Suggested change
(This record type is defined using [primary constructor](../../csharp/programming-guide/classes-and-structs/instance-constructors.md#primary-constructors) syntax. Primary constructors, which are available in C# 12 and later versions, combine the class definition with the parameters that are necessary to instantiate any instance of the class. The C# compiler generates public properties for the primary constructor parameters.)
(This record type is defined using [primary constructor](../../csharp/programming-guide/classes-and-structs/instance-constructors.md#primary-constructors) syntax. Primary constructors have been available for `record` types since C# 9.0, are available for all types in C# 12 and later versions. Primary constructors combine the class definition with the parameters that are necessary to instantiate any instance of the class. The C# compiler generates public properties in `record` types for the primary constructor parameters.)

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.

[UUF] Clarify structured output setup
2 participants