dotnet / dotnet/csharpstandard

Inaccurate wording regards binding of properties (get vs set)

Open
#295 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

This is a follow-up of a chat with @CyrusNajmabadi in Roslyn's Gitter. I was after an API to distinguishing the between the binding of a property's `set` or `get` underlying method, while I learned about this case.

```
class A { ref int Prop { get { ... } } }
...
a.Prop = 5
```

I suppose this makes the [language spec](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/classes#properties) inaccurate according to the statement below:

> Except as the target of an assignment, when a property is referenced in an expression, the get accessor of the property is invoked to compute the value of the property

If this assumption is correct, please consider updating the spec with the detailed rules.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.