Exemplo n.º 1
0
 public static void TestDebuggerAttributes(object obj)
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(obj);
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(obj);
 }
 public void DebuggerAttributesValid()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableHashSet.CreateBuilder <int>());
 }
 public void DebuggerAttributesValid()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableDictionary.CreateBuilder <string, int>());
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(ImmutableDictionary.CreateBuilder <int, string>());
 }
 public static void TestDebuggerAttributes()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new ConcurrentDictionary <string, int>());
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new ConcurrentDictionary <string, int>());
 }
Exemplo n.º 5
0
 public void ValidateDebuggerAttributes()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new ValueTask <int>(42));
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new ValueTask <string>(Task.FromResult("42")));
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new ValueTask <string>(new TaskCompletionSource <string>().Task));
 }
 public static void DebuggerAttribute_NullCollection_ThrowsArgumentNullException()
 {
     TargetInvocationException ex = Assert.Throws <TargetInvocationException>(() => DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(ObservableSet <int>), null));
     ArgumentNullException     argumentNullException = Assert.IsType <ArgumentNullException>(ex.InnerException);
 }
Exemplo n.º 7
0
        public void TestDequeueClass()
        {
            var c = Channel.CreateBounded <int>(10);

            DebuggerAttributes.ValidateDebuggerDisplayReferences(DebuggerAttributes.GetFieldValue(c, "_items"));
        }
        public static void DebuggerAttributeTests_Null()
        {
            TargetInvocationException ex = Assert.Throws <TargetInvocationException>(() => DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(CaptureCollection), null));

            Assert.IsType <ArgumentNullException>(ex.InnerException);
        }
