Ensure Primary Constructor Parameter Member Generation Coverage

Open
#780 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
testing-qa

Research direction

Start with the linked primary constructors documentation, then locate the repository's existing coverage for primary constructor parameters. Check cases for private-field capture, omitted fields, record properties, and inherited record properties, including the non-record distinction. Done means each stated behavior is covered by tests or examples and the relevant test suite passes.

Written by the indexing model from the issue text.

Description

manuscript
  • When a primary constructor parameter is used, the compiler captures the constructor parameter in a private field with a compiler-generated name.
    If a primary constructor parameter isn't used in the body of the type, no private field is captured. (That rule prevents accidentally allocating two copies of a primary constructor parameter that's passed to a base constructor.)
  • If the type includes the record modifier, the compiler instead synthesizes a public property with the same name as the primary constructor parameter.
  • For record class types, if a primary constructor parameter uses the same name as a base primary constructor, that property is a public property of the base record class type. It isn't duplicated in the derived record class type. These properties aren't generated for non-record types.
    See https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/instance-constructors#primary-constructors
Dominant language
C#
Stars
419
Forks
173
Avg merge
3m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntelliTect/EssentialCSharp

All issues in IntelliTect/EssentialCSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.