How create ObservableProperty with private setter?

Open
#468 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
documentation

Research direction

The issue does not name a file or test; start by locating the ObservableProperty documentation and existing examples. Check how private setters are currently handled, then define the expected behavior for the requested syntax and document or specify that behavior consistently.

Written by the indexing model from the issue text.

Description

Pri3

I can't find an example of a private setter implementation anywhere.

Usage scenario without toolkit:

private Project _current = null!;
/// <summary>
/// Редактируемый проект.
/// </summary>
public Project Current
{
    get => _current;
    private set => SetProperty(ref _current, value);
}

Desired implementation:

[ObservableProperty(PrivateSetter = true)] 
private Project _current = null!;
Dominant language
No language data
Stars
168
Forks
134
PR merge metrics
No merged PRs in 30d

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 MicrosoftDocs/CommunityToolkit

All issues in MicrosoftDocs/CommunityToolkit

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.