Example #1
0
 /// <summary>
 ///     Provides the implementation of calling a member.  Derived classes can override
 ///     this method to customize behavior.  When not overridden the call site requesting the
 ///     binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="args">The arguments to be used for the invocation.</param>
 /// <param name="result">The result of the invocation.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryInvokeMember(InvokeMemberBinder binder, object[] args, [NotNullWhen(true)] out object?result)
 {
     No.Op(binder);
     No.Op(args);
     result = null;
     return(false);
 }
Example #2
0
 /// <summary>
 ///     Provides the implementation of performing a set index operation.  Derived classes can
 ///     override this method to customize behavior.  When not overridden the call site requesting
 ///     the binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="indexes">The indexes to be used.</param>
 /// <param name="value">The value to set.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value)
 {
     No.Op(binder);
     No.Op(indexes);
     No.Op(value);
     return(false);
 }
Example #3
0
 /// <summary>
 ///     Provides the implementation of creating an instance of the <see cref="DynamicObject" />.
 ///     Derived classes can override this method to customize behavior.  When not overridden the
 ///     call site requesting the binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="args">The arguments used for creation.</param>
 /// <param name="result">The created instance.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryCreateInstance(CreateInstanceBinder binder, object[] args, [NotNullWhen(true)] out object?result)
 {
     No.Op(binder);
     No.Op(args);
     result = null;
     return(false);
 }
Example #4
0
 /// <summary>
 ///     Provides the implementation of performing a get index operation.  Derived classes can
 ///     override this method to customize behavior.  When not overridden the call site requesting
 ///     the binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="indexes">The indexes to be used.</param>
 /// <param name="result">The result of the operation.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryGetIndex(GetIndexBinder binder, object[] indexes, [NotNullWhen(true)] out object?result)
 {
     No.Op(binder);
     No.Op(indexes);
     result = null;
     return(false);
 }
Example #5
0
 /// <summary>
 ///     Provides the implementation of performing a binary operation.  Derived classes can
 ///     override this method to customize behavior.  When not overridden the call site requesting
 ///     the binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="arg">The right operand for the operation.</param>
 /// <param name="result">The result of the operation.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result)
 {
     No.Op(binder);
     No.Op(arg);
     result = null;
     return(false);
 }
Example #6
0
 /// <summary>
 ///     Provides the implementation of calling a member.  Derived classes can override
 ///     this method to customize behavior.  When not overridden the call site requesting the
 ///     binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="args">The arguments to be used for the invocation.</param>
 /// <param name="result">The result of the invocation.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
 {
     No.Op(binder);
     No.Op(args);
     result = null;
     return(false);
 }
Example #7
0
 /// <summary>
 ///     Provides the implementation of performing a get index operation.  Derived classes can
 ///     override this method to customize behavior.  When not overridden the call site requesting
 ///     the binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="indexes">The indexes to be used.</param>
 /// <param name="result">The result of the operation.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
 {
     No.Op(binder);
     No.Op(indexes);
     result = null;
     return(false);
 }
Example #8
0
 /// <summary>
 ///     Provides the implementation of performing a binary operation.  Derived classes can
 ///     override this method to customize behavior.  When not overridden the call site requesting
 ///     the binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="arg">The right operand for the operation.</param>
 /// <param name="result">The result of the operation.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryBinaryOperation(BinaryOperationBinder binder, object arg, [NotNullWhen(true)] out object?result)
 {
     No.Op(binder);
     No.Op(arg);
     result = null;
     return(false);
 }
