public static bool IsEnabled( this AnalyzerOptionDescriptor analyzerOption, Document document, SyntaxToken token) { return(IsEnabled(analyzerOption, document, token.SyntaxTree)); }
public static bool IsEnabled( this AnalyzerOptionDescriptor analyzerOption, Document document, SyntaxNode node) { return(IsEnabled(analyzerOption, document, node.SyntaxTree)); }
private static Diagnostic CreateObsoleteDiagnostic(AnalyzerOptionDescriptor analyzerOption, Location location) { return(Diagnostic.Create( descriptor: CommonDiagnosticRules.AnalyzerIsObsolete, location: location, $"option '{analyzerOption.Descriptor.Id}'", $" Use EditorConfig option '{analyzerOption.OptionKey} = true' instead.")); }
private static void ReportObsolete( SymbolAnalysisContext context, Location location, AnalyzerOptionDescriptor analyzerOption) { if (analyzerOption.Descriptor?.IsEffective(context.Compilation) == true) { ReportDiagnostic(context, CreateObsoleteDiagnostic(analyzerOption, location)); } }
public static bool IsEnabled( this AnalyzerOptionDescriptor analyzerOption, SymbolAnalysisContext context) { return(IsEnabled( analyzerOption, context.Symbol.Locations[0].SourceTree, context.Compilation.Options, context.Options)); }
public static void ReportObsolete( SyntaxNodeAnalysisContext context, SyntaxNode node, AnalyzerOptionDescriptor analyzerOption) { if (analyzerOption.Descriptor?.IsEffective(context.Compilation) == true) { ReportDiagnostic(context, CreateObsoleteDiagnostic(analyzerOption, node.GetLocation())); } }
public static int GetInt32Value( this AnalyzerOptionDescriptor analyzerOption, SyntaxTree syntaxTree, AnalyzerOptions analyzerOptions, int defaultValue) { return((TryGetInt32Value(analyzerOption, syntaxTree, analyzerOptions, out int result)) ? result : defaultValue); }
public static bool IsEnabled( this AnalyzerOptionDescriptor analyzerOption, SyntaxNodeAnalysisContext context) { return(IsEnabled( analyzerOption, context.Node.SyntaxTree, context.Compilation.Options, context.Options)); }
public static bool IsEnabled( this AnalyzerOptionDescriptor analyzerOption, Document document, SyntaxTree syntaxTree) { return(analyzerOption.Parent.IsEffective(syntaxTree, document.Project.CompilationOptions) && analyzerOption.IsEnabled( syntaxTree, document.Project.CompilationOptions, document.Project.AnalyzerOptions)); }
public static void ReportDiagnostic( SymbolAnalysisContext context, DiagnosticDescriptor descriptor, Location location, AnalyzerOptionDescriptor obsoleteAnalyzerOption, params object[] messageArgs) { ReportDiagnostic(context, descriptor, location, messageArgs); ReportObsolete(context, location, obsoleteAnalyzerOption); }
public static void ReportDiagnostic( SyntaxNodeAnalysisContext context, DiagnosticDescriptor descriptor, Location location, ImmutableDictionary <string, string> properties, AnalyzerOptionDescriptor obsoleteAnalyzerOption, params object[] messageArgs) { ReportDiagnostic(context, descriptor, location, properties, messageArgs); ReportObsolete(context, location, obsoleteAnalyzerOption); }
public static void ReportDiagnostic( SyntaxNodeAnalysisContext context, DiagnosticDescriptor descriptor, SyntaxNode node, AnalyzerOptionDescriptor obsoleteAnalyzerOption, params object[] messageArgs) { ReportDiagnostic( context: context, descriptor: descriptor, location: node.GetLocation(), obsoleteAnalyzerOption, messageArgs: messageArgs); }
public static bool?IsEnabled( this AnalyzerOptionDescriptor analyzerOption, SyntaxTree syntaxTree, CompilationOptions compilationOptions, AnalyzerOptions analyzerOptions, bool checkParent) { if (checkParent && !analyzerOption.Parent.IsEffective(syntaxTree, compilationOptions)) { return(null); } return(IsEnabled(analyzerOption, syntaxTree, compilationOptions, analyzerOptions)); }
public static bool TryGetInt32Value( this AnalyzerOptionDescriptor analyzerOption, SyntaxTree syntaxTree, AnalyzerOptions analyzerOptions, out int result) { if (analyzerOptions .AnalyzerConfigOptionsProvider .GetOptions(syntaxTree) .TryGetValue(analyzerOption.OptionKey, out string textValue) && int.TryParse(textValue, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.CurrentCulture, out int value)) { result = value; return(true); } result = default; return(false); }
public static bool IsEnabled( this AnalyzerOptionDescriptor analyzerOption, SyntaxTree syntaxTree, CompilationOptions compilationOptions, AnalyzerOptions analyzerOptions) { if (analyzerOptions .AnalyzerConfigOptionsProvider .GetOptions(syntaxTree) .TryGetValue(analyzerOption.OptionKey, out string value) && bool.TryParse(value, out bool enabled) && enabled) { return(true); } if (analyzerOption.Descriptor != null && compilationOptions .SpecificDiagnosticOptions .TryGetValue(analyzerOption.Descriptor.Id, out ReportDiagnostic reportDiagnostic)) { switch (reportDiagnostic) { case ReportDiagnostic.Default: case ReportDiagnostic.Suppress: return(false); case ReportDiagnostic.Error: case ReportDiagnostic.Warn: case ReportDiagnostic.Info: case ReportDiagnostic.Hidden: return(true); default: throw new InvalidOperationException(); } } return(false); }