fxcop

What is the static analysis rule to warn about unused using statements?

落花浮王杯 提交于 2021-02-09 07:16:21
问题 Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file? 回答1: You can enable the rule IDE0005 C# Using directive is unnecessary. in the category Style . 回答2: In addition to Udo's answer and this answer, I also needed to uncheck Suppress results from generated code (managed only) which can be found under Properties > Code Analyses . So all in all: Set the Warning Level to 4 for code analyzers to fire. Set rules CS8019

What is the static analysis rule to warn about unused using statements?

强颜欢笑 提交于 2021-02-09 07:13:24
问题 Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file? 回答1: You can enable the rule IDE0005 C# Using directive is unnecessary. in the category Style . 回答2: In addition to Udo's answer and this answer, I also needed to uncheck Suppress results from generated code (managed only) which can be found under Properties > Code Analyses . So all in all: Set the Warning Level to 4 for code analyzers to fire. Set rules CS8019

What is the static analysis rule to warn about unused using statements?

时光毁灭记忆、已成空白 提交于 2021-02-09 07:13:22
问题 Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file? 回答1: You can enable the rule IDE0005 C# Using directive is unnecessary. in the category Style . 回答2: In addition to Udo's answer and this answer, I also needed to uncheck Suppress results from generated code (managed only) which can be found under Properties > Code Analyses . So all in all: Set the Warning Level to 4 for code analyzers to fire. Set rules CS8019

What is the static analysis rule to warn about unused using statements?

北城余情 提交于 2021-02-09 07:10:59
问题 Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file? 回答1: You can enable the rule IDE0005 C# Using directive is unnecessary. in the category Style . 回答2: In addition to Udo's answer and this answer, I also needed to uncheck Suppress results from generated code (managed only) which can be found under Properties > Code Analyses . So all in all: Set the Warning Level to 4 for code analyzers to fire. Set rules CS8019

Suppress .codeanalysislog.xml and .lastcodeanalysisuccceeded files from getting dropped

做~自己de王妃 提交于 2021-02-07 18:17:46
问题 Is there a way I can suppress .codeanalysislog.xml and .lastcodeanalysisuccceeded from getting dropped in my output directory on build? 回答1: I agree, the bin folder is bad place for these FxCop files. However suppressing these files from getting generated, or deleting them unconditionally after the build is not the best decision. First, removing .lastcodeanalysissucceededd will cause code analysis re-run even when nothing has changed. Second, removing .CodeAnalysisLog.xml will make it almost

Code Analysis Warning CA2213 - Call Dispose() on IDisposable backing field

馋奶兔 提交于 2021-02-07 11:18:23
问题 Wanted to post this, even though I figured it out as I was writing the question. Will post answer below. Getting the following warning with VS Code Analysis: Warning CA2213 'DBConn' contains field 'DBConn.k__BackingField' that is of IDisposable type: 'SqlConnection'. Change the Dispose method on 'DBConn' to call Dispose or Close on this field. But my code does call Dispose() on the DBConn property. Does it not on the backing field? I have other instances like this - where I am disposing of

Static code analysis not working for custom ruleset

本小妞迷上赌 提交于 2021-01-07 06:37:44
问题 We are trying to have our own custom ruleset which we can apply during build process. For this I've created custom rule and custom ruleset but analysis doesn't work however I've tested the rule using Debug--> Start External program and it produced correct xml Already placed rule dll and ruleset inside fxcop rule and ruleset folder Rule XML <?xml version="1.0" encoding="utf-8" ?> <Rules> <Rule TypeName="CustomRule" Category="Performance" CheckId="R001" > <Name>AvoidUsingVirtualMethods</Name>

Static code analysis not working for custom ruleset

痞子三分冷 提交于 2021-01-07 06:33:22
问题 We are trying to have our own custom ruleset which we can apply during build process. For this I've created custom rule and custom ruleset but analysis doesn't work however I've tested the rule using Debug--> Start External program and it produced correct xml Already placed rule dll and ruleset inside fxcop rule and ruleset folder Rule XML <?xml version="1.0" encoding="utf-8" ?> <Rules> <Rule TypeName="CustomRule" Category="Performance" CheckId="R001" > <Name>AvoidUsingVirtualMethods</Name>