Created
April 4, 2018 08:49
-
-
Save bogdanbujdea/8f0cd15b2dd0a20eb59b3ae7561cfdeb to your computer and use it in GitHub Desktop.
Create diagnostic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void AnalyzeSymbol(SymbolAnalysisContext context) | |
| { | |
| //... | |
| var members = GetMembersFromClass(classSymbol); //retrieve only methods and properties | |
| var unorderedMember = GetUnorderedMember(members); //then find the first member that is out of order | |
| if (unorderedMember != null) | |
| { | |
| var rule = new DiagnosticDescriptor(DiagnosticId, Title, $"Move {unorderedMember.Name} lower in the file", Category, | |
| DiagnosticSeverity.Error, isEnabledByDefault: true, description: Description); | |
| //now we're creating a rule that tells the user to move the member lower in the file | |
| var diagnostic = Diagnostic.Create(rule, unorderedMember.Locations[0], classSymbol); | |
| context.ReportDiagnostic(diagnostic); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment