internal ContractEnsures(ICSharpStatement statement, PredicateExpression predicateExpression, Message message) 
     : base(statement, predicateExpression, message)
 {
     _contractResultArgument =
         predicateExpression.Predicates.Select(p => p.Argument)
             .OfType<ContractResultPredicateArgument>()
             .FirstOrDefault();
 }
        public InvalidRequiresMessageHighlighting(IInvocationExpression invocationExpression, Message contractMessage)
        {
            Contract.Requires(contractMessage != null);
            Contract.Requires(invocationExpression != null);

            _range = invocationExpression.GetHighlightingRange();
            _contractMessage = contractMessage;
        }
        private IfThrowPrecondition(IIfStatement ifStatement, 
            PredicateExpression predicateExpression, Message message, IClrTypeName exceptionTypeName)
            : base(ifStatement, predicateExpression, message)
        {
            Contract.Requires(ifStatement != null);
            Contract.Requires(exceptionTypeName != null);

            _ifStatement = ifStatement;
            _exceptionTypeName = exceptionTypeName;
        }
        protected ContractStatement(ICSharpStatement statement, PredicateExpression predicateExpression, Message message)
        {
            Contract.Requires(statement != null);
            Contract.Requires(predicateExpression != null);
            Contract.Requires(message != null);

            _statement = statement;
            _predicateExpression = predicateExpression;
            _message = message;
        }
        public ICSharpStatement CreateNonGenericContractRequires(string predicateExpression, Message message)
        {
            Contract.Requires(message != null);

            var originalExpression = message.OriginalExpression;

            if (originalExpression != null)
            {
                var formatWithMessage = string.Format("$0.Requires({0}, $1);", predicateExpression);

                return _factory.CreateStatement(formatWithMessage, ContractType, originalExpression);

            }
            var stringStatement = string.Format("$0.Requires({0});", predicateExpression);

            return _factory.CreateStatement(stringStatement, ContractType);
        }
        private ICSharpStatement CreateGenericContractRequires(IClrTypeName exceptionType, string predicateExpression, 
            Message message)
        {
            Contract.Requires(message != null);
            
            var originalExpression = message.OriginalExpression;
            
            if (originalExpression != null)
            {
                var formatWithMessage = string.Format("$0.Requires<$1>({0}, $2);", predicateExpression);

                return _factory.CreateStatement(
                    formatWithMessage, ContractType, 
                    CreateDeclaredType(exceptionType), originalExpression);
            }

            var format = string.Format("$0.Requires<$1>({0});", predicateExpression);

            return _factory.CreateStatement(format, ContractType, CreateDeclaredType(exceptionType));
        }
 internal ContractInvariant(ICSharpStatement statement, PredicateExpression predicateExpression, Message message) 
     : base(statement, predicateExpression, message)
 {}
 internal ContractRequires(ICSharpStatement statement, IInvocationExpression invocationExpression,
     PredicateExpression predicateExpression, Message message)
     : base(statement, predicateExpression, message)
 {
     GenericArgumentDeclaredType = GetGenericRequiresType(invocationExpression);
 }
 public PreconditionValidator(ICSharpStatement statement, 
     PredicateExpression predicateExpression, Message message) : base(statement, predicateExpression, message)
 {}
 private bool MessageIsAppropriateForContractRequires(Message message)
 {
     return message.IsValidForRequires();
 }
 public InvalidRequiresMessageHighlighting(Message contractMessage)
 {
     Contract.Requires(contractMessage != null);
     _contractMessage = contractMessage;
 }
 protected CodeContractAssertion(ICSharpStatement statement, 
     PredicateExpression predicateExpression, Message message)
     : base(statement, predicateExpression, message)
 {}