public static void DebuggerAttributeTests()
        {
            ReadOnlyDictionary <int, int> dict = new ReadOnlyDictionary <int, int>(new Dictionary <int, int> {
                { 1, 2 }, { 2, 4 }, { 3, 6 }
            });

            DebuggerAttributes.ValidateDebuggerDisplayReferences(dict);
            DebuggerAttributeInfo info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(dict);
            PropertyInfo          itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);

            KeyValuePair <int, int>[] pairs = itemProperty.GetValue(info.Instance) as KeyValuePair <int, int>[];
            Assert.Equal(dict, pairs);

            DebuggerAttributes.ValidateDebuggerDisplayReferences(dict.Keys);
            info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(ReadOnlyDictionary <int, int> .KeyCollection), new Type[] { typeof(int) }, dict.Keys);
            itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
            int[] items = itemProperty.GetValue(info.Instance) as int[];
            Assert.Equal(dict.Keys, items);

            DebuggerAttributes.ValidateDebuggerDisplayReferences(dict.Values);
            info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(ReadOnlyDictionary <int, int> .KeyCollection), new Type[] { typeof(int) }, dict.Values);
            itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
            items        = itemProperty.GetValue(info.Instance) as int[];
            Assert.Equal(dict.Values, items);
        }
Exemplo n.º 2
0
        public static void DebuggerAttribute()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(new Queue());

            var testQueue = new Queue();

            testQueue.Enqueue("a");
            testQueue.Enqueue(1);
            testQueue.Enqueue("b");
            testQueue.Enqueue(2);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(testQueue);

            bool threwNull = false;

            try
            {
                DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(Queue), null);
            }
            catch (TargetInvocationException ex)
            {
                threwNull = ex.InnerException is ArgumentNullException;
            }

            Assert.True(threwNull);
        }
Exemplo n.º 3
0
        public static void DebuggerAttribute()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(new Stack());

            var stack = new Stack();

            stack.Push("a");
            stack.Push(1);
            stack.Push("b");
            stack.Push(2);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(stack);

            bool threwNull = false;

            try
            {
                DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(Stack), null);
            }
            catch (TargetInvocationException ex)
            {
                threwNull = ex.InnerException is ArgumentNullException;
            }

            Assert.True(threwNull);
        }
Exemplo n.º 4
0
        public void DebuggerAttributes_Success(int count)
        {
            IProducerConsumerCollection <int> c = CreateProducerConsumerCollection(count);

            DebuggerAttributes.ValidateDebuggerDisplayReferences(c);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(c);
        }
Exemplo n.º 5
0
        public void DebuggerAttributes_Success()
        {
            var q = new ConcurrentQueue <int>(Enumerable.Range(0, 10));

            DebuggerAttributes.ValidateDebuggerDisplayReferences(q);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(q);
        }
Exemplo n.º 6
0
        public static void DebuggerAttribute()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(new Hashtable());

            var hash = new Hashtable()
            {
                { "a", 1 }, { "b", 2 }
            };

            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(hash);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(Hashtable), Hashtable.Synchronized(hash));

            bool threwNull = false;

            try
            {
                DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(Hashtable), null);
            }
            catch (TargetInvocationException ex)
            {
                threwNull = ex.InnerException is ArgumentNullException;
            }

            Assert.True(threwNull);
        }
Exemplo n.º 7
0
        public static void ValidateDebuggerAttributes()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(new ConcurrentBag <int>());
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new ConcurrentBag <int>());

            DebuggerAttributes.ValidateDebuggerDisplayReferences(new ConcurrentBag <int>(Enumerable.Range(0, 10)));
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new ConcurrentBag <int>(Enumerable.Range(0, 10)));
        }
Exemplo n.º 8
0
        public static void DebuggerAttributeTests()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(new ReadOnlyDictionary <int, int>(new Dictionary <int, int>()));
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new ReadOnlyDictionary <int, int>(new Dictionary <int, int>()));

            DebuggerAttributes.ValidateDebuggerDisplayReferences(new ReadOnlyDictionary <int, int>(new Dictionary <int, int>()).Keys);
            DebuggerAttributes.ValidateDebuggerDisplayReferences(new ReadOnlyDictionary <int, int>(new Dictionary <int, int>()).Values);
        }
Exemplo n.º 9
0
 public void DebuggerAttributeTests()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new ArrayList());
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new ArrayList()
     {
         "a", 1, "b", 2
     });
 }
Exemplo n.º 10
0
 public void DebuggerAttributeTests()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new SortedList());
     DebuggerAttributes.ValidateDebuggerTypeProxyProperties(new SortedList()
     {
         { "a", 1 }, { "b", 2 }
     });
 }
