public void ToEcmaCref_NestedType_FourDeep()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Type,
                Namespace  = "Mono",
                TypeName   = "DocTest",
                NestedType = new EcmaDesc {
                    DescKind   = EcmaDesc.Kind.Type,
                    TypeName   = "NestedClass",
                    NestedType = new EcmaDesc {
                        DescKind   = EcmaDesc.Kind.Type,
                        TypeName   = "Double",
                        NestedType = new EcmaDesc {
                            DescKind   = EcmaDesc.Kind.Type,
                            TypeName   = "Triple",
                            NestedType = new EcmaDesc {
                                DescKind = EcmaDesc.Kind.Type,
                                TypeName = "Quadruple",
                            },
                        },
                    },
                },
            };

            string targetUrl = "T:Mono.DocTest+NestedClass+Double+Triple+Quadruple";

            AssertEcmaString(targetUrl, actual);
            AssertUrlDesc(actual, targetUrl);
        }
        public void MethodWithArgsUrlParseTest()
        {
            var args = new[] {
                new EcmaDesc {
                    DescKind  = EcmaDesc.Kind.Type,
                    Namespace = "System",
                    TypeName  = "String"
                },
                new EcmaDesc {
                    DescKind  = EcmaDesc.Kind.Type,
                    TypeName  = "Int32",
                    Namespace = string.Empty
                }
            };
            var ast = new EcmaDesc()
            {
                DescKind        = EcmaDesc.Kind.Method,
                TypeName        = "String",
                Namespace       = "System",
                MemberName      = "FooBar",
                MemberArguments = args
            };

            AssertUrlDesc(ast, "M:System.String.FooBar(System.String, Int32)");
        }
示例#3
0
        public static string ToDisplayName(this EcmaDesc desc)
        {
            if (desc == null)
            {
                return(null);
            }

            string name = null;

            if (desc.GenericTypeArgumentsCount == 0)
            {
                name = desc.TypeName;
            }
            else
            {
                name = string.Format("{0}<{1}>", desc.TypeName, string.Join(",", desc.GenericTypeArguments.Select(d => d.ToDisplayName())));
            }
            if (desc.NestedType != null)
            {
                name += ("." + desc.NestedType.TypeName);
            }
            if (desc.ArrayDimensions?.Count > 0)
            {
                for (int i = 0; i < desc.ArrayDimensions?.Count; i++)
                {
                    name += "[]";
                }
            }
            if (desc.DescModifier == EcmaDesc.Mod.Pointer)
            {
                name += "*";
            }

            return(name);
        }
        public void TypeWithNestedGenericUrlParseTest()
        {
            var generics = new[] {
                new EcmaDesc {
                    DescKind  = EcmaDesc.Kind.Type,
                    TypeName  = "T",
                    Namespace = string.Empty
                },
                new EcmaDesc {
                    DescKind             = EcmaDesc.Kind.Type,
                    Namespace            = "System.Collections.Generic",
                    TypeName             = "List",
                    GenericTypeArguments = new[] {
                        new EcmaDesc {
                            DescKind  = EcmaDesc.Kind.Type,
                            TypeName  = "V",
                            Namespace = string.Empty
                        }
                    }
                }
            };
            var ast = new EcmaDesc()
            {
                DescKind             = EcmaDesc.Kind.Type,
                TypeName             = "String",
                Namespace            = "System",
                GenericTypeArguments = generics,
            };

            AssertUrlDesc(ast, "T:System.String<T, System.Collections.Generic.List<V>>");
        }
        public void MethodWithArgsAndGenericsUrlParseTest()
        {
            var args = new[] {
                new EcmaDesc {
                    DescKind  = EcmaDesc.Kind.Type,
                    Namespace = "System",
                    TypeName  = "String"
                },
                new EcmaDesc {
                    DescKind             = EcmaDesc.Kind.Type,
                    Namespace            = "System.Collections.Generic",
                    TypeName             = "Dictionary",
                    GenericTypeArguments = new[] {
                        new EcmaDesc {
                            DescKind  = EcmaDesc.Kind.Type,
                            TypeName  = "K",
                            Namespace = string.Empty
                        },
                        new EcmaDesc {
                            DescKind  = EcmaDesc.Kind.Type,
                            TypeName  = "V",
                            Namespace = string.Empty
                        }
                    }
                }
            };

            var generics = new[] {
                new EcmaDesc {
                    DescKind             = EcmaDesc.Kind.Type,
                    TypeName             = "Action",
                    Namespace            = string.Empty,
                    GenericTypeArguments = new[] {
                        new EcmaDesc {
                            DescKind  = EcmaDesc.Kind.Type,
                            Namespace = "System",
                            TypeName  = "Single",
                        },
                        new EcmaDesc {
                            DescKind  = EcmaDesc.Kind.Type,
                            TypeName  = "int",
                            Namespace = string.Empty
                        },
                    }
                }
            };

            var ast = new EcmaDesc()
            {
                DescKind               = EcmaDesc.Kind.Method,
                TypeName               = "String",
                Namespace              = "System",
                MemberName             = "FooBar",
                MemberArguments        = args,
                GenericMemberArguments = generics
            };

            AssertUrlDesc(ast, "M:System.String.FooBar<Action<System.Single, int>>(System.String, System.Collections.Generic.Dictionary<K, V>)");
        }
        public void ToEcmaCref_Namespace()
        {
            var actual = new EcmaDesc {
                DescKind  = EcmaDesc.Kind.Namespace,
                Namespace = "System.IO",
            };

            AssertEcmaString("N:System.IO", actual);
        }
        public void ToEcmaCref_SimpleType()
        {
            var actual = new EcmaDesc {
                DescKind  = EcmaDesc.Kind.Type,
                Namespace = "System.IO",
                TypeName  = "Path",
            };

            AssertEcmaString("T:System.IO.Path", actual);
        }
