/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
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 }
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"); }
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); }
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(); } }
public static int BadMethodSig_3(int a, int b, int c) { No.Op(a); No.Op(b); No.Op(c); return(1); }
public static void SortedSetMethodAvailability() { const SortedSet <T> sortedSet = null; No.Op <Func <T, IEnumerable <T> > >(sortedSet.Append); No.Op <TryGetValue <T> >(sortedSet.TryGetValue); }
/// <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); }
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(); }
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"); }
protected HashSetEx(SerializationInfo info, StreamingContext context) #endif { No.Op(info); No.Op(context); }
/// <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); }
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); } }
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"); }
public static void MethodInfoMethodAvailability() { const MethodInfo methodInfo = null; No.Op <Func <Type, Delegate> >(methodInfo.CreateDelegate); No.Op <Func <Type, object, Delegate> >(methodInfo.CreateDelegate); }
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 }
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)); }
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); }
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; }