Performing code analysis in Visual Studio
Microsoft knows that as C# and .NET changes, it can be very difficult to keep up with evolving standards in a broad and changing language.
To address this, Microsoft gave us tools beyond code metrics in the form of analyzers that inspect our C# code for issues. These analyzers look at our code and flag potential issues and optimizations. This helps ensure our code complies with standards and is secure, reliable, and maintainable.
Analyzing your solution using the default ruleset
To see an analyzer in action, build this chapter’s solution in Visual Studio and notice the three warnings that appear in the Output pane, as shown in Figure 12.4:
Figure 12.4 – An overview of the build results showing warnings
These three lines represent separate compiler warnings for the CS8618 code analysis rule, which we’ll look at shortly.
Before we do that, click on the View menu and then select Error...