private bool ShouldRunProviderForClosedFile(bool openedDocument, DiagnosticAnalyzer provider) { // we have opened document, doesnt matter if (openedDocument) { return(true); } return(_owner.GetDiagnosticDescriptors(provider).Any(d => d.DefaultSeverity != DiagnosticSeverity.Hidden)); }
private static bool CheckTelemetry(DiagnosticAnalyzerService service, DiagnosticAnalyzer analyzer) { if (analyzer.IsCompilerAnalyzer()) { return(true); } ImmutableArray <DiagnosticDescriptor> diagDescriptors; try { // SupportedDiagnostics is potentially user code and can throw an exception. diagDescriptors = service != null?service.GetDiagnosticDescriptors(analyzer) : analyzer.SupportedDiagnostics; } catch (Exception) { return(false); } if (diagDescriptors == null) { return(false); } // find if the first diagnostic in this analyzer allows telemetry DiagnosticDescriptor diagnostic = diagDescriptors.Length > 0 ? diagDescriptors[0] : null; return(diagnostic == null ? false : diagnostic.CustomTags.Any(t => t == WellKnownDiagnosticTags.Telemetry)); }
private void AccessSupportedDiagnostics(DiagnosticAnalyzer analyzer) { var diagnosticService = new DiagnosticAnalyzerService(LanguageNames.CSharp, analyzer); diagnosticService.GetDiagnosticDescriptors(projectOpt: null); }
private static bool CheckTelemetry(DiagnosticAnalyzerService service, DiagnosticAnalyzer analyzer) { if (analyzer.IsCompilerAnalyzer()) { return true; } ImmutableArray<DiagnosticDescriptor> diagDescriptors; try { // SupportedDiagnostics is potentially user code and can throw an exception. diagDescriptors = service != null ? service.GetDiagnosticDescriptors(analyzer) : analyzer.SupportedDiagnostics; } catch (Exception) { return false; } if (diagDescriptors == null) { return false; } // find if the first diagnostic in this analyzer allows telemetry DiagnosticDescriptor diagnostic = diagDescriptors.Length > 0 ? diagDescriptors[0] : null; return diagnostic == null ? false : diagnostic.CustomTags.Any(t => t == WellKnownDiagnosticTags.Telemetry); }