Skip to content

Instantly share code, notes, and snippets.

@bogdanbujdea
Created April 4, 2018 08:49
Show Gist options
  • Select an option

  • Save bogdanbujdea/8f0cd15b2dd0a20eb59b3ae7561cfdeb to your computer and use it in GitHub Desktop.

Select an option

Save bogdanbujdea/8f0cd15b2dd0a20eb59b3ae7561cfdeb to your computer and use it in GitHub Desktop.
Create diagnostic
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