c# - Is the record "with" operator supported in CSharpScript?
问题描述
I am trying to execute the following bit of code in CSharpScript:
var script = @"
public record MyRecord{public int I{get;init;}}
var instance = new MyRecord();
instance with {I = 2}";
var result = await CSharpScript.EvaluateAsync(script);
This script does not compile:
(4,16): error CS1014: A get or set accessor expected
When introducing a variable in between it works:
var script = @"
public record MyRecord{public int I{get;init;}}
var instance = new MyRecord();
var newInstance = instance with {I = 2};
newInstance";
var result = await CSharpScript.EvaluateAsync(script);
Is this a bug or is the with operator not properly supported in CsharpScript? Any hint on how to circumvent this?
解决方案
推荐阅读
- go - Is GoLang safe to use partial cache restoration with CircleCI?
- c# - How to use class from DLL referenced by referenced DLL
- python - 403 forbidden when using OpenGraph Django
- spring-boot - 如何在@WebFluxTest 中禁用 oauth2 客户端注册?
- php - Getting maximum values from table through inner join not producing fully output
- c# - Kafka c#:自定义分区器和分配器实现
- c# - .Include 表达式不一致的EntityFramework
- spring-boot - Spring Boot Rest 模板编码
- python - 如何检查数据帧的三列值是否小于另一个标准数据帧的同时值?
- css - Intersection Observer - 如何循环或重新启动动画?