Exemplo n.º 9
0
        public void TestDebuggerDisplaysAndTypeProxies()
        {
            // Test both canceled and non-canceled
            foreach (var ct in new[] { new CancellationToken(false), new CancellationToken(true) })
            {
                // Some blocks have different code paths for whether they're greedy or not.
                // This helps with code-coverage.
                var dboBuffering   = new DataflowBlockOptions();
                var dboNoBuffering = new DataflowBlockOptions()
                {
                    BoundedCapacity = 1
                };
                var dboExBuffering = new ExecutionDataflowBlockOptions {
                    MaxDegreeOfParallelism = 2, CancellationToken = ct
                };
                var dboExSpsc = new ExecutionDataflowBlockOptions {
                    SingleProducerConstrained = true
                };
                var dboExNoBuffering = new ExecutionDataflowBlockOptions {
                    MaxDegreeOfParallelism = 2, BoundedCapacity = 1, CancellationToken = ct
                };
                var dboGroupGreedy    = new GroupingDataflowBlockOptions();
                var dboGroupNonGreedy = new GroupingDataflowBlockOptions {
                    Greedy = false
                };

                // Item1 == test DebuggerDisplay, Item2 == test DebuggerTypeProxy, Item3 == object
                var objectsToTest = new Tuple <bool, bool, object>[]
                {
                    // Primary Blocks
                    // (Don't test DebuggerTypeProxy on instances that may internally have async operations in progress)
                    Tuple.Create <bool, bool, object>(true, true, new ActionBlock <int>(i => {})),
                    Tuple.Create <bool, bool, object>(true, true, new ActionBlock <int>(i => {}, dboExBuffering)),
                    Tuple.Create <bool, bool, object>(true, true, new ActionBlock <int>(i => {}, dboExSpsc)),
                    Tuple.Create <bool, bool, object>(true, false, SendAsyncMessages(new ActionBlock <int>(i => {}, dboExNoBuffering), 2)),
                    Tuple.Create <bool, bool, object>(true, true, new TransformBlock <int, int>(i => i)),
                    Tuple.Create <bool, bool, object>(true, true, new TransformBlock <int, int>(i => i, dboExBuffering)),
                    Tuple.Create <bool, bool, object>(true, false, SendAsyncMessages(new TransformBlock <int, int>(i => i, dboExNoBuffering), 2)),
                    Tuple.Create <bool, bool, object>(true, true, new TransformManyBlock <int, int>(i => new [] { i })),
                    Tuple.Create <bool, bool, object>(true, true, new TransformManyBlock <int, int>(i => new [] { i }, dboExBuffering)),
                    Tuple.Create <bool, bool, object>(true, false, SendAsyncMessages(new TransformManyBlock <int, int>(i => new [] { i }, dboExNoBuffering), 2)),
                    Tuple.Create <bool, bool, object>(true, true, new BufferBlock <int>()),
                    Tuple.Create <bool, bool, object>(true, true, new BufferBlock <int>(new DataflowBlockOptions()
                    {
                        NameFormat = "none"
                    })),
                    Tuple.Create <bool, bool, object>(true, true, new BufferBlock <int>(new DataflowBlockOptions()
                    {
                        NameFormat = "foo={0}, bar={1}"
                    })),
                    Tuple.Create <bool, bool, object>(true, true, new BufferBlock <int>(new DataflowBlockOptions()
                    {
                        NameFormat = "foo={0}, bar={1}, kaboom={2}"
                    })),
                    Tuple.Create <bool, bool, object>(true, true, new BufferBlock <int>(dboBuffering)),
                    Tuple.Create <bool, bool, object>(true, false, SendAsyncMessages(new BufferBlock <int>(new DataflowBlockOptions {
                        BoundedCapacity = 10
                    }), 20)),
                    Tuple.Create <bool, bool, object>(true, true, new BroadcastBlock <int>(i => i)),
                    Tuple.Create <bool, bool, object>(true, true, new BroadcastBlock <int>(i => i, dboBuffering)),
                    Tuple.Create <bool, bool, object>(true, false, SendAsyncMessages(new BroadcastBlock <int>(i => i, dboNoBuffering), 20)),
                    Tuple.Create <bool, bool, object>(true, true, new WriteOnceBlock <int>(i => i)),
                    Tuple.Create <bool, bool, object>(true, false, SendAsyncMessages(new WriteOnceBlock <int>(i => i), 1)),
                    Tuple.Create <bool, bool, object>(true, true, new WriteOnceBlock <int>(i => i, dboBuffering)),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int>()),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int>(dboGroupGreedy)),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int>(dboGroupNonGreedy)),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int, int>()),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int, int>(dboGroupGreedy)),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int, int>(dboGroupNonGreedy)),
                    Tuple.Create <bool, bool, object>(true, true, new BatchedJoinBlock <int, int>(42)),
                    Tuple.Create <bool, bool, object>(true, true, new BatchedJoinBlock <int, int>(42, dboGroupGreedy)),
                    Tuple.Create <bool, bool, object>(true, true, new BatchedJoinBlock <int, int, int>(42, dboGroupGreedy)),
                    Tuple.Create <bool, bool, object>(true, true, new BatchBlock <int>(42)),
                    Tuple.Create <bool, bool, object>(true, true, new BatchBlock <int>(42, dboGroupGreedy)),
                    Tuple.Create <bool, bool, object>(true, true, new BatchBlock <int>(42, dboGroupNonGreedy)),
                    Tuple.Create <bool, bool, object>(true, true, DataflowBlock.Encapsulate <int, int>(new BufferBlock <int>(), new BufferBlock <int>())),
                    Tuple.Create <bool, bool, object>(true, true, new BufferBlock <int>().AsObservable()),

                    // Supporting and Internal Types
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new ActionBlock <int>(i => {}, dboExBuffering), "_defaultTarget")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new ActionBlock <int>(i => {}, dboExNoBuffering), "_defaultTarget")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(DebuggerAttributes.GetFieldValue(new ActionBlock <int>(i => {}), "_defaultTarget"), "_messages")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new ActionBlock <int>(i => {}, dboExSpsc), "_spscTarget")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(DebuggerAttributes.GetFieldValue(new ActionBlock <int>(i => {}, dboExSpsc), "_spscTarget"), "_messages")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new BufferBlock <int>(), "_source")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new BufferBlock <int>(new DataflowBlockOptions {
                        BoundedCapacity = 10
                    }), "_source")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new TransformBlock <int, int>(i => i, dboExBuffering), "_source")),
                    Tuple.Create <bool, bool, object>(true, true, DebuggerAttributes.GetFieldValue(new TransformBlock <int, int>(i => i, dboExNoBuffering), "_reorderingBuffer")),
                    Tuple.Create <bool, bool, object>(true, true, DebuggerAttributes.GetFieldValue(DebuggerAttributes.GetFieldValue(new TransformBlock <int, int>(i => i, dboExBuffering), "_source"), "_targetRegistry")),
                    Tuple.Create <bool, bool, object>(true, true, DebuggerAttributes.GetFieldValue(DebuggerAttributes.GetFieldValue(WithLinkedTarget <TransformBlock <int, int>, int>(new TransformBlock <int, int>(i => i, dboExNoBuffering)), "_source"), "_targetRegistry")),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int>().Target1),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int>(dboGroupGreedy).Target1),
                    Tuple.Create <bool, bool, object>(true, true, new JoinBlock <int, int>(dboGroupNonGreedy).Target1),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new JoinBlock <int, int>().Target1, "_sharedResources")),
                    Tuple.Create <bool, bool, object>(true, true, new BatchedJoinBlock <int, int>(42).Target1),
                    Tuple.Create <bool, bool, object>(true, true, new BatchedJoinBlock <int, int>(42, dboGroupGreedy).Target1),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new BatchBlock <int>(42), "_target")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new BatchBlock <int>(42, dboGroupGreedy), "_target")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new BatchBlock <int>(42, dboGroupNonGreedy), "_target")),
                    Tuple.Create <bool, bool, object>(true, false, new BufferBlock <int>().LinkTo(new ActionBlock <int>(i => {}))), // ActionOnDispose
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new BroadcastBlock <int>(i => i), "_source")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new BroadcastBlock <int>(i => i, dboGroupGreedy), "_source")),
                    Tuple.Create <bool, bool, object>(true, false, DebuggerAttributes.GetFieldValue(new BroadcastBlock <int>(i => i, dboGroupNonGreedy), "_source")),
                    Tuple.Create <bool, bool, object>(true, true, CreateNopLinkSource <int>()),
                    Tuple.Create <bool, bool, object>(true, true, CreateFilteringSource <int>()),
                    Tuple.Create <bool, bool, object>(true, true, CreateSendSource <int>()),
                    Tuple.Create <bool, bool, object>(true, false, CreateReceiveTarget <int>()),
                    Tuple.Create <bool, bool, object>(true, false, CreateOutputAvailableTarget()),
                    Tuple.Create <bool, bool, object>(true, false, CreateChooseTarget <int>()),
                    Tuple.Create <bool, bool, object>(true, false, new BufferBlock <int>().AsObservable().Subscribe(DataflowBlock.NullTarget <int>().AsObserver())),

                    // Other
                    Tuple.Create <bool, bool, object>(true, false, new DataflowMessageHeader(1)),
                };

                // Test all DDAs and DTPAs
                foreach (var obj in objectsToTest)
                {
                    if (obj.Item1)
                    {
                        DebuggerAttributes.ValidateDebuggerDisplayReferences(obj.Item3);
                    }
                    if (obj.Item2)
                    {
                        DebuggerAttributes.ValidateDebuggerTypeProxyProperties(obj.Item3);
                    }
                }
            }
        }
