FAQ: How do I debug a custom rule?
来源:互联网 发布:网络信息发送 编辑:程序博客网 时间:2024/04/30 08:28
While writing your custom rule, you will likely come across a need to debug it and work out why it's behaving in a particular manner.
Debugging within FxCop
Debugging a custom rule within the FxCop UI is actually quite easy. To do so, simply:
- Open the FxCop project that contains your custom rule (making sure the PDB is alongside the assembly)
- Open the solution that contains your custom rule and set a breakpoint in the rule your want to debug
- Choose Debug -> Attach to Process
- Under Available Processes, choose FxCop.exe and click Attach
- In FxCop, choose Project -> Analyze
The debugger should break when it hits the breakpoint.
Debugging within Visual Studio or via command-line
However, if you want debug a rule that you've written for Visual Studio Code Analysis, or via the command-line, the procedure is not so obvious:
- Open a Visual Studio Command Prompt
- If debugging a custom rule written for Visual Studio, run the following:
> cd %VSINSTALLDIR%\Team Tools\Static Analysis Tools\FxCop
Otherwise, if debugging a custom rule written for FxCop, run the following:> cd %PROGRAMFILES%\Microsoft FxCop 1.35
- Run the following command, replacing [TargetAssembly] and [RuleAssembly] with the assembly you want to analyze and the assembly that contains your custom rule respectively.
> devenv /debugexe FxCopCmd.exe /file:[TargetAssembly]/rule:[RuleAssembly] /console
This will open Visual Studio in a state that is ready to debug your custom rule. Choose File -> Open -> File and browse to and open the source file that contains your custom rule
Set a breakpoint in the rule
Choose Debug -> Start Debugging
The debugger should break when it hits the breakpoint.
The Modules window is your friend
If the breakpoint is not being hit, check to make sure that you actually have symbols for your custom rule loaded:
- While debugging, choose Debug -> Windows -> Modules
To do this if you are debugging via /debugexe switch, as soon as the command window opens to start running FxCop, click PAUSE on the keyboard. - Look for your rule assembly and check under the Symbol Status column.
- If this column states anything other Symbols Loaded, then right-click on the assembly and choose Load Symbols and browse manually to the PDB.
- FAQ: How do I debug a custom rule?
- How do I register a custom filetype in iOS【链接】
- FAQ How do I write to the console from a plug-in?
- How do I debug JavaScript in Safari?
- How do I create a MEX file
- How do I configure a Virtual IP
- How do I rename a data file
- How do I add a component
- How do I rename a data file
- How do I get a preference value?
- How do I set a preference value?
- How do I develop a service?
- How do I debug UiAutomator scripts with Eclipse
- How do I debug UIAutomator scripts with Eclipse
- How do I select a random line from a file?
- How do I add a ProgressBar to a .NET StatusBar
- I want to do custom handling of special keys such as the Tab key or F2 in the TextBox of a column in the DataGrid. How do I subc
- How do I?
- How to write custom static code analysis rules and integrate them into Visual Studio 2010
- NYOJ 304 节能 -- 区间dp
- android控件之EditText输入框之值监控以及类型限制(数字,英语字母,下划线,是否为星号密码)
- FAQ: Why is file and line information available for some warnings in FxCop but not for others?
- FusionCharts控件保存图片后没有触发FC_Exported事件的解决
- FAQ: How do I debug a custom rule?
- 书斋
- 7 Steps to Write Your Own Custom Rule using FXCOP
- IIs 映射 问题
- 进程间通信之面包师问题
- 数据结构与算法之:块状链表(或者叫块状数组)
- 电商战略哪来“大师”们说的那么复杂?
- qwt安装使用教程
- C#计算发表时间为几个月,几天前,几小时前,几分钟前,或几秒前