dotnet/roslyn

With Operator not properly supported in C# Script

Offen

#53.670 geöffnet am 25.05.2021

 (7 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-InteractiveConcept-Continuous Improvementhelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

Version Used: 3.9.0

Steps to Reproduce: Execute the following script: var script = @" public record MyRecord{public int I{get;set;}} var instance = new MyRecord(); instance with {I = 2}"; await CSharpScript.EvaluateAsync(script)

Expected Behavior: Script should compile without problems.

Actual Behavior: Compilation error: (4,16): error CS1014: A get or set accessor expected

With parenthesis it works:

var script = @" public record MyRecord{public int I{get;set;}} var instance = new MyRecord(); (instance with {I = 2})"; await CSharpScript.EvaluateAsync(script)

The situation is even worse when trying to use records as fluent API: await (builder with {OptionA = 1}).ExecuteAsync(), cannot be made to work at all, no matter with which parenthesis used.

Contributor Guide