From b515ea7aed8f5bbc46137906893f119fbc3eeebb Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 23 Dec 2025 10:42:12 -0800 Subject: [PATCH 1/2] Add reason for using primary constructor Explain the benefits and trade-offs of using primary constructors in C#. --- docs/fundamentals/code-analysis/style-rules/ide0290.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0290.md b/docs/fundamentals/code-analysis/style-rules/ide0290.md index 2ac705366d18d..9da9851ff7ec8 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0290.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0290.md @@ -24,6 +24,8 @@ dev_langs: This rule flags classes that can use a [primary constructor](../../../csharp/programming-guide/classes-and-structs/instance-constructors.md#primary-constructors) instead of a separate constructor definition. You define a primary constructor by placing any constructor parameters in parentheses following the type name. A primary constructor indicates that these parameters are necessary for any instance of the type. +The ability of a class or struct in C# to have more than one constructor provides for generality, but at the expense of some tedium in the declaration syntax, because the constructor input and the class state need to be cleanly separated. Primary constructors put the parameters of one constructor in scope for the whole class or struct to be used for initialization or directly as object state. The trade-off is that any other constructors must call through the primary constructor. + ## Options Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). From ba6f51ad05c3c70a6df7f4990c31ec8a5c793956 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 08:36:37 -0800 Subject: [PATCH 2/2] Rewrite primary constructor rationale in active voice (#50892) * Initial plan * Rewrite primary constructor rationale in active voice Converted passive voice paragraph to active voice with conversational tone per style guidelines. Uses "you" form and simpler, more direct language. Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com> --- docs/fundamentals/code-analysis/style-rules/ide0290.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0290.md b/docs/fundamentals/code-analysis/style-rules/ide0290.md index 9da9851ff7ec8..ffde613497f3e 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0290.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0290.md @@ -24,7 +24,7 @@ dev_langs: This rule flags classes that can use a [primary constructor](../../../csharp/programming-guide/classes-and-structs/instance-constructors.md#primary-constructors) instead of a separate constructor definition. You define a primary constructor by placing any constructor parameters in parentheses following the type name. A primary constructor indicates that these parameters are necessary for any instance of the type. -The ability of a class or struct in C# to have more than one constructor provides for generality, but at the expense of some tedium in the declaration syntax, because the constructor input and the class state need to be cleanly separated. Primary constructors put the parameters of one constructor in scope for the whole class or struct to be used for initialization or directly as object state. The trade-off is that any other constructors must call through the primary constructor. +When you create a class or struct with multiple constructors, you gain flexibility, but you also add verbose syntax. You must cleanly separate the constructor input from the class state. With primary constructors, you can put one constructor's parameters in scope for the whole class or struct. You can use these parameters for initialization or directly as object state. However, if you add other constructors, they must call through the primary constructor. ## Options