Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Roslyn Cookbook
Roslyn Cookbook

Roslyn Cookbook: Compiler as a Service, Code Analysis, Code Quality and more

Arrow left icon
Profile Icon Manish Vasani
Arrow right icon
£7.99 £29.99
eBook Jul 2017 350 pages 1st Edition
eBook
£7.99 £29.99
Paperback
£36.99
Subscription
Free Trial
Renews at £16.99p/m
Arrow left icon
Profile Icon Manish Vasani
Arrow right icon
£7.99 £29.99
eBook Jul 2017 350 pages 1st Edition
eBook
£7.99 £29.99
Paperback
£36.99
Subscription
Free Trial
Renews at £16.99p/m
eBook
£7.99 £29.99
Paperback
£36.99
Subscription
Free Trial
Renews at £16.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Roslyn Cookbook

Consuming Diagnostic Analyzers in .NET Projects

In the previous chapter, we showed you how to write diagnostic analyzers to analyze and report issues about the .NET source code and contribute them to the .NET developer community. In this chapter, we will show you how to search, install, view, and configure the analyzers that have already been published by various analyzer authors on NuGet and the VS extension gallery. We will cover the following recipes:

  • Searching and installing analyzers through the NuGet package manager
  • Searching and installing VSIX analyzers through the VS extension gallery
  • Viewing and configuring analyzers in the solution explorer in Visual Studio
  • Using the ruleset file and Rule Set editor to configure analyzers

Introduction

Diagnostic analyzers are extensions to the Roslyn C# compiler and Visual Studio IDE to analyze user code and report diagnostics. The user will see these diagnostics in the error list after building the project from Visual Studio and even when building the project on the command line. They will also see the diagnostics live while editing the source code in the Visual Studio IDE. Analyzers can report diagnostics to enforce specific code styles, improve code quality and maintenance, recommend design guidelines, or even report very domain-specific issues, which cannot be covered by the core compiler.

Analyzers can be installed in a .NET project either as a NuGet package or as a VSIX. To get a better understanding of these packaging schemes and learn about the differences in the analyzer experience when installed as a NuGet package versus a VSIX, it is recommended that...

Searching and installing analyzers through the NuGet package manager

In this recipe, we will show you how to search and install analyzer NuGet packages in the NuGet package manager in Visual Studio, and see the analyzer diagnostics from an installed NuGet package shown in project build and as live diagnostics during code editing in Visual Studio.

Getting ready

How to do it...

...

Searching and installing VSIX analyzers through the VS extension gallery

In this recipe, we will show you how to search and install analyzer VSIX packages in the Visual Studio extension manager and see how the analyzer diagnostics from an installed VSIX light up as live diagnostics during code editing in Visual Studio.

Getting ready

How to do it...

...

Viewing and configuring analyzers in solution explorer in Visual Studio

In this recipe, we will show you how to use the Solution explorer in Visual Studio 2017 to view the different analyzers installed in a project, view the implemented analyzer rules in these assemblies, as well as the rule properties (or the descriptor metadata), and configure the rule severity and persist the new severity settings.

Getting ready

You will need to have created and opened a .NET project in Visual Studio 2017 with NuGet-based analyzers installed in the project. Refer to the first recipe in this chapter for installing analyzers in a .NET project.

...

Using the ruleset file and Rule Set editor to configure analyzers

In this recipe, we will show you how to use the ruleset file and the Rule Set editor in Visual Studio to configure the per-project severity of analyzer rules, and illustrate how the severity changes are reflected in the live diagnostics in Visual Studio, as well as command-line builds.

Getting ready

You will need to have created and opened a .NET project in Visual Studio 2017 with NuGet-based analyzers installed in the project. Refer to the first recipe in this chapter for installing analyzers in a .NET project.

How to do it...

