Пример #1
0
        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);
        }
Пример #2
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>());
        }
Пример #3
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);
 }
        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);
        }
Пример #5
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);
        }
Пример #6
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);
        }
        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);
        }
Пример #8
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);
 }
Пример #9
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);
        }
        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);
        }
Пример #12
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);
        }
Пример #13
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);
        }
Пример #14
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);

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

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

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