示例#8
0
        static int GenericTypeBacktickSearch(IList <Node> childNodes, EcmaDesc desc)
        {
            /* Our strategy is to search for the non-generic variant of the type
             * (which in most case should fail) and then use the closest index
             * to linearily search for the generic variant with the right generic arg number
             */
            var searchNode = new Node()
            {
                Caption = desc.TypeName
            };
            int index = childNodes.BinarySearch(searchNode, EcmaTypeNodeComparer.Instance);

            // Place the index in the right start position
            if (index < 0)
            {
                index = ~index;
            }

            for (int i = index; i < childNodes.Count; i++)
            {
                var currentNode = childNodes[i];
                // Find the index of the generic argument list
                int genericIndex = currentNode.Caption.IndexOf('<');
                // If we are not on the same base type name anymore, there is no point
                int captionSlice = genericIndex != -1 ? genericIndex : currentNode.Caption.LastIndexOf(' ');
                if (string.Compare(searchNode.Caption, 0,
                                   currentNode.Caption, 0,
                                   Math.Max(captionSlice, searchNode.Caption.Length),
                                   StringComparison.Ordinal) != 0)
                {
                    break;
                }

                var numGenerics = CountTypeGenericArguments(currentNode.Caption, genericIndex);
                if (numGenerics == desc.GenericTypeArguments.Count)
                {
                    // Simple comparison if we are not looking for an inner type
                    if (desc.NestedType == null)
                    {
                        return(i);
                    }
                    // If more complicated, we fallback to using EcmaUrlParser
                    var caption = currentNode.Caption;
                    caption = "T:" + caption.Substring(0, caption.LastIndexOf(' ')).Replace('.', '+');
                    EcmaDesc otherDesc;
                    var      parser = new EcmaUrlParser();
                    if (parser.TryParse(caption, out otherDesc) && desc.NestedType.Equals(otherDesc.NestedType))
                    {
                        return(i);
                    }
                }
            }

            return(-1);
        }
        public void ToEcmaCref_Method()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Method,
                Namespace  = "System",
                TypeName   = "Int32",
                MemberName = "Add"
            };

            AssertEcmaString("M:System.Int32.Add", actual);
        }
        public void ToEcmaCref_SimpleType_WithGenerics()
        {
            var actual = new EcmaDesc {
                DescKind             = EcmaDesc.Kind.Type,
                Namespace            = "System.IO",
                TypeName             = "Path",
                GenericTypeArguments = GenericTypeArgumentsList("K").ToArray()
            };

            AssertEcmaString("T:System.IO.Path<K>", actual);
        }
        public void JaggedArrayWithDimensions()
        {
            var ast = new EcmaDesc {
                DescKind        = EcmaDesc.Kind.Type,
                TypeName        = "Int32",
                Namespace       = "System",
                ArrayDimensions = new int[] { 3, 1, 1 }
            };

            AssertUrlDesc(ast, "T:System.Int32[,,][][]");
        }
        public void ToEcmaCref_Property()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Property,
                Namespace  = "System.IO",
                TypeName   = "Path",
                MemberName = "TheProperty",
            };

            AssertEcmaString("P:System.IO.Path.TheProperty", actual);
        }
        public void ToEcmaCref_Field()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Field,
                Namespace  = "System.IO",
                TypeName   = "Path",
                MemberName = "TheField"
            };

            AssertEcmaString("F:System.IO.Path.TheField", actual);
        }
        public void ToEcmaCref_Event()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Event,
                Namespace  = "System.IO",
                TypeName   = "Path",
                MemberName = "TheEvent",
            };

            AssertEcmaString("E:System.IO.Path.TheEvent", actual);
        }
        public void ToEcmaCref_Operator()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Operator,
                Namespace  = "System",
                TypeName   = "Int32",
                MemberName = "Addition",
            };

            AssertEcmaString("O:System.Int32.Addition", actual);
        }
