Exercise 2: Suppressing Code Analysis Warnings
来源:互联网 发布:服务器数据丢失 编辑:程序博客网 时间:2024/05/29 19:01
In this exercise, you will learn how to suppress Code Analysis warnings at the project and source level.
- In the Error List window, select the first three warnings that appear which are associated with the project. Note that they are not associated with a file by looking in the File column. Imagine that we do not want to address the selected issues and no longer want them to appear when Code Analysis executes.
- Right-click on the selected warnings and select Supress Message(s) | In Project Suppression File from the context menu that appears. This will add assembly level metadata to a project level GlobalSuppressions.cs file.Figure 1
Suppressing specific code analysis rules at the project level
- Open the GlobalSuppressions.cs file to view the added code.Figure 2
Suppressed rules are crossed out and GlobalSuppressions.cs changes
- Take a look at the next Code Analysis warning that is listed, CA1726, which suggests changing the type name ‘Cancelled’ with the preferred alternate ‘Canceled’.Double-click on it to go to the correct source location for the fix.
- Right-click on the class name ‘Cancelled’ and select Refactor | Rename… from the context menu that appears.Figure 3
Renaming class to fix spelling
- In the Rename window, change ‘Cancelled’ to ‘Canceled’ and select the OK button to continue.
- In the Preview Changes – Rename window, review the proposed changes and select theApply button to complete the refactoring process.
- Move on to the next Code Analysis warning by selecting it. Imagine that we want to suppress this specific rule, but this time we only want applied to this particular source file. Right-click on the warning and selectSuppress Message(s) | In Source from the context menu that appears. This applies aSuppressMessage attribute to the delegate for which the Code Analysis rule was identifying.Figure 4
Suppressing a Code Analysis rule at the source code level
- Select Analyze | Run Code Analysis on Tailspin.Model from the main menu and verify that more of the warnings have been successfully addressed.
- At this point, there are additional Code Analysis warnings that we could address, but imagine that we simply want to ignore the remaining items for now. Return to theCode Analysis section of the project properties and select the ‘Microsoft Minimum Recommended Rules’ option.
- Select Analyze | Run Code Analysis on Tailspin.Model from the main menu and verify that the number of warnings has dramatically been reduced. The warnings that appear as the result of using this rule set are more likely to be problematic during runtime.
- Exercise 2: Suppressing Code Analysis Warnings
- Code Analysis for Managed Code Warnings
- Exercise 1: Introduction to Code Analysis
- C# 警告错误问题处理笔记整理(Code Analysis for Managed Code Warnings)
- Code Exercise
- code analysis
- complete exercise source code
- 2 Perl - Warnings
- Stanford UFLDL教程 Exercise:Independent Component Analysis
- static code analysis
- Caffe Code Analysis-3
- static code analysis
- caffe source code analysis
- UserGroupInformation Source Code Analysis
- code forces Harmony Analysis
- Code analysis of Hadoop v0.1.0 (2) conf package
- CSAPP3e - x86-64 assembly code analysis - Bomb Lab: phase 2
- spark 1.6.2 spark-shell source code analysis
- Negative margin参考网站
- 基于jquery的html 选中一行
- window 下配置Apache FTPServer
- hadoop作业执行流程及代码简略解读之二JobClient
- spring学习笔记一
- Exercise 2: Suppressing Code Analysis Warnings
- oracle安装完成后WEB配置页面
- Linux Shell
- hadoop作业执行流程及代码简略解读之三JobTracker
- 配置scope为prototype,使得每一次获取的都是新的
- thinkphp开发,表里增加记录后 左侧菜单不显示
- Linux下X Server工作方式
- hadoop作业执行流程及代码简略解读之四TaskTracker
- 随想录(程序员的缺点) .