public static ExpressionSyntax ConvertToExpression(IThrowOperation throwOperation) { var throwStatement = (ThrowStatementSyntax)throwOperation.Syntax; RoslynDebug.Assert(throwStatement.Expression != null); return(SyntaxFactory.ThrowExpression(throwStatement.ThrowKeyword, throwStatement.Expression)); }
public override void VisitThrow(IThrowOperation operation) { if (_finallyBlockNestingDepth > 0) { ThrowExpressions.Add(operation); } base.VisitThrow(operation); }
public override void VisitThrow(IThrowOperation operation) { if (operation.Exception == null && _seenEmptyThrowInCatchClauses.Count > 0 && !_seenEmptyThrowInCatchClauses.Peek()) { _seenEmptyThrowInCatchClauses.Pop(); _seenEmptyThrowInCatchClauses.Push(true); } base.VisitThrow(operation); }
public override Location VisitThrow([NotNull] IThrowOperation operation, [CanBeNull] object argument) { if (operation.IsStatement()) { var syntax = (ThrowStatementSyntax)operation.Syntax; return(syntax.ThrowKeyword.GetLocation()); } return(base.VisitThrow(operation, argument)); }
public override void VisitThrow(IThrowOperation operation) { if (_seenRethrowInCatchClauses.Count > 0 && !_seenRethrowInCatchClauses.Peek()) { _seenRethrowInCatchClauses.Pop(); _seenRethrowInCatchClauses.Push(true); } base.VisitThrow(operation); }
public static ITypeSymbol GetExceptionType(this IThrowOperation throwOperation) { if (throwOperation.Exception != null) { return(throwOperation.Exception.Type); } var catchOperation = throwOperation.GetAncestor <ICatchClauseOperation>(OperationKind.CatchClause); return(catchOperation?.ExceptionType); }
public override void VisitThrow(IThrowOperation operation) { Assert.Equal(OperationKind.Throw, operation.Kind); if (operation.Exception == null) { Assert.Empty(operation.Children); } else { Assert.Same(operation.Exception, operation.Children.Single()); } }
internal static Location GetExceptionalLocation(this IThrowOperation @this) { if (@this.Syntax is ThrowExpressionSyntax expressionSyntax) { return(expressionSyntax.ThrowKeyword.GetLocation()); } else if (@this.Syntax is ThrowStatementSyntax statementSyntax) { return(statementSyntax.ThrowKeyword.GetLocation()); } else { return(@this.Syntax.GetLocation()); } }
private void AnalyzeThrowOperation(OperationAnalysisContext context, IThrowOperation operation) { if (operation.Exception.Type != _platformNotSupportedException) { return; } var rejectedPlatforms = GetRejectedPlatforms(operation); // If we couldn't find any rejected platforms then the throw operation wasn't // inside an if that checked for the absence of specific platforms. if (!rejectedPlatforms.Any) { return; } // To check wether we didn't annoate them, we'll subtract the declared platforms // from the rejected ones. var declaredPlatforms = GetDeclaredPlatforms(context.ContainingSymbol); rejectedPlatforms.RemoveAll(declaredPlatforms); // If there aren't any left, that means we annoated them all. if (!rejectedPlatforms.Any) { return; } // Alright, we missed some. Report them. var symbol = context.ContainingSymbol; var formattedSymbol = symbol.ToDisplayString(_symbolDisplayFormat); var formattedPlatforms = rejectedPlatforms.ToString(); var location = operation.Syntax.GetLocation(); var diagnostic = Diagnostic.Create(_pc0003, location, formattedSymbol, formattedPlatforms); context.ReportDiagnostic(diagnostic); }
protected override ExpressionSyntax ConvertToExpression(IThrowOperation throwOperation) => CSharpUseConditionalExpressionHelpers.ConvertToExpression(throwOperation);
public override PointsToAbstractValue VisitThrow(IThrowOperation operation, object argument) { var _ = base.VisitThrow(operation, argument); return(PointsToAbstractValue.NoLocation); }
public ExceptionalOperation(IThrowOperation operation) { Location = operation.GetExceptionalLocation(); Method = null; Type = operation.Exception.GetUnconvertedType(); }
public bool IsArgumentException(IThrowOperation operation) { return(operation.Exception != null && operation.Exception.Type.IsOrInheritFrom(_argumentSymbol)); }
protected abstract TExpressionSyntax ConvertToExpression(IThrowOperation throwOperation);
public override IOperation VisitThrow(IThrowOperation operation, object argument) { return(new ThrowExpression(Visit(operation.Exception), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit)); }
public override NullAbstractValue VisitThrow(IThrowOperation operation, object argument) { var _ = base.VisitThrow(operation, argument); return(NullAbstractValue.NotNull); }
public override void VisitThrow([NotNull] IThrowOperation operation) { Result.SetImmediate(); }
public override void VisitThrow([NotNull] IThrowOperation operation) { IncrementStatementCount(operation); base.VisitThrow(operation); }
public override bool VisitThrow([NotNull] IThrowOperation operation1, [CanBeNull] IOperation argument) { return(argument is IThrowOperation operation2 && AreBaseOperationsEqual(operation1, operation2)); }
public virtual void VisitThrow(IThrowOperation operation) { DefaultVisit(operation); }
public override void VisitThrow([NotNull] IThrowOperation operation) { base.VisitThrow(operation); }