示例#16
0
		void AssertUrlDesc (EcmaDesc expected, string url)
		{
			EcmaDesc actual = null;
			try {
				actual = parser.Parse (url);
			} catch (Exception e) {
				Assert.Fail (string.Format ("URL '{0}' deemed not valid: {1}{2}", url, Environment.NewLine, e.ToString ()));
			}

			Assert.AreEqual (expected, actual, "Converted URL differs");
		}
        public void SimpleMethodWithNumberInType()
        {
            var ast = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Method,
                TypeName   = "ASN1",
                Namespace  = "Mono.Security",
                MemberName = "Add"
            };

            AssertUrlDesc(ast, "M:Mono.Security.ASN1.Add");
        }
        public void SimpleTypeUrlParseTest()
        {
            var ast = new EcmaDesc()
            {
                DescKind  = EcmaDesc.Kind.Type,
                TypeName  = "String",
                Namespace = "System"
            };

            AssertUrlDesc(ast, "T:System.String");
        }
        public void ToEcmaCref_Method_Generics()
        {
            var actual = new EcmaDesc {
                DescKind               = EcmaDesc.Kind.Method,
                Namespace              = "System",
                TypeName               = "Int32",
                MemberName             = "Add",
                GenericMemberArguments = GenericTypeArgumentsList("T", "K").ToArray(),
            };

            AssertEcmaString("M:System.Int32.Add<T,K>", actual);
        }
        public void MetaEtcNodeTest()
        {
            var ast = new EcmaDesc()
            {
                DescKind  = EcmaDesc.Kind.Type,
                Namespace = "Foo.Bar",
                TypeName  = "Type",
                Etc       = '*'
            };

            AssertUrlDesc(ast, "T:Foo.Bar.Type/*");
        }
        void AssertUrlDesc(EcmaDesc expected, string url)
        {
            EcmaDesc actual = null;

            try {
                actual = parser.Parse(url);
            } catch (Exception e) {
                Assert.Fail(string.Format("URL '{0}' deemed not valid: {1}{2}", url, Environment.NewLine, e.ToString()));
            }

            Assert.AreEqual(expected, actual, "Converted URL differs");
        }
        public void SimpleMethodUrlParseTest()
        {
            var ast = new EcmaDesc()
            {
                DescKind   = EcmaDesc.Kind.Method,
                TypeName   = "String",
                Namespace  = "System",
                MemberName = "FooBar"
            };

            AssertUrlDesc(ast, "M:System.String.FooBar()");
        }
        public void ToEcmaCref_NestedType()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Type,
                Namespace  = "System.IO",
                TypeName   = "Path",
                NestedType = new EcmaDesc {
                    DescKind = EcmaDesc.Kind.Type,
                    TypeName = "TheNestedType",
                },
            };

            AssertEcmaString("T:System.IO.Path+TheNestedType", actual);
        }
        public void NamespaceValidTest()
        {
            AssertValidUrl("N:Foo.Bar");
            AssertValidUrl("N:Foo");
            AssertValidUrl("N:Foo.Bar.Baz");
            AssertValidUrl("N:A.B.C");

            var ast = new EcmaDesc()
            {
                DescKind  = EcmaDesc.Kind.Namespace,
                Namespace = "Foo.Bar.Blop"
            };

            AssertUrlDesc(ast, "N:Foo.Bar.Blop");
        }
        public void ToEcmaCref_NestedType_Field()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Field,
                Namespace  = "System.IO",
                TypeName   = "Path",
                NestedType = new EcmaDesc {
                    DescKind = EcmaDesc.Kind.Type,
                    TypeName = "TheNestedType",
                },
                MemberName = "NestedField"
            };

            AssertEcmaString("F:System.IO.Path+TheNestedType.NestedField", actual);
        }
