private static void AnalyzeCatchClause(SyntaxNodeAnalysisContext context) { var catchClause = (CatchClauseSyntax)context.Node; CatchDeclarationSyntax declaration = catchClause.Declaration; if (declaration == null) { return; } SemanticModel semanticModel = context.SemanticModel; CancellationToken cancellationToken = context.CancellationToken; ILocalSymbol symbol = semanticModel.GetDeclaredSymbol(declaration, cancellationToken); if (symbol?.IsErrorType() != false) { return; } ExpressionSyntax expression = null; Walker walker = null; try { walker = Walker.GetInstance(); walker.Symbol = symbol; walker.SemanticModel = semanticModel; walker.CancellationToken = cancellationToken; walker.VisitBlock(catchClause.Block); expression = walker.ThrowStatement?.Expression; } finally { if (walker != null) { Walker.Free(walker); } } if (expression != null) { DiagnosticHelpers.ReportDiagnostic( context, DiagnosticRules.RemoveOriginalExceptionFromThrowStatement, expression); } }
public List <Point> FindBorder(Bitmap image, Point start, Color borderColor) { var border = new List <Point> { start }; var walker = Walker.GetInstance(start); do { walker.TurnRight(); var walkerBorderNeighbor = FindBorderNeighborInSquareAroundWalker(image, walker, borderColor); if (walkerBorderNeighbor == null) { continue; } border.Add(walkerBorderNeighbor.Position); walker = walkerBorderNeighbor; } while (walker.Position != start); return(border); }