dotnet / dotnet/fsharp

Accessing C# internal set with public get results in no Property Initialization, and odd setter acce

Open
#7,165 4 comments 1 reaction 0 assignees View on GitHub
Area-Compiler-Checking Area-Compiler-Checking-Accessibility Feature Improvement
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Access to properties with public setters but internal getters is quite unusual.

**Repro steps**

Provide the steps required to reproduce the problem:

1. `dotnet new console -lang F#`
2. try to access a property declared as such `public int Prop { internal get; set; }` or try creating an instance of that class and set the property in property initialization syntax.

If possible attach a zip file with the repro case. This often makes it easier for others to reproduce.
The zip file should ideally represent the situation just before the call/step that is problematic.
repro repo resides radically realistically relativistically responsive, really https://github.com/tldrlol/Fs-Prop-Oddity/blob/master/DsTest.Cs/C.cs

**Expected behavior**

`let x = C(Prop=1)` or
`let x = C(); x.Prop <- 1` works

**Actual behavior**

only `let x = C(); x.set_Prop 1` works

**Known workarounds**

`x.set_Prop`

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.