示例#26
0
        public static string ToOuterTypeUid(this EcmaDesc desc)
        {
            if (desc == null)
            {
                return(null);
            }
            var typeStr = string.IsNullOrEmpty(desc.Namespace) ? desc.TypeName : (desc.Namespace + "." + desc.TypeName);

            if (desc.GenericTypeArgumentsCount > 0)
            {
                typeStr += "`" + desc.GenericTypeArgumentsCount;
            }

            return(typeStr);
        }
        public void MetaEtcWithInnerTypeTest()
        {
            var ast = new EcmaDesc()
            {
                DescKind   = EcmaDesc.Kind.Type,
                Namespace  = "Novell.Directory.Ldap",
                TypeName   = "Connection",
                NestedType = new EcmaDesc {
                    DescKind = EcmaDesc.Kind.Type, TypeName = "ReaderThread"
                },
                Etc = '*'
            };

            AssertUrlDesc(ast, "T:Novell.Directory.Ldap.Connection+ReaderThread/*");
        }
        public void ExplicitMethodImplementationParseTest()
        {
            var inner = new EcmaDesc {
                MemberName = "Dispose",
                TypeName   = "IDisposable",
                Namespace  = "System"
            };
            var ast = new EcmaDesc {
                DescKind           = EcmaDesc.Kind.Method,
                TypeName           = "RegistryKey",
                Namespace          = "Microsoft.Win32",
                ExplicitImplMember = inner
            };

            AssertUrlDesc(ast, "M:Microsoft.Win32.RegistryKey$System.IDisposable.Dispose");
        }
        public void ToEcmaCref_ExplicitlyImplemented_Property()
        {
            var explicitImpl = new EcmaDesc {
                Namespace  = "System.Web.SessionState",
                TypeName   = "IHttpSessionState",
                MemberName = "Item",
            };
            var actual = new EcmaDesc {
                DescKind           = EcmaDesc.Kind.Property,
                TypeName           = "HttpSessionStateContainer",
                Namespace          = "System.Web.SessionState",
                ExplicitImplMember = explicitImpl,
            };

            AssertEcmaString("P:System.Web.SessionState.HttpSessionStateContainer$System.Web.SessionState.IHttpSessionState.Item", actual);
        }
        public void ToEcmaCref_Nestedype_WithGenericsOnBoth()
        {
            var actual = new EcmaDesc {
                DescKind   = EcmaDesc.Kind.Type,
                Namespace  = "System.IO",
                TypeName   = "Path",
                NestedType = new EcmaDesc {
                    DescKind             = EcmaDesc.Kind.Type,
                    TypeName             = "TheNestedType",
                    GenericTypeArguments = GenericTypeArgumentsList("T", "V").ToArray(),
                },
                GenericTypeArguments = GenericTypeArgumentsList("K").ToArray()
            };

            AssertEcmaString("T:System.IO.Path<K>+TheNestedType<T,V>", actual);
        }
