dotnet/roslyn

EnC does not work in init accessors

オープン

#48,632 opened on 2020/10/15

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-InteractiveConcept-Continuous Improvementhelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

Version Used:

Version 16.9.0 Preview 1.0 [30614.203.main]

Steps to Reproduce:

During debugging update

class C
{
   public int F { get => 1; init /*breakpoint here*/{ } }

  public static void Main() => new C() { F = 1; }
}

to

class C
{
   public int F { get => 1; init /*breakpoit here*/{ Console.WriteLine(1); } }

  public static void Main() => new C() { F = 1; }
}

and step.

Expected Behavior:

Change applied.

Actual Behavior:

Change not applied.

It should also be possible to change set to init and vice versa if the accessor has an explicit body (i.e. the compiler does not generate backing field). The modifier of the generated backing field is different between set and init (readonly for init) - I believe the runtime does not support updating it, but we should double-check if it's true. If not we can allow changing set to init and vice versa also for auto-props.

コントリビューターガイド