...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • 1. Use Roslyn extensions and tools in Visual Studio to enforce "house rules" on code and fix security and performance vulnerabilities in your code.
  • 2. Write Roslyn extensions using the Roslyn service API to help developers enforce conventions and design idioms.
  • 3. Improve developer productivity by using Roslyn-based agile development features in Visual Studio, such as live unit testing, C# interactive and scripting.
  • 4. Contribute to the C# language and compiler tool chain to analyze and edit code.

Description

Open-sourcing the C# and Visual Basic compilers is one of the most appreciated things by the .NET community, especially as it exposes rich code analysis APIs to analyze and edit code. If you want to use Roslyn API to write powerful extensions and contribute to the C# developer tool chain, then this book is for you. Additionally, if you are just a .NET developer and want to use this rich Roslyn-based functionality in Visual Studio to improve the code quality and maintenance of your code base, then this book is also for you. This book is divided into the following broad modules: 1. Writing and consuming analyzers/fixers (Chapters 1 - 5): You will learn to write different categories of Roslyn analyzers and harness and configure analyzers in your C# projects to catch quality, security and performance issues. Moving ahead, you will learn how to improve code maintenance and readability by using code fixes and refactorings and also learn how to write them. 2. Using Roslyn-based agile development features (Chapters 6 and 7): You will learn how to improve developer productivity in Visual Studio by using features such as live unit testing, C# interactive and scripting. 3. Contributing to the C# language and compiler tool chain (Chapters 8 - 10): You will see the power of open-sourcing the Roslyn compiler via the simple steps this book provides; thus, you will contribute a completely new C# language feature and implement it in the Roslyn compiler codebase. Finally, you will write simple command line tools based on the Roslyn service API to analyze and edit C# code.

Who is this book for?

.NET Developers and architects, who are interested in taking full advantage of the Roslyn based extensions and tools to improve the development processes, will find this book useful. Roslyn contributors, i.e. the producers and C# community developers, will also find this book useful

What you will learn

  • • Write extensions to analyze source code and report warnings and errors.
  • • Edit C# source code to fix compiler/analyzer diagnostics or refactor source code.
  • • Improve code maintenance and readability by using analyzers and code fixes.
  • • Catch security and performance issues by using PUMA scan analyzers and FxCop analyzers.
  • • Perform Live Unit tests in Visual Studio.
  • • Use C# interactive and scripting in Visual Studio.
  • • Design a new C# language feature and implement various compiler phases for a new language feature.
  • • Write command line tools to analyze and edit C# code.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 31, 2017
Length: 350 pages
Edition : 1st
Language : English
ISBN-13 : 9781787288522
Vendor :
Microsoft
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jul 31, 2017
Length: 350 pages
Edition : 1st
Language : English
ISBN-13 : 9781787288522
Vendor :
Microsoft
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
£16.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
£169.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just £5 each
Feature tick icon Exclusive print discounts
£234.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just £5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total £ 138.97
Roslyn Cookbook
£36.99
C# 7.1 and .NET Core 2.0 ??? Modern Cross-Platform Development
£59.99
ASP.NET Core 2 High Performance
£41.99
Total £ 138.97 Stars icon
Banner background image

Table of Contents

10 Chapters
Writing Diagnostic Analyzers Chevron down icon Chevron up icon
Consuming Diagnostic Analyzers in .NET Projects Chevron down icon Chevron up icon
Writing IDE Code Fixes, Refactorings, and Intellisense Completion Providers Chevron down icon Chevron up icon
Improving Code Maintenance of C# Code Base Chevron down icon Chevron up icon
Catch Security Vulnerabilities and Performance Issues in C# Code Chevron down icon Chevron up icon
Live Unit Testing in Visual Studio Enterprise Chevron down icon Chevron up icon
C# Interactive and Scripting Chevron down icon Chevron up icon
Contribute Simple Functionality to Roslyn C# Compiler Open Source Code Chevron down icon Chevron up icon
Design and Implement a New C# Language Feature Chevron down icon Chevron up icon
Command-Line Tools Based on Roslyn API Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.