示例#31
0
        public void TypeWithOneGenericUrlParseTest()
        {
            var generics = new[] {
                new EcmaDesc {
                    DescKind = EcmaDesc.Kind.Type,
                    TypeName = "T"
                }
            };
            var ast = new EcmaDesc()
            {
                DescKind             = EcmaDesc.Kind.Type,
                TypeName             = "String",
                Namespace            = "System",
                GenericTypeArguments = generics,
            };

            AssertUrlDesc(ast, "T:System.String<T>");
        }
示例#32
0
		public void ToEcmaCref_NestedType_Field ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Field,
				Namespace = "System.IO",
				TypeName = "Path",
				NestedType = new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					TypeName = "TheNestedType",
				},
				MemberName = "NestedField"
			};

			AssertEcmaString ("F:System.IO.Path+TheNestedType.NestedField", actual);
		}
示例#33
0
		public void ToEcmaCref_Method_Parameters ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Method,
				Namespace = "System",
				TypeName = "Int32",
				MemberName = "Add",
				MemberArguments = new [] { 
					new EcmaDesc {
						DescKind = EcmaDesc.Kind.Type,
						Namespace = "System",
						TypeName = "Double",
					},
					new EcmaDesc {
						DescKind = EcmaDesc.Kind.Type,
						Namespace = "System",
						TypeName = "Int32",
					},
				},
			};

			AssertEcmaString ("M:System.Int32.Add(System.Double,System.Int32)", actual);
		}
示例#34
0
		public void ExplicitMethodImplementationParseTest ()
		{
			var inner = new EcmaDesc {
				MemberName = "Dispose",
				TypeName = "IDisposable",
				Namespace = "System"
			};
			var ast = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Method,
				TypeName = "RegistryKey",
				Namespace = "Microsoft.Win32",
				ExplicitImplMember = inner
			};
			AssertUrlDesc (ast, "M:Microsoft.Win32.RegistryKey$System.IDisposable.Dispose");
			var actual = parser.Parse ("M:Microsoft.Win32.RegistryKey$System.IDisposable.Dispose");
			Assert.IsNotNull (actual.ExplicitImplMember);
			Assert.AreEqual ("System.IDisposable.Dispose", ast.ToCompleteMemberName (EcmaDesc.Format.WithoutArgs));
		}
示例#35
0
		public void ToEcmaCref_Method ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Method,
				Namespace = "System",
				TypeName = "Int32",
				MemberName = "Add"
			};

			AssertEcmaString ("M:System.Int32.Add", actual);
		}
示例#36
0
		public void TypeWithNestedGenericUrlParseTest ()
		{
			var generics = new[] {
				new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					TypeName = "T",
					Namespace = string.Empty
				},
				new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					Namespace = "System.Collections.Generic",
					TypeName = "List",
					GenericTypeArguments = new[] {
						new EcmaDesc {
							DescKind = EcmaDesc.Kind.Type,
							TypeName = "V",
							Namespace = string.Empty
						}
					}
				}
			};
			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Type,
			                            TypeName = "String",
			                            Namespace = "System",
			                            GenericTypeArguments = generics,
			};

			AssertUrlDesc (ast, "T:System.String<T, System.Collections.Generic.List<V>>");
		}
