private void CheckChildStatement(SyntaxNodeAnalysisContext context, StatementSyntax childStatement) { if (childStatement is BlockSyntax) { return; } FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); if (lineSpan.StartLinePosition.Line == lineSpan.EndLinePosition.Line) { return; } context.ReportDiagnostic(Diagnostic.Create(Descriptor, childStatement.GetLocation())); }
private static void CheckChildStatement(SyntaxNodeAnalysisContext context, StatementSyntax childStatement) { if (childStatement is BlockSyntax) { return; } if (context.SemanticModel.Compilation.Options.SpecificDiagnosticOptions.GetValueOrDefault(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.DiagnosticId, ReportDiagnostic.Default) != ReportDiagnostic.Suppress) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); if (lineSpan.StartLinePosition.Line != lineSpan.EndLinePosition.Line) { return; } } context.ReportDiagnostic(Diagnostic.Create(Descriptor, childStatement.GetLocation())); }
private static void CheckChildStatement(SyntaxNodeAnalysisContext context, StatementSyntax childStatement) { if (childStatement is BlockSyntax) { return; } if (!context.IsAnalyzerSuppressed(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.Descriptor)) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); if (lineSpan.StartLinePosition.Line != lineSpan.EndLinePosition.Line) { return; } } context.ReportDiagnostic(Diagnostic.Create(Descriptor, childStatement.GetLocation())); }
private static void CheckChildStatement(SyntaxNodeAnalysisContext context, SyntaxNode node, StatementSyntax childStatement) { if (childStatement == null || childStatement.IsMissing) { return; } if (childStatement is BlockSyntax) { // BlockSyntax child statements are handled by HandleBlock return; } // We are only interested in the first instance of this violation on a line. if (!node.GetFirstToken().IsFirstInLine()) { return; } // We are only interested in the case where statement and childStatement start on the same line. Use // IsFirstInLine to detect this condition easily. SyntaxToken firstChildToken = childStatement.GetFirstToken(); if (firstChildToken.IsMissingOrDefault() || firstChildToken.IsFirstInLine()) { return; } if (!context.IsAnalyzerSuppressed(SA1519CurlyBracketsMustNotBeOmittedFromMultiLineChildStatement.DiagnosticId)) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); if (lineSpan.StartLinePosition.Line != lineSpan.EndLinePosition.Line) { return; } } context.ReportDiagnostic(Diagnostic.Create(Descriptor, childStatement.GetLocation())); }
private static void CheckChildStatement(SyntaxNodeAnalysisContext context, StatementSyntax childStatement) { bool reportAsHidden = false; if (childStatement == null || childStatement.IsMissing) { return; } if (childStatement is BlockSyntax) { // BlockSyntax child statements are handled by HandleBlock return; } // We are only interested in the case where statement and childStatement start on the same line. Use // IsFirstInLine to detect this condition easily. SyntaxToken firstChildToken = childStatement.GetFirstToken(); if (firstChildToken.IsMissingOrDefault() || firstChildToken.IsFirstInLine()) { return; } if (!context.IsAnalyzerSuppressed(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.Descriptor)) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); if (lineSpan.StartLinePosition.Line != lineSpan.EndLinePosition.Line) { reportAsHidden = true; } } ReportDiagnostic(context, childStatement.GetLocation(), reportAsHidden); }
private static void CheckChildStatement(SyntaxNodeAnalysisContext context, StatementSyntax childStatement) { if (childStatement is BlockSyntax) { return; } if (context.SemanticModel.Compilation.Options.SpecificDiagnosticOptions.GetValueOrDefault(SA1519CurlyBracketsMustNotBeOmittedFromMultiLineChildStatement.DiagnosticId, ReportDiagnostic.Default) != ReportDiagnostic.Suppress) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); if (lineSpan.StartLinePosition.Line != lineSpan.EndLinePosition.Line) { return; } } context.ReportDiagnostic(Diagnostic.Create(Descriptor, childStatement.GetLocation())); }
private static void CheckChildStatement(SyntaxNodeAnalysisContext context, SyntaxNode node, StatementSyntax childStatement) { if (childStatement == null || childStatement.IsMissing) { return; } if (childStatement is BlockSyntax) { // BlockSyntax child statements are handled by HandleBlock return; } // We are only interested in the first instance of this violation on a line. if (!node.GetFirstToken().IsFirstInLine()) { return; } // We are only interested in the case where statement and childStatement start on the same line. Use // IsFirstInLine to detect this condition easily. SyntaxToken firstChildToken = childStatement.GetFirstToken(); if (firstChildToken.IsMissingOrDefault() || firstChildToken.IsFirstInLine()) { return; } if (!context.IsAnalyzerSuppressed(SA1519CurlyBracketsMustNotBeOmittedFromMultiLineChildStatement.DiagnosticId)) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); if (lineSpan.StartLinePosition.Line != lineSpan.EndLinePosition.Line) { return; } } context.ReportDiagnostic(Diagnostic.Create(Descriptor, childStatement.GetLocation())); }
private static void CheckChildStatement(SyntaxNodeAnalysisContext context, StatementSyntax childStatement) { if (childStatement is BlockSyntax) { return; } FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); if (lineSpan.StartLinePosition.Line == lineSpan.EndLinePosition.Line) { return; } context.ReportDiagnostic(Diagnostic.Create(Descriptor, childStatement.GetLocation())); }