dotnet / dotnet/arcade

RefSource generator generates setter instead of `init`

Open
#14,859 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
729
Forks
397
Avg merge
3d 15m
Merged PRs (30d)
149

Description

- [ ] This issue is blocking
- [ ] This issue is causing unreasonable pain

Generated Ref source from System.Net.Quic src for the new API in https://github.com/dotnet/runtime/issues/101534 (using `dotnet msbuild /t:GenerateReferenceAssemblySource`).
Source:
```C#
public readonly struct QuicStreamCapacityChangedArgs
{
public int BidirectionalIncrement { get; init; }
public int UnidirectionalIncrement { get; init; }
}
```

Generated Ref:
```C#
public readonly partial struct QuicStreamCapacityChangedArgs
{
private readonly int _dummyPrimitive;
public int BidirectionalIncrement { get { throw null; } set { } }
public int UnidirectionalIncrement { get { throw null; } set { } }
}
```

Expected Ref:
```C#
public readonly partial struct QuicStreamCapacityChangedArgs
{
public int BidirectionalIncrement { get { throw null; } init { } }
public int UnidirectionalIncrement { get { throw null; } init { } }
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the GenerateReferenceAssemblySource target invoked by `dotnet msbuild /t:GenerateReferenceAssemblySource`, using the System.Net.Quic example and the source and generated Ref snippets as the reproduction. Done means generated properties preserve `init` accessors instead of emitting setters, matching the expected Ref output.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.