none
Bug report: code contract assumptions for IQuery<T>

    Question

  •  public IQueryable<T> GetSortedQueryable<T>(IQuery<T> query)
                where T : class, IPersistentEntity
            {
                var result = this.GetNonSortedQueryable(query);
    
                // Due to a bug in the contract system
                Contract.Assume(query.SortingOrders != null); 
    
                if (query.SortingOrders.Any())
                {
                    // Loop through each and apply in turn.
                    result = query.SortingOrders.Aggregate(result, (current, order) => order.ApplySort(current));
                }
    
                return result;
            }

    I have code contract within IQuery<T> to ensure that sorting orders are not null. Still an error is received saying there are unproven code contracts. The above code contract assumption is needed due to this bug. the following error is given when the above assumption is not included: CodeContracts: requires unproven: source != null

    Monday, November 19, 2012 10:20 PM

All replies