Exemplo n.º 11
0
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableSortedSet.Create <int>());
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(ImmutableSortedSet.Create <string>("1", "2", "3"));

            object rootNode = DebuggerAttributes.GetFieldValue(ImmutableSortedSet.Create <object>(), "_root");

            DebuggerAttributes.ValidateDebuggerDisplayReferences(rootNode);
        }
Exemplo n.º 12
0
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableDictionary.Create <int, int>());
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(ImmutableDictionary.Create <string, int>());

            object rootNode = DebuggerAttributes.GetFieldValue(ImmutableDictionary.Create <string, string>(), "_root");

            DebuggerAttributes.ValidateDebuggerDisplayReferences(rootNode);
        }
Exemplo n.º 13
0
        public static void TestDebuggerAttributes(object obj)
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(obj);
            DebuggerAttributeInfo info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(obj);
            PropertyInfo          itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
            Array items = itemProperty.GetValue(info.Instance) as Array;

            Assert.Equal((obj as IEnumerable).Cast <object>().ToArray(), items.Cast <object>());
        }
Exemplo n.º 14
0
 public static void DebuggerAttributeTests()
 {
     ObservableCollection<int> col = new ObservableCollection<int>(new[] {1, 2, 3, 4});
     DebuggerAttributes.ValidateDebuggerDisplayReferences(col);
     DebuggerAttributeInfo info = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(col);
     PropertyInfo itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute<DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
     int[] items = itemProperty.GetValue(info.Instance) as int[];
     Assert.Equal(col, items);
 }
Exemplo n.º 15
0
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableQueue.Create <int>());
            ImmutableQueue <string> queue        = ImmutableQueue.Create("One", "Two");
            DebuggerAttributeInfo   info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(queue);
            PropertyInfo            itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);

            string[] items = itemProperty.GetValue(info.Instance) as string[];
            Assert.Equal(queue, items);
        }
Exemplo n.º 16
0
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableHashSet.Create <string>());
            ImmutableHashSet <int> set          = ImmutableHashSet.Create(1, 2, 3);
            DebuggerAttributeInfo  info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(set);
            PropertyInfo           itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);

            int[] items = itemProperty.GetValue(info.Instance) as int[];
            Assert.Equal(set, items);
        }
Exemplo n.º 17
0
        public void ValidateDebuggerAttributes()
        {
            Channel <int> c = CreateChannel();

            for (int i = 1; i <= 10; i++)
            {
                c.Writer.WriteAsync(i);
            }
            DebuggerAttributes.ValidateDebuggerDisplayReferences(c);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(c);
        }
Exemplo n.º 18
0
 public static void TestDebuggerAttributes()
 {
     DebuggerAttributes.ValidateDebuggerDisplayReferences(new ConcurrentDictionary<string, int>());
     ConcurrentDictionary<string, int> dict = new ConcurrentDictionary<string, int>();
     dict.TryAdd("One", 1);
     dict.TryAdd("Two", 2);
     DebuggerAttributeInfo info = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(dict);
     PropertyInfo itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute<DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
     KeyValuePair<string, int>[] items = itemProperty.GetValue(info.Instance) as KeyValuePair<string, int>[];
     Assert.Equal(dict, items);
 }
Exemplo n.º 19
0
        public static void DebuggerAttributeTests()
        {
            CaptureCollection col = CreateCollection();

            DebuggerAttributes.ValidateDebuggerDisplayReferences(col);
            DebuggerAttributeInfo info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(col);
            PropertyInfo          itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);

            Capture[] items = itemProperty.GetValue(info.Instance) as Capture[];
            Assert.Equal(col, items);
        }
Exemplo n.º 20
0
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableArray.CreateBuilder <int>());
            ImmutableArray <string> .Builder builder = ImmutableArray.CreateBuilder <string>(4);
            builder.AddRange("One", "Two", "Three", "Four");
            DebuggerAttributeInfo info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(builder);
            PropertyInfo          itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);

            string[] items = itemProperty.GetValue(info.Instance) as string[];
            Assert.Equal(builder, items);
        }
