Learn how the most powerful features of Visual Studio 2015 - diagnostic analyzers, code fixes, and refactorings - let you automate code quality issues. You’ll learn how to find, understand, and create analyzers so you can get back to real work.
Visual Studio 2015 leverages the power of Roslyn to add powerful new diagnostic features: diagnostic analyzers, code fixes, and refactorings. This course begins by teaching you how to find and install analyzers for individual projects or your machine. It then teaches you how to understand existing analyzers and build new ones. The power lies in writing or tweaking analyzers so they align with your team. This lets you switch effort from mundane code quality issue to building applications.
Using Diagnostic Analyzers I'm Kathleen Dollard and this course teaches you how to use and create diagnostic analyzers, code fixes, and refactorings. Diagnostic analyzers will change the way you code because they smoothly integrate best practices and team guidelines into everyday coding. If you break your own rules, you'll see it as a familiar underline along with an explanation on hover an error, warning, or informational messages in the compiler's errors pane. Automatic fixes are provided via the new light bulb marker and the code fix suggestions even provide a preview of the proposed changes. I designed this course to answer your questions about diagnostic analyzers, code fixes, and refactorings. These are new features in Visual Studio 2015 and this course was created using late community technology previews and the release candidates. This means a few things early in the course change slightly by the end and I'll create a new course as soon as the Visual Studio 2015 final version is released. In this module, you'll get a basic understanding of analyzers. I'll show you how to find analyzers, install and use them, and how to suppress individual analyzers of a set and to suppress a specific analyzer at a specific location. I'll also include a clip that contains definitions used in the rest of the course. In later modules, you'll learn how easy they are to build, how to test them, how to use them for more challenging problems, and guidelines for their use.
Create a Code Fix Using Test Driven Development (TDD) I'm Kathleen Dollard and you're watching my course Diagnostic Analyzers in Visual Studio 2015. In this module, you'll learn a good approach to the process of creating analyzers, how to leverage TDD in creating analyzers, and how to build code fixes. As you've seen, running analyzers to debug them is a pain because it requires starting a new instance of Visual Studio and waiting for both your analyzer and the code you're going to analyze to open up. That's sufficiently painful that I did video editing tricks to cut that waiting time in most of the last module. TDD, Test Driven Development, is by far the best strategy for analyzers, code fixes, and refactorings. The reason I delay teaching you about code fixes is so I could do that with the aide of TDD. In this module, I'll build on the test infrastructure you saw in the last module to create a pattern, a process for planning and testing your analyzers. Then I'll use this approach to build interesting analyzers with code fixes.
Multiple Code Fixes with Real-world Infrastructure and Testing I'm Kathleen Dollard and welcome back to my course Diagnostic Analyzers in Visual Studio 2015. In this module, I'll begin building a solution that combines several diagnostic analyzers and code fixes. I think this is what you'll do, create analyzers, or find Open Source ones close to what you want and then test and tweak them a bit for your team. The analyzer in this module will provide several alternative code fixes that can be automated for a particular pattern. In the next modules, I'll add more analyzers to this project. Providing multiple code fixes is easy. Testing them is a little harder, but the testing challenge of managing many source variations, which I do with separate files, inspired a test infrastructure layer, which makes testing future analyzers and code fixes nearly trivial, well, nearly trivial after you create all that sample source files. You'll see how to use that in this module. I'll show all this with an analyzer that finds EmptyCatch blocks. EmptyCatch blocks swallow all exceptions and they are generally a very bad idea. This is another variation of a Code Cracker analyzer.
Creating More Complex Diagnostics I'm Kathleen Dollard and you're watching my Pluralsight course, Diagnostic Analyzers in Visual Studio 2015. This module builds on the infrastructure of the last module to add two more analyzers and code fixes to the project. Previous analyzers in this course have relied on the syntax tree. The first analyzer in this module introduces analysis with the semantic model, specifically analyzing based on symbols. I'll do this with an analyzer that checks that your attribute classes are all sealed. The second analyzer introduces compiler services that you can use in analyzers. In this case, analyzing how local variables are used with a dataflow analysis service. I'll do this with an analyzer that checks for local variables that could be constants. Throughout this module, you'll see additional helper methods that make creating your analyzers easy and the code readable. Analyzers are like any other code breaking complex processes down with well-named methods makes your code easy to read and generalizing those methods where appropriate allows reuse.
Other Diagnostics I'm Kathleen Dollard and welcome back to my Pluralsight course, Diagnostic Analyzers in Visual Studio 2015. In this module, you'll learn about other registration methods for analyzers and when you should use them. I'll cover how to target a particular language version like the new C# 6 features and I'll also show how to create refactorings.
Final Details I'm Kathleen Dollard and this is the last module of my course, Diagnostic Analyzers in Visual Studio 2015. In this module, I'll cover some really important details like execution order, concurrency, and performance. I'll also talk about localization and why you might not want to localize your analyzer, code fixes, and refactoring. I'll talk about deployment. It's not entirely taken care of for you in the templates. And I'll offer some guidelines for creating great analyzers.