示例#37
0
		public void MethodWithArgsUrlParseTest ()
		{
			var args = new[] {
				new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					Namespace = "System",
					TypeName = "String"
				},
				new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					TypeName = "Int32",
					Namespace = string.Empty
				}
			};
			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Method,
			                            TypeName = "String",
			                            Namespace = "System",
			                            MemberName = "FooBar",
			                            MemberArguments = args
			};
			AssertUrlDesc (ast, "M:System.String.FooBar(System.String, Int32)");
		}
示例#38
0
		public void ToEcmaCref_Method_Generics_PlusParameters ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Method,
				Namespace = "System",
				TypeName = "Int32",
				MemberName = "Add",
				GenericMemberArguments = GenericTypeArgumentsList ("T", "K").ToArray (),
				MemberArguments = new [] { 
					new EcmaDesc {
						DescKind = EcmaDesc.Kind.Type,
						Namespace = "",
						TypeName = "T",
					},
					new EcmaDesc {
						DescKind = EcmaDesc.Kind.Type,
						Namespace = "",
						TypeName = "K",
					},
				},
			};

			AssertEcmaString ("M:System.Int32.Add<T,K>(T,K)", actual);
		}
示例#39
0
		public void SimpleTypeUrlParseTest ()
		{
			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Type,
			                            TypeName = "String",
			                            Namespace = "System" };
			AssertUrlDesc (ast, "T:System.String");
		}
示例#40
0
		public void ExplicitMethodImplementationParseTest ()
		{
			var inner = new EcmaDesc {
				MemberName = "Dispose",
				TypeName = "IDisposable",
				Namespace = "System"
			};
			var ast = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Method,
				TypeName = "RegistryKey",
				Namespace = "Microsoft.Win32",
				ExplicitImplMember = inner
			};
			AssertUrlDesc (ast, "M:Microsoft.Win32.RegistryKey$System.IDisposable.Dispose");
		}
示例#41
0
		public void JaggedArrayWithDimensions ()
		{
			var ast = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Type,
				TypeName = "Int32",
				Namespace = "System",
				ArrayDimensions = new int[] { 3, 1, 1 }
			};
			AssertUrlDesc (ast, "T:System.Int32[,,][][]");
		}
示例#42
0
		public void ToEcmaCref_ExplicitlyImplemented_Property ()
		{
			var explicitImpl = new EcmaDesc {
				Namespace = "System.Web.SessionState",
				TypeName = "IHttpSessionState",
				MemberName = "Item",
			};
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Property,
				TypeName = "HttpSessionStateContainer",
				Namespace = "System.Web.SessionState",
				ExplicitImplMember = explicitImpl,
			};
			AssertEcmaString ("P:System.Web.SessionState.HttpSessionStateContainer$System.Web.SessionState.IHttpSessionState.Item", actual);
		}
示例#43
0
		public void ToEcmaCref_ExplicitlyImplemented_Method ()
		{
			var explicitImpl = new EcmaDesc {
				Namespace = "System.Web.SessionState",
				TypeName = "IHttpSessionState",
				MemberName = "Item",
				MemberArguments = new [] {
					new EcmaDesc {
						DescKind = EcmaDesc.Kind.Type,
						Namespace = "System",
						TypeName = "Int32",
					},
				},
			};
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Method,
				TypeName = "HttpSessionStateContainer",
				Namespace = "System.Web.SessionState",
				ExplicitImplMember = explicitImpl,
			};
			AssertEcmaString ("M:System.Web.SessionState.HttpSessionStateContainer$System.Web.SessionState.IHttpSessionState.Item(System.Int32)", actual);
		}
示例#44
0
		void AssertEcmaString (string expected, EcmaDesc actual)
		{
			string actualString = actual.ToEcmaCref ();
			Assert.AreEqual (expected, actualString);
		}
示例#45
0
		public void MetaEtcNodeTest ()
		{
			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Type,
			                            Namespace = "Foo.Bar",
			                            TypeName = "Type",
			                            Etc = '*' };
			AssertUrlDesc (ast, "T:Foo.Bar.Type/*");
		}