Example #9
0
 public static void EnsuresOnThrow <TException>(bool condition)
     where TException : Exception
 {
     No.Op(typeof(TException));
     No.Op(condition);
     AssertMustUseRewriter(ContractFailureKind.PostconditionOnException, nameof(EnsuresOnThrow));
 }
        public static void MethodAvailability()
        {
            No.Op <Func <int, Task> >(TaskEx.Delay);
            No.Op <Func <TimeSpan, Task> >(TaskEx.Delay);
            No.Op <Func <TimeSpan, CancellationToken, Task> >(TaskEx.Delay);
            No.Op <Func <int, CancellationToken, Task> >(TaskEx.Delay);
            No.Op <Func <TResult, Task <TResult> > >(TaskEx.FromResult);
            No.Op <Func <Action, Task> >(TaskEx.Run);
            No.Op <Func <Action, CancellationToken, Task> >(TaskEx.Run);
            No.Op <Func <Func <TResult>, Task <TResult> > >(TaskEx.Run);
            No.Op <Func <Func <TResult>, CancellationToken, Task <TResult> > >(TaskEx.Run);
            No.Op <Func <Func <Task>, Task> >(TaskEx.Run);
            No.Op <Func <Func <Task>, CancellationToken, Task> >(TaskEx.Run);
            No.Op <Func <Func <Task <TResult> >, Task <TResult> > >(TaskEx.Run);
            No.Op <Func <Func <Task <TResult> >, CancellationToken, Task <TResult> > >(TaskEx.Run);
            No.Op <Func <Task[], Task> >(TaskEx.WhenAll);
            No.Op <Func <Task <TResult>[], Task <TResult[]> > >(TaskEx.WhenAll);
            No.Op <Func <IEnumerable <Task>, Task> >(TaskEx.WhenAll);
            No.Op <Func <IEnumerable <Task <TResult> >, Task <TResult[]> > >(TaskEx.WhenAll);
            No.Op <Func <Task[], Task> >(TaskEx.WhenAny);
            No.Op <Func <Task <TResult>[], Task <Task <TResult> > > >(TaskEx.WhenAny);
            No.Op <Func <IEnumerable <Task>, Task> >(TaskEx.WhenAny);
            No.Op <Func <IEnumerable <Task <TResult> >, Task <Task <TResult> > > >(TaskEx.WhenAny);
#if LESSTHAN_NET45 || LESSTHAN_NETCOREAPP20 || LESSTHAN_NETSTANDARD20
            No.Op <Func <global::System.Runtime.CompilerServices.YieldAwaitable> >(TaskEx.Yield);
#else
            // No.Op<Func<global::Microsoft.Runtime.CompilerServices.YieldAwaitable>>(TaskEx.Yield);
#endif
        }
Example #11
0
        public void Add()
        {
            var collection      = new ObservableCollection <char>();
            var propertyChanged = false;
            var changedProps    = new List <string>();
            NotifyCollectionChangedEventArgs args = null;

            ((INotifyPropertyChanged)collection).PropertyChanged += (sender, e) =>
            {
                No.Op(sender);
                propertyChanged = true;
                changedProps.Add(e.PropertyName);
            };

            collection.CollectionChanged += (sender, e) =>
            {
                No.Op(sender);
                args = e;
            };

            collection.Add('A');

            Assert.IsTrue(propertyChanged, "ADD_1");
            Assert.IsTrue(changedProps.Contains("Count"), "ADD_2");
            Assert.IsTrue(changedProps.Contains("Item[]"), "ADD_3");

            CollectionChangedEventValidators.ValidateAddOperation(args, new[] { 'A' }, 0, "ADD_4");
        }
Example #12
0
        public void Clear()
        {
            var initial = new List <char>
            {
                'A',
                'B',
                'C'
            };

            var collection      = new ObservableCollection <char>(initial);
            var propertyChanged = false;
            var changedProps    = new List <string>();
            NotifyCollectionChangedEventArgs args = null;

            ((INotifyPropertyChanged)collection).PropertyChanged += (sender, e) =>
            {
                No.Op(sender);
                propertyChanged = true;
                changedProps.Add(e.PropertyName);
            };

            collection.CollectionChanged += (sender, e) =>
            {
                No.Op(sender);
                args = e;
            };

            collection.Clear();

            Assert.IsTrue(propertyChanged, "CLEAR_1");
            Assert.IsTrue(changedProps.Contains("Count"), "CLEAR_2");
            Assert.IsTrue(changedProps.Contains("Item[]"), "CLEAR_3");

            CollectionChangedEventValidators.ValidateResetOperation(args, "CLEAR_4");
        }
 public static void EnumerableMethodAvailability()
 {
     No.Op <Func <IEnumerable, IEnumerable <TResult> > >(Enumerable.Cast <TResult>);
     No.Op <Func <IEnumerable <TResult> > >(Enumerable.Empty <TResult>);
     No.Op <Func <int, int, IEnumerable <int> > >(Enumerable.Range);
     No.Op <Func <TResult, int, IEnumerable <TResult> > >(Enumerable.Repeat);
 }
Example #14
0
        protected SortedSet(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            No.Op(context);
            Comparer = (IComparer <T>)info.GetValue(nameof(Comparer), typeof(IComparer <T>));
            _wrapped = new AVLTree <T, T>(Comparer);
            var count = info.GetInt32(nameof(Count));

            if (count != 0)
            {
                var value = (T[])info.GetValue("Items", typeof(T[]));
                if (value == null)
                {
                    throw new SerializationException();
                }

                foreach (var item in value)
                {
                    Add(item);
                }
            }

            info.GetInt32("Version");
            if (Count != count)
            {
                throw new SerializationException();
            }
        }
