|
我有一個(gè)像這樣的課: [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Io")]
public void ParaQueFalleCalidadCodigoUnoIo_ReglaCA1709()
{
}
public void ParaQueFalleCalidadCodigoDosIo_ReglaCA1709()
{
}
我使用自定義規(guī)則集文件CustomRules.ruleset <RuleSet Name="RulesNet" ToolsVersion="10.0">
<RuleHintPaths>
<Path>C:\Fxcop10.0\Rules</Path>
</RuleHintPaths>
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1709" Action="Warning" />
</Rules>
</RuleSet>
當(dāng)我運(yùn)行內(nèi)置代碼分析工具的VS2010時(shí),我收到此警告: CA1709 : Microsoft.Naming : Correct the casing of ‘Io’ in member name
‘_Default.ParaQueFalleCalidadCodigoDosIo_ReglaCA1709()’ by changing it
to ‘IO’.
現(xiàn)在,我可以在FxCopCmd.exe中使用相同的規(guī)則集文件CustomRules.ruleset: FxCopCmd.exe /gac /d:”C:\CompanyFramework\4.0.0.0″ /f:”D:\TFS\Tests\WebApplication1\bin\WebApplication1.dll” /o:”resultsFxCop.xml” /ruleset:”=CustomRules.ruleset” /v
我得到2個(gè)錯(cuò)誤(FixCategory Breaking和Level Error) CA1709 – Correct the casing of ‘Io’ in member name
‘_Default.ParaQueFalleCalidadCodigoUnoIo_ReglaCA1709()’ by changing it
to ‘IO’. CA1709 – Correct the casing of ‘Io’ in member name
‘_Default.ParaQueFalleCalidadCodigoDosIo_ReglaCA1709()’ by changing it
to ‘IO’.
<Message Id="Io" TypeName="IdentifiersShouldBeCasedCorrectly" Category="Microsoft.Naming" CheckId="CA1709" Status="Active" Created="2013-02-05 10:24:01Z" FixCategory="Breaking">
<Issue Name="Member" Certainty="85" Level="Error" Path="D:\TFS\Tests\WebApplication1" File="Default.aspx.cs" Line="21">Correct the casing of 'Io' in member name '_Default.ParaQueFalleCalidadCodigoUnoIo_ReglaCA1709()' by changing it to 'IO'.</Issue>
</Message>
<Message Id="Io" TypeName="IdentifiersShouldBeCasedCorrectly" Category="Microsoft.Naming" CheckId="CA1709" Status="Active" Created="2013-02-05 10:24:01Z" FixCategory="Breaking">
<Issue Name="Member" Certainty="85" Level="Error" Path="D:\TFS\Tests\WebApplication1" File="Default.aspx.cs" Line="26">Correct the casing of 'Io' in member name '_Default.ParaQueFalleCalidadCodigoDosIo_ReglaCA1709()' by changing it to 'IO'.</Issue>
</Message>
在resultsFxcop.xml中,我看到了CA1709:IdentifiersShouldBeCasedCorrectly規(guī)則: <Rule TypeName="IdentifiersShouldBeCasedCorrectly" Category="Microsoft.Naming" CheckId="CA1709">
<Name>Identifiers should be cased correctly</Name>
<Description>Type, namespace, and... OMITED.</Description>
<Resolution Name="Member">Correct the casing of '{0}' in member name {1} by changing it to '{2}'.</Resolution>
<Owner />
<Url>http://msdn.microsoft.com/library/ms182240(VS.100).aspx</Url>
<Email>[none]</Email>
<MessageLevel Certainty="85">Error</MessageLevel>
<File Name="namingrules.dll" Version="10.0.0.0" />
</Rule>
MessageLevel for CA1709規(guī)則: 06004
兩個(gè)問題: >我得到錯(cuò)誤,但CA1709規(guī)則行動(dòng)是警告 >使用FxCopcmd.exe忽略SuppressMessage 現(xiàn)在,我修改CustomRules.ruleset并再次執(zhí)行FxCopcmd.exe <Rule Id="CA1709" Action="None" />
我沒有錯(cuò)誤. 我修改CustomRules.ruleset并再次執(zhí)行FxCopcmd.exe <Rule Id="CA1709" Action="Ignore" />
我得到了同樣的2個(gè)錯(cuò)誤. 我需要使用FxCopCmd.exe和自定義規(guī)則集. > SuppressMessage是否適用于FxCopcmd.exe? >如果Action為Warning,使用Fxcopcmd.exe,為什么會(huì)出現(xiàn)錯(cuò)誤? > CA1709規(guī)則的MessageLevel錯(cuò)誤是什么意思?比規(guī)則行動(dòng)“警告”更優(yōu)先? 有什么建議? 更新 http://social.msdn.microsoft.com/Forums/en/vstscode/thread/3f8931da-9a4d-47a6-b331-8b6b07aea8d6 http://social.msdn.microsoft.com/forums/en-US/vstscode/thread/3cb6c50c-7095-4551-a4e3-a3cbc7cb85be 對于默認(rèn)的FxCop規(guī)則,沒有簡單的方法來修改消息級別, MessageLevel是消息的重要性,例如如果您有數(shù)千條消息,那么首先開始解決Critical(感嘆號)錯(cuò)誤可能是個(gè)好主意. 確定性是規(guī)則編寫者為每個(gè)規(guī)則分配的數(shù)字,它是消息導(dǎo)致代碼更改的可能性.此數(shù)字是根據(jù)領(lǐng)域?qū)<业姆答伣⒌?客戶以及規(guī)則中使用的啟發(fā)式方法能夠避免誤報(bào). 修復(fù)類別:這表示如果代碼先前已發(fā)送,違規(guī)的修復(fù)是否為二進(jìn)制更改.例如,您有一個(gè)拼寫錯(cuò)誤的庫,您已經(jīng)將其發(fā)送給客戶.你現(xiàn)在開始在它上面運(yùn)行FxCop并看到拼寫錯(cuò)誤. FxCop會(huì)告訴你這是一個(gè)重大改變.如果您修復(fù)了拼寫錯(cuò)誤并將新版本的庫發(fā)送給客戶,則他們無法在不更改和重新編譯代碼的情況下使用該庫.因此,您可能希望忽略此API上的FxCop違規(guī).另一方面,如果您從未發(fā)貨過,那么修復(fù)FxCop違規(guī)將完全沒問題. 解決方法: Does SuppressMessage works for FxCopcmd.exe?
是.您需要使用定義的CODE_ANALYSIS編譯符號進(jìn)行編譯,以便將SuppressMessage屬性包含在程序集中.一旦他們在那里,FxCop引擎將識別它們,無論用于運(yùn)行分析的機(jī)制如何. Why I get errors if Action is Warning, using Fxcopcmd.exe?
寫入FxCop生成的報(bào)告的問題級別始終使用規(guī)則作者指定的級別.從Visual Studio中運(yùn)行時(shí),Visual Studio集成插件會(huì)使用規(guī)則集中指定的級別覆蓋此級別.運(yùn)行fxcopcmd.exe時(shí),將規(guī)則配置為警告與錯(cuò)誤之間的唯一區(qū)別是檢測到錯(cuò)誤級別規(guī)則違規(guī)將導(dǎo)致fxcopcmd.exe返回非零退出代碼,從而允許您中斷自動(dòng)構(gòu)建. 如果您希望fxcopcmd.exe在生成報(bào)告時(shí)使用級別覆蓋,則可能需要考慮在http://visualstudio./處提出建議. 來源:https://www./content-1-266851.html
|