Exemplo n.º 10
0
 public void DebuggerAttributeTests()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new Hashtable());
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new Hashtable());
 }
Exemplo n.º 11
0
        public static void DebuggerAttribute_NullDictionaryKeys_ThrowsArgumentNullException()
        {
            TargetInvocationException ex = Assert.Throws <TargetInvocationException>(() => DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(ReadOnlyDictionary <int, int> .KeyCollection), new Type[] { typeof(int) }, null));
            ArgumentNullException     argumentNullException = Assert.IsType <ArgumentNullException>(ex.InnerException);

            Assert.Equal("collection", argumentNullException.ParamName);
        }
Exemplo n.º 12
0
        public static void TestDebuggerAttributes_Null(object obj)
        {
            Type proxyType = DebuggerAttributes.GetProxyType(obj);

            Assert.Throws <TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object)null));
        }
 public static void TestDebuggerAttributes_Null()
 {
     Type proxyType = DebuggerAttributes.GetProxyType(ImmutableHashSet.Create<string>());
     TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object)null));
     Assert.IsType<ArgumentNullException>(tie.InnerException);
 }
Exemplo n.º 14
0
 public void DebuggerAttributesValid()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableQueue.Create <int>());
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(ImmutableQueue.Create <string>());
 }
Exemplo n.º 15
0
 public static void DebuggerAttributeTests()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(CreateCollection());
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(CreateCollection());
 }
Exemplo n.º 16
0
 public void DebuggerAttributesAreValid()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(Color.Aquamarine);
     DebuggerAttributes.ValidateDebuggerDisplayReferences(Color.FromArgb(4, 3, 2, 1));
 }
Exemplo n.º 17
0
 public static void Test10_DebuggerAttributes()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new ConcurrentStack <int>());
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new ConcurrentStack <int>());
 }
 public static void DebuggerAttribute_Tests()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new ReadOnlyObservableCollection <int>(new ObservableCollection <int>()));
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new ReadOnlyObservableCollection <int>(new ObservableCollection <int>()));
 }
Exemplo n.º 19
0
 public static void TestDebuggerAttributes_Null()
 {
     Type proxyType = DebuggerAttributes.GetProxyType(new ConcurrentDictionary<string, int>());
     TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object)null));
     Assert.IsType<ArgumentNullException>(tie.InnerException);
 }