Example #15
0
 public static int BadMethodSig_3(int a, int b, int c)
 {
     No.Op(a);
     No.Op(b);
     No.Op(c);
     return(1);
 }
Example #16
0
        public static void SortedSetMethodAvailability()
        {
            const SortedSet <T> sortedSet = null;

            No.Op <Func <T, IEnumerable <T> > >(sortedSet.Append);
            No.Op <TryGetValue <T> >(sortedSet.TryGetValue);
        }
Example #17
0
 /// <summary>
 ///     Provides the implementation of creating an instance of the <see cref="DynamicObject" />.
 ///     Derived classes can override this method to customize behavior.  When not overridden the
 ///     call site requesting the binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="args">The arguments used for creation.</param>
 /// <param name="result">The created instance.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryCreateInstance(CreateInstanceBinder binder, object[] args, out object result)
 {
     No.Op(binder);
     No.Op(args);
     result = null;
     return(false);
 }
Example #18
0
        public static void LongWait()
        {
            var semaphore1 = new SemaphoreSlim(0);
            var semaphore2 = new SemaphoreSlim(0);
            var semaphore3 = new SemaphoreSlim(0);
            var thread     = new Thread
                             (
                () =>
            {
                Thread.Sleep(5000);
                semaphore1.Release();
                Thread.Sleep(5000);
                semaphore2.Release();
            }
                             );

            thread.Start();
            semaphore1.Wait();
            var source1 = new CancellationTokenSource(10000);

            semaphore2.Wait(source1.Token);
            var source2 = new CancellationTokenSource(10);

            try
            {
                semaphore3.Wait(source2.Token);
            }
            catch (OperationCanceledException exception)
            {
                No.Op(exception);
                return;
            }
            Assert.Fail();
        }
Example #19
0
 public static T Bind <T>(CallSiteBinder binder, CallSite <T> site, object[] args) where T : class
 {
     No.Op(binder);
     No.Op(site);
     No.Op(args);
     throw new InvalidOperationException("No or Invalid rule produced");
 }
Example #20
0
        protected HashSetEx(SerializationInfo info, StreamingContext context)
#endif

        {
            No.Op(info);
            No.Op(context);
        }
Example #21
0
 /// <summary>
 ///     Provides low-level runtime binding support.  Classes can override this and provide a direct
 ///     delegate for the implementation of rule.  This can enable saving rules to disk, having
 ///     specialized rules available at runtime, or providing a different caching policy.
 /// </summary>
 /// <typeparam name="T">The target type of the CallSite.</typeparam>
 /// <param name="site">The CallSite the bind is being performed for.</param>
 /// <param name="args">The arguments for the binder.</param>
 /// <returns>A new delegate which replaces the CallSite Target.</returns>
 public virtual T?BindDelegate <T>(CallSite <T> site, object[] args)
     where T : class
 {
     No.Op(site);
     No.Op(args);
     return(null);
 }
 public static void MethodAvailability()
 {
     No.Op <Func <int, Task> >(TaskEx.Delay);
     No.Op <Func <TimeSpan, Task> >(TaskEx.Delay);
     No.Op <Func <TimeSpan, CancellationToken, Task> >(TaskEx.Delay);
     No.Op <Func <int, CancellationToken, Task> >(TaskEx.Delay);
     No.Op <Func <TResult, Task <TResult> > >(TaskEx.FromResult);
     No.Op <Func <Action, Task> >(TaskEx.Run);
     No.Op <Func <Action, CancellationToken, Task> >(TaskEx.Run);
     No.Op <Func <Func <TResult>, Task <TResult> > >(TaskEx.Run);
     No.Op <Func <Func <TResult>, CancellationToken, Task <TResult> > >(TaskEx.Run);
     No.Op <Func <Func <Task>, Task> >(TaskEx.Run);
     No.Op <Func <Func <Task>, CancellationToken, Task> >(TaskEx.Run);
     No.Op <Func <Func <Task <TResult> >, Task <TResult> > >(TaskEx.Run);
     No.Op <Func <Func <Task <TResult> >, CancellationToken, Task <TResult> > >(TaskEx.Run);
     No.Op <Func <Task[], Task> >(TaskEx.WhenAll);
     No.Op <Func <Task <TResult>[], Task <TResult[]> > >(TaskEx.WhenAll);
     No.Op <Func <IEnumerable <Task>, Task> >(TaskEx.WhenAll);
     No.Op <Func <IEnumerable <Task <TResult> >, Task <TResult[]> > >(TaskEx.WhenAll);
     No.Op <Func <Task[], Task> >(TaskEx.WhenAny);
     No.Op <Func <Task <TResult>[], Task <Task <TResult> > > >(TaskEx.WhenAny);
     No.Op <Func <IEnumerable <Task>, Task> >(TaskEx.WhenAny);
     No.Op <Func <IEnumerable <Task <TResult> >, Task <Task <TResult> > > >(TaskEx.WhenAny);
     No.Op <Func <YieldAwaitable> >(TaskEx.Yield);
 }
