Пример #1
0
        public override void VisitCatchClause(ICatchClauseOperation operation)
        {
            var exceptionType = operation.ExceptionType;
            var locals        = operation.Locals;

            base.VisitCatchClause(operation);
        }
            public override void VisitCatchClause(ICatchClauseOperation operation)
            {
                _seenRethrowInCatchClauses.Push(false);

                Visit(operation.Filter);
                Visit(operation.Handler);

                bool seenRethrow = _seenRethrowInCatchClauses.Pop();

                if (!seenRethrow && IsDisallowedCatch(operation) && !MightBeFilteringBasedOnTheCaughtException(operation))
                {
                    CatchClausesForDisallowedTypesWithoutRethrow.Add(operation);
                }
            }
            public override void VisitCatchClause(ICatchClauseOperation operation)
            {
                _seenEmptyThrowInCatchClauses.Push(false);

                Visit(operation.Filter);
                Visit(operation.Handler);

                bool seenEmptyThrow = _seenEmptyThrowInCatchClauses.Pop();

                if (IsCaughtTypeTooGeneral(operation.ExceptionType) && !seenEmptyThrow)
                {
                    CatchAllCatchClausesWithoutEmptyThrow.Add(operation);
                }
            }
Пример #4
0
        public override void VisitCatchClause(ICatchClauseOperation operation)
        {
            Assert.Equal(OperationKind.CatchClause, operation.Kind);
            var exceptionType = operation.ExceptionType;

            VisitLocals(operation.Locals);

            IEnumerable <IOperation> children = Array.Empty <IOperation>();

            if (operation.ExceptionDeclarationOrExpression != null)
            {
                children = children.Concat(new[] { operation.ExceptionDeclarationOrExpression });
            }

            if (operation.Filter != null)
            {
                children = children.Concat(new[] { operation.Filter });
            }

            children = children.Concat(new[] { operation.Handler });
            AssertEx.Equal(children, operation.Children);
        }
Пример #5
0
 private static bool IsReassignedInCatch(ICatchClauseOperation catchClause, ILocalReferenceOperation localReference)
 {
     var dataflow = catchClause.Language == LanguageNames.CSharp
         ? catchClause.SemanticModel.AnalyzeDataFlow(catchClause.Handler.Syntax)
         : catchClause.SemanticModel.AnalyzeDataFlow(catchClause.Handler.Operations[0].Syntax, catchClause.Handler.Operations[^ 1].Syntax);
 private static bool MightBeFilteringBasedOnTheCaughtException(ICatchClauseOperation operation)
 {
     return(operation.ExceptionDeclarationOrExpression != null && operation.Filter != null);
 }
 private bool IsDisallowedCatch(ICatchClauseOperation operation)
 {
     return(operation.ExceptionType is INamedTypeSymbol exceptionType &&
            _isDisallowedCatchType(exceptionType));
 }
Пример #8
0
 public override IOperation VisitCatchClause(ICatchClauseOperation operation, object argument)
 {
     return(new CatchClause(Visit(operation.ExceptionDeclarationOrExpression), operation.ExceptionType, operation.Locals, Visit(operation.Filter), Visit(operation.Handler), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit));
 }
Пример #9
0
 public virtual void VisitCatchClause(ICatchClauseOperation operation)
 {
     DefaultVisit(operation);
 }
Пример #10
0
 public override void VisitCatchClause([NotNull] ICatchClauseOperation operation)
 {
     base.VisitCatchClause(operation);
 }
 private static bool IsGenericCatch(ICatchClauseOperation operation)
 {
     return(operation.ExceptionType == null);
 }
 private bool IsCatchTooGeneral(ICatchClauseOperation operation)
 {
     return(IsGenericCatch(operation) || _disallowedCatchTypes.Any(type => operation.ExceptionType.Equals(type)));
 }
Пример #13
0
 public override bool VisitCatchClause([NotNull] ICatchClauseOperation operation1, [CanBeNull] IOperation argument)
 {
     return(argument is ICatchClauseOperation operation2 && AreBaseOperationsEqual(operation1, operation2) &&
            AreSymbolSequencesEqual(operation1.Locals, operation2.Locals) &&
            AreSymbolsEqual(operation1.ExceptionType, operation2.ExceptionType));
 }
            public override Location VisitCatchClause([NotNull] ICatchClauseOperation operation, [CanBeNull] object argument)
            {
                var syntax = (CatchClauseSyntax)operation.Syntax;

                return(syntax.CatchKeyword.GetLocation());
            }
Пример #15
0
 private static bool IsGenericCatch(ICatchClauseOperation operation)
 {
     return(operation.ExceptionDeclarationOrExpression == null);
 }