示例#46
0
		public void ToEcmaCref_Operator ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Operator,
				Namespace = "System",
				TypeName = "Int32",
				MemberName = "Addition",
			};

			AssertEcmaString ("O:System.Int32.Addition", actual);
		}
示例#47
0
		public void MetaEtcWithInnerTypeTest ()
		{
			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Type,
			                            Namespace = "Novell.Directory.Ldap",
			                            TypeName = "Connection",
			                            NestedType = new EcmaDesc { DescKind = EcmaDesc.Kind.Type, TypeName = "ReaderThread" },
			                            Etc = '*' };
			AssertUrlDesc (ast, "T:Novell.Directory.Ldap.Connection+ReaderThread/*");
		}
示例#48
0
		public void ToEcmaCref_Operator_Conversion ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Operator,
				Namespace = "System",
				TypeName = "Int32",
				MemberName = "ExplicitConversion",
				MemberArguments = new [] { 
					new EcmaDesc { 
						DescKind = EcmaDesc.Kind.Type,
						Namespace = "System",
						TypeName = "Double",
					},
					new EcmaDesc {
						DescKind = EcmaDesc.Kind.Type,
						Namespace = "System",
						TypeName = "Int32",
					}
				},
			};

			AssertEcmaString ("O:System.Int32.ExplicitConversion(System.Double,System.Int32)", actual);
		}
示例#49
0
		public void TypeWithOneGenericUrlParseTest ()
		{
			var generics = new[] {
				new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					Namespace = string.Empty,
					TypeName = "T"
				}
			};
			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Type,
			                            TypeName = "String",
			                            Namespace = "System",
			                            GenericTypeArguments = generics,
			};

			AssertUrlDesc (ast, "T:System.String<T>");
		}
示例#50
0
		public void ToEcmaCref_Nestedype_Property_WithGenericsOnBoth ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Property,
				Namespace = "System.IO",
				TypeName = "Path",
				NestedType = new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					TypeName = "TheNestedType",
					GenericTypeArguments = GenericTypeArgumentsList ("T", "V").ToArray (),
				},
				GenericTypeArguments = GenericTypeArgumentsList ("K").ToArray (),
				MemberName = "TheProperty"
			};

			AssertEcmaString ("P:System.IO.Path<K>+TheNestedType<T,V>.TheProperty", actual);
		}
示例#51
0
		public void SimpleMethodUrlParseTest ()
		{
			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Method,
			                            TypeName = "String",
			                            Namespace = "System",
			                            MemberName = "FooBar"
			};
			AssertUrlDesc (ast, "M:System.String.FooBar()");
		}
示例#52
0
		public void ToEcmaCref_Nestedype_WithGenerics ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Type,
				Namespace = "System.IO",
				TypeName = "Path",
				NestedType = new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					TypeName = "TheNestedType",
				},
				GenericTypeArguments = GenericTypeArgumentsList ("K").ToArray ()
			};

			AssertEcmaString ("T:System.IO.Path<K>+TheNestedType", actual);
		}
示例#53
0
		public void MethodWithArgsAndGenericsUrlParseTest ()
		{
			var args = new[] {
				new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					Namespace = "System",
					TypeName = "String"
				},
				new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					Namespace = "System.Collections.Generic",
					TypeName = "Dictionary",
					GenericTypeArguments = new[] {
						new EcmaDesc {
							DescKind = EcmaDesc.Kind.Type,
							TypeName = "K",
							Namespace = string.Empty
						},
						new EcmaDesc {
							DescKind = EcmaDesc.Kind.Type,
							TypeName = "V",
							Namespace = string.Empty
						}
					}
				}
			};

			var generics = new[] {
				new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					TypeName = "Action",
					Namespace = string.Empty,
					GenericTypeArguments = new[] {
						new EcmaDesc {
							DescKind = EcmaDesc.Kind.Type,
							Namespace = "System",
							TypeName = "Single",
						},
						new EcmaDesc {
							DescKind = EcmaDesc.Kind.Type,
							TypeName = "int",
							Namespace = string.Empty
						},
					}
				}
			};

			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Method,
			                            TypeName = "String",
			                            Namespace = "System",
			                            MemberName = "FooBar",
			                            MemberArguments = args,
			                            GenericMemberArguments = generics
			};
			AssertUrlDesc (ast, "M:System.String.FooBar<Action<System.Single, int>>(System.String, System.Collections.Generic.Dictionary<K, V>)");
		}