Exemplo n.º 21
0
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableSortedDictionary.CreateBuilder <string, int>());
            ImmutableSortedDictionary <int, string> .Builder builder = ImmutableSortedDictionary.CreateBuilder <int, string>();
            builder.Add(1, "One");
            builder.Add(2, "Two");
            DebuggerAttributeInfo info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(builder);
            PropertyInfo          itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);

            KeyValuePair <int, string>[] items = itemProperty.GetValue(info.Instance) as KeyValuePair <int, string>[];
            Assert.Equal(builder, items);
        }
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableDictionary.Create<int, int>());
            ImmutableDictionary<string, int> dict = ImmutableDictionary.Create<string, int>().Add("One", 1).Add("Two", 2);
            DebuggerAttributeInfo info = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(dict);

            object rootNode = DebuggerAttributes.GetFieldValue(ImmutableDictionary.Create<string, string>(), "_root");
            DebuggerAttributes.ValidateDebuggerDisplayReferences(rootNode);
            PropertyInfo itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute<DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
            KeyValuePair<string, int>[] items = itemProperty.GetValue(info.Instance) as KeyValuePair<string, int>[];
            Assert.Equal(dict, items);
        }
Exemplo n.º 23
0
    public void DebuggerAttributeTests()
    {
        DebuggerAttributes.ValidateDebuggerDisplayReferences(new Queue());

        var testQueue = new Queue();

        testQueue.Enqueue("a");
        testQueue.Enqueue(1);
        testQueue.Enqueue("b");
        testQueue.Enqueue(2);
        DebuggerAttributes.ValidateDebuggerTypeProxyProperties(testQueue);
    }
Exemplo n.º 24
0
        public void ValidateInternalDebuggerAttributes()
        {
            Channel <int> c = CreateChannel();

            Assert.True(c.Writer.TryWrite(1));
            Assert.True(c.Writer.TryWrite(2));

            object queue = DebuggerAttributes.GetFieldValue(c, "_items");

            DebuggerAttributes.ValidateDebuggerDisplayReferences(queue);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(queue);
        }
Exemplo n.º 25
0
        public void DebuggerAttributeTests()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(new Stack());

            var testStack = new Stack();

            testStack.Push("a");
            testStack.Push(1);
            testStack.Push("b");
            testStack.Push(2);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(testStack);
        }
Exemplo n.º 26
0
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableSortedSet.CreateBuilder <string>());
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(ImmutableSortedSet.CreateBuilder <int>());
            ImmutableSortedSet <int> .Builder builder = ImmutableSortedSet.CreateBuilder <int>();
            builder.Add(1);
            builder.Add(2);
            builder.Add(3);
            DebuggerAttributeInfo info         = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(builder);
            PropertyInfo          itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);

            int[] items = itemProperty.GetValue(info.Instance) as int[];
            Assert.Equal(builder, items);
        }
        public void ValidateDebuggerAttributes()
        {
            var spscq = new SingleProducerSingleConsumerQueue <int>();

            DebuggerAttributes.ValidateDebuggerDisplayReferences(spscq);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(spscq);

            for (int i = 0; i < 10; i++)
            {
                spscq.Enqueue(i);
            }
            DebuggerAttributes.ValidateDebuggerDisplayReferences(spscq);
            DebuggerAttributes.ValidateDebuggerTypeProxyProperties(spscq);
        }
        public void DebuggerAttributesValid()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(ImmutableSortedSet.Create <int>());
            ImmutableSortedSet <string> set  = ImmutableSortedSet.Create("1", "2", "3");
            DebuggerAttributeInfo       info = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(set);

            object rootNode = DebuggerAttributes.GetFieldValue(ImmutableSortedSet.Create <object>(), "_root");

            DebuggerAttributes.ValidateDebuggerDisplayReferences(rootNode);
            PropertyInfo itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute <DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);

            string[] items = itemProperty.GetValue(info.Instance) as string[];
            Assert.Equal(set, items);
        }
Exemplo n.º 29
0
        public static void DebuggerAttribute_NullStack_ThrowsArgumentNullException()
        {
            bool threwNull = false;

            try
            {
                DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(Stack), null);
            }
            catch (TargetInvocationException ex)
            {
                threwNull = ex.InnerException is ArgumentNullException;
            }

            Assert.True(threwNull);
        }
Exemplo n.º 30
0
        public static void DebuggerAttribute()
        {
            DebuggerAttributes.ValidateDebuggerDisplayReferences(new Stack());

            var stack = new Stack();

            stack.Push("a");
            stack.Push(1);
            stack.Push("b");
            stack.Push(2);

            DebuggerAttributeInfo debuggerAttribute = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(stack);
            PropertyInfo          infoProperty      = debuggerAttribute.Properties.Single(property => property.Name == "Items");

            object[] items = (object[])infoProperty.GetValue(debuggerAttribute.Instance);

            Assert.Equal(stack.ToArray(), items);
        }