配置位置
通常在 .csproj 项目文件中:
<PropertyGroup>
<WarningsAsErrors>$(WarningsAsErrors);CA1835</WarningsAsErrors>
</PropertyGroup>
CA1835
<WarningsAsErrors>$(WarningsAsErrors);CA1835</WarningsAsErrors>
触发警告的代码(旧方式):
// 这会触发 CA1835 警告
byte[] buffer = new byte[1024];
await stream.ReadAsync(buffer, 0, buffer.Length);
推荐的代码(新方式):
// 推荐的使用 Memory<T> 的方式
byte[] buffer = new byte[1024];
await stream.ReadAsync(buffer.AsMemory(0, buffer.Length));
737

被折叠的 条评论
为什么被折叠?