示例#54
0
		public void ToEcmaCref_Event ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Event,
				Namespace = "System.IO",
				TypeName = "Path",
				MemberName = "TheEvent",
			};

			AssertEcmaString ("E:System.IO.Path.TheEvent", actual);
		}
示例#55
0
		public void SimpleMethodWithNumberInType ()
		{
			var ast = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Method,
				TypeName = "ASN1",
				Namespace = "Mono.Security",
				MemberName = "Add"
			};
			AssertUrlDesc (ast, "M:Mono.Security.ASN1.Add");
		}
示例#56
0
		public void ToEcmaCref_Property ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Property,
				Namespace = "System.IO",
				TypeName = "Path",
				MemberName = "TheProperty",
			};

			AssertEcmaString ("P:System.IO.Path.TheProperty", actual);
		}
示例#57
0
		public void ExplicitIndexerImplementation ()
		{
			var explicitImpl = new EcmaDesc {
				Namespace = "System.Web.SessionState",
				TypeName = "IHttpSessionState",
				MemberName = "Item",
				MemberArguments = new [] { new EcmaDesc { DescKind = EcmaDesc.Kind.Type, Namespace = "System", TypeName = "Int32" } },
			};
			var ast = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Property,
				TypeName = "HttpSessionStateContainer",
				Namespace = "System.Web.SessionState",
				ExplicitImplMember = explicitImpl,
			};
			AssertUrlDesc (ast, "P:System.Web.SessionState.HttpSessionStateContainer$System.Web.SessionState.IHttpSessionState.Item(System.Int32)");
		}
示例#58
0
		public void ToEcmaCref_Field ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Field,
				Namespace = "System.IO",
				TypeName = "Path",
				MemberName = "TheField"
			};

			AssertEcmaString ("F:System.IO.Path.TheField", actual);
		}
示例#59
0
		public void NamespaceValidTest ()
		{
			AssertValidUrl ("N:Foo.Bar");
			AssertValidUrl ("N:Foo");
			AssertValidUrl ("N:Foo.Bar.Baz");
			AssertValidUrl ("N:A.B.C");

			var ast = new EcmaDesc () { DescKind = EcmaDesc.Kind.Namespace,
			                            Namespace = "Foo.Bar.Blop" };
			AssertUrlDesc (ast, "N:Foo.Bar.Blop");
		}
示例#60
0
		public void ToEcmaCref_NestedType_FourDeep ()
		{
			var actual = new EcmaDesc {
				DescKind = EcmaDesc.Kind.Type,
				Namespace = "Mono",
				TypeName = "DocTest",
				NestedType = new EcmaDesc {
					DescKind = EcmaDesc.Kind.Type,
					TypeName = "NestedClass",
					NestedType = new EcmaDesc {
						DescKind = EcmaDesc.Kind.Type,
						TypeName = "Double",
						NestedType = new EcmaDesc {
							DescKind = EcmaDesc.Kind.Type,
							TypeName = "Triple",
							NestedType = new EcmaDesc {
								DescKind = EcmaDesc.Kind.Type,
								TypeName = "Quadruple",
							},
						},
					},
				},
			};

			string targetUrl = "T:Mono.DocTest+NestedClass+Double+Triple+Quadruple";
			AssertEcmaString (targetUrl, actual);
			AssertUrlDesc (actual, targetUrl);
		}