1 |
MetaAnalyzer001 |
Missing diagnostic id |
Tutorial |
True |
True |
The diagnostic id identifies a particular diagnostic so that the diagnotic can be fixed in CodeFixProvider.cs |
2 |
MetaAnalyzer002 |
Missing Initialize method |
Tutorial |
True |
True |
An analyzer requires the Initialize method to register code analysis actions. Actions are registered to call an analysis method when something specific changes in the syntax tree or semantic model. For example, context.RegisterSyntaxNodeAction(AnalyzeMethod, SyntaxKind.IfStatement) will call AnalyzeMethod every time an if-statement changes in the syntax tree. |
3 |
MetaAnalyzer003 |
Missing register statement |
Tutorial |
True |
True |
The Initialize method must register for at least one action so that some analysis can be performed. Otherwise, analysis will not be performed and no diagnostics will be reported. Registering a syntax node action is useful for analyzing the syntax of a piece of code. |
4 |
MetaAnalyzer004 |
Multiple registered actions |
Tutorial |
True |
True |
For this tutorial only, the Initialize method should only register one action. More complicated analyzers may need to register multiple actions. |
5 |
MetaAnalyzer005 |
Incorrect method signature |
Tutorial |
True |
True |
The Initialize method should override the abstract Initialize class member from the DiagnosticAnalyzer class. It therefore needs to be public, overriden, and return void. It needs to have a single input parameter of type 'AnalysisContext.' |
6 |
MetaAnalyzer006 |
Incorrect statement |
Tutorial |
True |
True |
By definition, the purpose of the Initialize method is to register actions for analysis. Therefore, all other statements placed in Initialize are incorrect. |
7 |
MetaAnalyzer007 |
Missing SupportedDiagnostics property |
Tutorial |
True |
True |
The SupportedDiagnostics property tells the analyzer which diagnostic ids the analyzer supports, in other words, which DiagnosticDescriptors might be reported by the analyzer. Generally, any DiagnosticDescriptor should be returned by SupportedDiagnostics. |
8 |
MetaAnalyzer008 |
Incorrect SupportedDiagnostics property |
Tutorial |
True |
True |
T: The overriden SupportedDiagnostics property should return an Immutable Array of Diagnostic Descriptors |
9 |
MetaAnalyzer009 |
Missing get-accessor |
Tutorial |
True |
True |
The SupportedDiagnostics property needs to have a get-accessor to make the ImmutableArray of DiagnosticDescriptors accessible |
10 |
MetaAnalyzer010 |
Too many accessors |
Tutorial |
True |
True |
The purpose of the SupportedDiagnostics property is to return a list of all diagnostics that can be reported by a particular analyzer, so it doesn't have a need for any other accessors |
11 |
MetaAnalyzer011 |
Get accessor missing return value |
Tutorial |
True |
True |
The purpose of the SupportedDiagnostics property's get-accessor is to return a list of all diagnostics that can be reported by a particular analyzer |
12 |
MetaAnalyzer012 |
SupportedDiagnostics return value incorrect |
Tutorial |
True |
True |
The purpose of the SupportedDiagnostics property's get-accessor is to return a list of all diagnostics that can be reported by a particular analyzer |
13 |
MetaAnalyzer013 |
ImmutableArray incorrect |
Tutorial |
True |
True |
The purpose of the SupportedDiagnostics property is to return a list of all diagnostics that can be reported by a particular analyzer, so it should include every DiagnosticDescriptor rule that is created |
14 |
MetaAnalyzer014 |
Incorrect DiagnosticDescriptor id |
Tutorial |
True |
True |
The id parameter of a DiagnosticDescriptor should be a string constant previously declared. This ensures that the diagnostic id is accessible from the CodeFixProvider.cs file. |
15 |
MetaAnalyzer015 |
Missing Diagnostic id declaration |
Tutorial |
True |
True |
The id parameter of a DiagnosticDescriptor should be a string constant previously declared. This ensures that the diagnostic id is accessible from the CodeFixProvider.cs file. |
16 |
MetaAnalyzer016 |
Incorrect defaultSeverity |
Tutorial |
True |
True |
There are four option for the severity of the diagnostic: error, warning, hidden, and info. An error is completely not allowed and causes build errors. A warning is something that might be a problem, but is not a build error. An info diagnostic is simply information and is not actually a problem. A hidden diagnostic is raised as an issue, but it is not accessible through normal means. In simple analyzers, the most common severities are error and warning. |
17 |
MetaAnalyzer017 |
Incorrect isEnabledByDefault |
Tutorial |
True |
True |
The 'isEnabledByDefault' field determines whether the diagnostic is enabled by default or the user of the analyzer has to manually enable the diagnostic. Generally, it will be set to true. |
18 |
MetaAnalyzer018 |
Incorrect DiagnosticDescriptor modifiers |
Tutorial |
True |
True |
The DiagnosticDescriptor rules should all be internal because they only need to be accessed by pieces of this project and nothing outside. They should be static because their lifetime will extend throughout the entire running of this program |
19 |
MetaAnalyzer019 |
Missing DiagnosticDescriptor |
Tutorial |
True |
True |
The DiagnosticDescriptor rule is what is reported by the analyzer when it finds a problem, so there must be at least one. It should have an id to differentiate the diagnostic, a default severity level, a boolean describing if it's enabled by default, a title, a message, and a category. |
20 |
MetaAnalyzer020 |
Missing if-statement extraction |
Tutorial |
True |
True |
The context parameter has a Node member. This Node is what the register statement from Initialize triggered on, and so should be cast to the expected syntax or symbol type |
21 |
MetaAnalyzer021 |
If-statement extraction incorrect |
Tutorial |
True |
True |
The context parameter has a Node member. This Node is what the register statement from Initialize triggered on, so it should be cast to the expected syntax or symbol type |
22 |
MetaAnalyzer022 |
Missing if-keyword extraction |
Tutorial |
True |
True |
In the syntax tree, a node of type IfStatementSyntax has an IfKeyword attached to it. On the syntax tree diagram, this is represented by the green 'if' SyntaxToken |
23 |
MetaAnalyzer023 |
Incorrect if-keyword extraction |
Tutorial |
True |
True |
In the syntax tree, a node of type IfStatementSyntax has an IfKeyword attached to it. On the syntax tree diagram, this is represented by the green 'if' SyntaxToken |
24 |
MetaAnalyzer024 |
Missing trailing trivia check |
Tutorial |
True |
True |
Syntax trivia are all the things that aren't actually code (i.e. comments, whitespace, end of line tokens, etc). The first step in checking for a single space between the if-keyword and '(' is to check if the if-keyword SyntaxToken has any trailing trivia |
25 |
MetaAnalyzer025 |
Incorrect trailing trivia check |
Tutorial |
True |
True |
Syntax trivia are all the things that aren't actually code (i.e. comments, whitespace, end of line tokens, etc). The first step in checking for a single space between the if-keyword and '(' is to check if the if-keyword SyntaxToken has any trailing trivia |
26 |
MetaAnalyzer026 |
Missing trailing trivia extraction |
Tutorial |
True |
True |
The first trailing trivia of the if-keyword should be a single whitespace |
27 |
MetaAnalyzer027 |
Incorrect trailing trivia extraction |
Tutorial |
True |
True |
The first trailing trivia of the if-keyword should be a single whitespace |
28 |
MetaAnalyzer028 |
Missing SyntaxKind check |
Tutorial |
True |
True |
T: Next, check if the kind of '{0}' is whitespace trivia |
29 |
MetaAnalyzer029 |
Incorrect SyntaxKind check |
Tutorial |
True |
True |
T: This statement should check to see if the kind of '{0}' is whitespace trivia |
30 |
MetaAnalyzer030 |
Missing whitespace check |
Tutorial |
True |
True |
T: Next, check if '{0}' is a single whitespace, which is the desired formatting |
31 |
MetaAnalyzer031 |
Incorrect whitespace check |
Tutorial |
True |
True |
T: This statement should check to see if '{0}' is a single whitespace, which is the desired formatting |
32 |
MetaAnalyzer032 |
Missing return |
Tutorial |
True |
True |
If the analyzer determines that there are no issues with the code it is analyzing, it can simply return from the analysis method without reporting any diagnostics |
33 |
MetaAnalyzer033 |
Incorrect return |
Tutorial |
True |
True |
If the analyzer determines that there are no issues with the code it is analyzing, it can simply return from the analysis method without reporting any diagnostics |
34 |
MetaAnalyzer034 |
Missing open parenthesis variable |
Tutorial |
True |
True |
The open parenthesis of the condition is going to be the end point of the diagnostic squiggle that is created |
35 |
MetaAnalyzer035 |
Open parenthesis variable incorrect |
Tutorial |
True |
True |
The open parenthesis of the condition is going to be the end point of the diagnostic squiggle that is created |
36 |
MetaAnalyzer036 |
Start span variable missing |
Tutorial |
True |
True |
Each node in the syntax tree has a span. This span represents the number of character spaces that the node takes up |
37 |
MetaAnalyzer037 |
Start span variable incorrect |
Tutorial |
True |
True |
Each node in the syntax tree has a span. This span represents the number of character spaces that the node takes up |
38 |
MetaAnalyzer038 |
End span variable missing |
Tutorial |
True |
True |
The open parenthesis of the condition is going to be the end point of the diagnostic squiggle that is created |
39 |
MetaAnalyzer039 |
End span variable incorrect |
Tutorial |
True |
True |
Each node in the syntax tree has a span. This span represents the number of character spaces that the node takes up |
40 |
MetaAnalyzer040 |
Diagnostic span variable missing |
Tutorial |
True |
True |
Each node in the syntax tree has a span. This span represents the number of character spaces that the node takes up |
41 |
MetaAnalyzer041 |
Diagnostic span variable incorrect |
Tutorial |
True |
True |
Each node in the syntax tree has a span. This span represents the number of character spaces that the node takes up. TextSpan.FromBounds(start, end) can be used to create a span to use for a diagnostic |
42 |
MetaAnalyzer042 |
Diagnostic location variable missing |
Tutorial |
True |
True |
A location can be created by combining a span with a syntax tree. The span is applied to the given syntax tree so that the location within the syntax tree is determined |
43 |
MetaAnalyzer043 |
Diagnostic location variable incorrect |
Tutorial |
True |
True |
A location can be created by combining a span with a syntax tree. The span is applied to the given syntax tree so that the location within the syntax tree is determined |
44 |
MetaAnalyzer044 |
Missing analysis method |
Tutorial |
True |
True |
In Initialize, the register statement denotes an analysis method to be called when an action is triggered. This method needs to be created |
45 |
MetaAnalyzer045 |
Too many statements |
Tutorial |
True |
False |
For the purpose of this tutorial there are too many statements here, use the code fixes to guide you through the creation of this section |
46 |
MetaAnalyzer046 |
Diagnostic variable missing |
Tutorial |
True |
True |
This is the diagnostic that will be reported to the user as an error squiggle |
47 |
MetaAnalyzer047 |
Diagnostic variable incorrect |
Tutorial |
True |
True |
The diagnostic is created with a DiagnosticDescriptor, a Location, and message arguments. The message arguments are the inputs to the DiagnosticDescriptor MessageFormat format string |
48 |
MetaAnalyzer048 |
Diagnostic report missing |
Tutorial |
True |
True |
A diagnostic is reported to a context so that the diagnostic will appear as a squiggle and in the eroor list |
49 |
MetaAnalyzer049 |
Diagnostic report incorrect |
Tutorial |
True |
True |
A diagnostic is reported to a context so that the diagnostic will appear as a squiggle and in the eroor list |
50 |
MetaAnalyzer050 |
Analyzer tutorial complete |
Tutorial |
True |
False |
T: Congratulations! You have written an analyzer! If you would like to explore a code fix for your diagnostic, open up CodeFixProvider.cs and take a look! To see your analyzer in action, press F5. A new instance of Visual Studio will open up, in which you can open a new C# console app and write test if-statements. |
51 |
MetaAnalyzer051 |
Incorrect kind |
Tutorial |
True |
True |
For the purposes of this tutorial, the only analysis will occur on an if-statement, so it is only necessary to register for syntax of kind IfStatement |
52 |
MetaAnalyzer052 |
Incorrect register |
Tutorial |
True |
True |
For the purposes of this tutorial, analysis will occur on SyntaxNodes, so only actions on SyntaxNodes should be registered |
53 |
MetaAnalyzer053 |
Incorrect arguments |
Tutorial |
True |
True |
The RegisterSyntaxNodeAction method takes two arguments. The first argument is a method that will be called to perform the analysis. The second argument is a SyntaxKind, which is the kind of syntax that the method will be triggered on |
54 |
MetaAnalyzer054 |
Incorrect analysis method accessibility |
Tutorial |
True |
True |
T: The '{0}' method should be private |
55 |
MetaAnalyzer055 |
Incorrect analysis method return type |
Tutorial |
True |
True |
T: The '{0}' method should have a void return type |
56 |
MetaAnalyzer056 |
Incorrect parameter to analysis method |
Tutorial |
True |
True |
T: The '{0}' method should take one parameter of type SyntaxNodeAnalysisContext |
57 |
MetaAnalyzer057 |
Trailing trivia count missing |
Tutorial |
True |
True |
T: Next, check that '{0}' only has one trailing trivia element |
58 |
MetaAnalyzer058 |
Trailing trivia count incorrect |
Tutorial |
True |
True |
T: This statement should check that '{0}' only has one trailing trivia element |
59 |
MetaAnalyzer059 |
ID string literal |
Tutorial |
True |
True |
T: The ID should not be a string literal, because the ID must be accessible from the code fix provider |
60 |
MetaAnalyzer060 |
Change default title |
Tutorial |
True |
True |
T: Please change the title to a string of your choosing |
61 |
MetaAnalyzer061 |
Change default message |
Tutorial |
True |
True |
T: Please change the default message to a string of your choosing |
62 |
MetaAnalyzer062 |
Change default category |
Tutorial |
True |
True |
T: Please change the category to a string of your choosing |