Ejemplo n.º 1
0
        public void Track(TrackerInput input, object[] diagnosticMessageArgs, params Condition[] conditions)
        {
            input.Context.RegisterCompilationStartAction(c =>
            {
                if (input.IsEnabled(c.Options))
                {
                    c.RegisterSyntaxNodeActionInNonGenerated(
                        Language.GeneratedCodeRecognizer,
                        TrackAndReportIfNecessary,
                        TrackedSyntaxKinds);
                }
            });

            void TrackAndReportIfNecessary(SyntaxNodeAnalysisContext c)
            {
                if (CreateContext(c) is { } trackingContext &&
                    conditions.All(c => c(trackingContext)) &&
                    trackingContext.PrimaryLocation != null &&
                    trackingContext.PrimaryLocation != Location.None)
                {
                    c.ReportDiagnosticWhenActive(
                        Diagnostic.Create(input.Rule,
                                          trackingContext.PrimaryLocation,
                                          trackingContext.SecondaryLocations.ToAdditionalLocations(),
                                          trackingContext.SecondaryLocations.ToProperties(),
                                          diagnosticMessageArgs));
                }
            }
        }
Ejemplo n.º 2
0
 protected abstract void Initialize(TrackerInput input);
Ejemplo n.º 3
0
 public void Track(TrackerInput input, params Condition[] conditions) =>
 Track(input, Array.Empty <object>(), conditions);