Example #23
0
        public void Constructor_Invalid()
        {
            try
            {
                // ReSharper disable once AssignNullToNotNullAttribute
                var x = new ObservableCollection <int>(null);
                GC.KeepAlive(x);
                Assert.Fail("#1");
            }
            catch (ArgumentNullException ex)
            {
                No.Op(ex);
            }

            try
            {
                // ReSharper disable once AssignNullToNotNullAttribute
                var x = new ObservableCollection <int>((IEnumerable <int>)null);
                GC.KeepAlive(x);
                Assert.Fail("#2");
            }
            catch (ArgumentNullException ex)
            {
                No.Op(ex);
            }
        }
Example #24
0
        public void Set()
        {
            var collection      = new ObservableCollection <char>();
            var propertyChanged = false;
            var changedProps    = new List <string>();
            NotifyCollectionChangedEventArgs args = null;

            collection.Add('A');
            collection.Add('B');
            collection.Add('C');

            ((INotifyPropertyChanged)collection).PropertyChanged += (sender, e) =>
            {
                No.Op(sender);
                propertyChanged = true;
                changedProps.Add(e.PropertyName);
            };

            collection.CollectionChanged += (sender, e) =>
            {
                No.Op(sender);
                args = e;
            };

            collection[2] = 'I';

            Assert.IsTrue(propertyChanged, "SET_1");
            Assert.IsTrue(changedProps.Contains("Item[]"), "SET_2");

            CollectionChangedEventValidators.ValidateReplaceOperation(args, new[] { 'C' }, new[] { 'I' }, 2, "SET_3");
        }
Example #25
0
        public static void MethodInfoMethodAvailability()
        {
            const MethodInfo methodInfo = null;

            No.Op <Func <Type, Delegate> >(methodInfo.CreateDelegate);
            No.Op <Func <Type, object, Delegate> >(methodInfo.CreateDelegate);
        }
Example #26
0
        public static void TaskCompletionSourceMethodAvailability()
        {
#if TARGETS_NET || TARGETS_NETCORE || GREATERTHAN_NETSTANDARD12
            const TaskCompletionSource <int> source = null;
            No.Op <Func <bool> >(source.TrySetCanceled);
            No.Op <Func <CancellationToken, bool> >(source.TrySetCanceled);
#endif
        }
Example #27
0
 public static void AGenericMethod <TX, TY>(string foo, int bar)
 {
     // Used via Reflection
     No.Op(foo);
     No.Op(bar);
     No.Op(typeof(TX));
     No.Op(typeof(TY));
 }
Example #28
0
        protected virtual void Dispose(bool disposing)
        {
            // This is a protected method, the parameter should be kept
            No.Op(disposing);
            var state = Interlocked.Exchange(ref _state, null);

            state?.Dispose();
        }
 public static void MethodAvailability()
 {
     No.Op <Func <WaitCallback, bool> >(ThreadPool.QueueUserWorkItem);
     No.Op <Func <WaitCallback, object, bool> >(ThreadPoolEx.QueueUserWorkItem);
     No.Op <Func <Action <object>, object, bool, bool> >(ThreadPoolEx.QueueUserWorkItem);
     No.Op <Func <WaitCallback, object, bool> >(ThreadPoolEx.UnsafeQueueUserWorkItem);
     No.Op <Func <Action <object>, object, bool, bool> >(ThreadPoolEx.UnsafeQueueUserWorkItem);
 }
Example #30
0
 protected virtual void Dispose(bool disposing)
 {
     // This is a protected method, the parameter should be kept
     No.Op(disposing);
     _disposed = true;
     _canEnter.Dispose();
     _asyncWaiters = null;
     _canEnter     = null;
 }