How to do it...

  1. Expand the PurchaseOrderAnalyzer (Portable) project and open the DiagnosticAnalyzer.cs file.
  1. As seen earlier, you will see your diagnostic analyzer class. It should read public class PurchaseOrderAnalyzerAnalyzer : DiagnosticAnalyzer. Add the following code to the top of this class, replacing the code for the DiagnosticId, Title, MessageFormat, Description, Category, and Rule variables. Note that I have added two enumerators called ClassTypesToCheck and MandatoryInterfaces to the class. I only want this analyzer to act on a class if it is called PurchaseOrder or SalesOrder. I also only want the IReceiptable interface to ...

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.