In the Error List window, select the first three warnings by clicking the first, holding the Shift key, and clicking the third. In this exercise, you will learn how to suppress Code Analysis warnings at the project and source level.Ĭlear the search box in the Error List window. Task 2: Suppressing Code Analysis warnings There should be one less warning than before. Run the code analysis once again to verify that the warning disappears as expected. Resolve the warning by removing the declaration of the “var report =” variable. For CA1804, we are told that we should remove unused locals. Now we will perform the code fix necessary to resolve the warning. The Error List window contains a search box where you can filter code analysis results on warning number, text in the title or message of the warning, as well as filename or function name.ĭouble-click the result shown in the Error List window to load the specified location in the code editor. The warnings produced by Code Analysis provide a wealth of information including a unique ID (such as CA1020 in the screenshot above), a description of the problem or suggested fix, and the file location of the offending code. Note: Depending on the version of FabrikamFiber that you are running, you may see more or less results than depicted in screenshots.Ĭode Analysis rules can also be configured to show up as errors if desired. Scroll through the list of results and read a few of them. The Code Analysis feature runs through static code analysis rules as defined by Microsoft and displays the results in the Code Analysis window. In Solution Explorer, right-click the FabrikamFiber.Web project node and select Analyze | Run Code Analysis. Note: If you are interested in learning how to create custom rule sets, please see this MSDN documentation. As you can see, there are other rule sets to choose from based upon your needs. The currently selected Rule Set is Microsoft All Rules, which provides a comprehensive set of rules. Note: The Code Analysis tab allows you to choose from sets of rules rather than picking and choosing from one flat list of rules. Select the Code Analysis tab in the project properties window. In Solution Explorer, right-click the FabrikamFiber.Web project node and select Properties. Select Build | Rebuild Solution from the main menu to build the solution. All user passwords are P2ssw0rd.įrom the Start Page, click to open it. In this exercise, you will learn about the code analysis features in Visual Studio 2019 by configuring the rule set used, performing code analysis on a sample project, and addressing some of the warnings that are raised. The team, which consists of 8-10 people has decided to use Visual Studio application lifecycle management tools to manage their source code, run their builds, test their web sites, and plan and track the project.Įxercise 1: Introduction to Code Analysis In this set of hands-on labs, you will take part in a number of scenarios that involve the development and testing team at Fabrikam Fiber. They also use an on-premises ASP.NET MVC application for their customer service representatives to administer customer orders. They are growing rapidly and have embraced Windows Azure to scale their customer-facing web site directly to end-users to allow them to self-service tickets and track technicians. Fabrikam Fiber provides cable television and related services to the United States. This set of hands-on-labs uses a fictional company, Fabrikam Fiber, as a backdrop to the scenarios you are learning about. Click the button below to launch the virtual machine on the Microsoft Hands-on-Labs portal.Īlternatively, you can download the virtual machine from here. In order to complete this lab you will need the Azure DevOps Server 2019 virtual machine provided by Microsoft. In this lab, you will be introduced to Code Analysis, how to configure rules sets to use, and finally how to suppress specific rules at a project and source code level. Code Analysis can be run manually at any time from within the Visual Studio IDE, or even setup to automatically run as part of a Team Build or check-in policy for Azure DevOps Server. The Code Analysis feature of Visual Studio performs static code analysis to help developers identify potential design, globalization, interoperability, performance, security, and a host of other categories of potential problems.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |