如何找到在循环中使用Stackalloc的位置? (故障排除CA2014和代码分析仪)
microsot.scodeanalysis.charp.Netanalyzers告诉我
CA2014请勿在循环中使用Stackalloc
带有黄色三角图标的环中使用stackalloc。
我如何找到项目中的什么代码? 我构建时没有错误,警告或消息。
我在文档中发现了一些东西在这里以及代码分析师< /a>
我的项目开始,就像
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<AnalysisLevel>latest-recommended</AnalysisLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
我在vs 2022 17.1.5中,
包括 docs >
我已经搜索了“ Stackalloc”的代码,但我不使用它。
Microsot.CodeAnalysis.Charp.NetAnalyzers tells me
CA2014 Do not use stackalloc in loops
with the yellow triangle icon.
How do I find what code in my project is doing this?
There are no errors or warnings or messages when I build.
I found something in the docs here and some information on code analysers
My projects starts like
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<AnalysisLevel>latest-recommended</AnalysisLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
I am on VS 2022 17.1.5
There is some more information in the error properties
Including a link to docs
I have searched my code for "stackalloc" but I am not using it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚打开了另一个看起来更像您的项目。当我尝试调查时,我发现了可能的混乱:规则旁边的图标(信息,警告,错误) 不是意味着该规则中存在错误或警告,但规则级别分别设置为警告或错误(您可以通过右键单击规则来更改此操作)。如果您在哪里介绍一些会触发该警告的代码,则应在编译错误列表中看到它。
I just opened another of my projects which looks more like yours. When I tried to investigate, I found the possible confusion: The icon next to the rule (info, warning, error) does not mean that there are errors or warnings from that rule, but that the rule level is set to warning or error respectively (you can change this by right-clicking on the rule). If you where to introduce some code that would trigger that warning, you should see it in the list of the compilation errors.