Esempio n. 1
0
        public void DotNetMethod_FromAssembly_OptionalParameter()
        {
            //arrange
            XElement   xmlTypeElement   = XElement.Parse("<member name='T:DataFilesTest.DotNetMethodTests.NormalClass' />", LoadOptions.PreserveWhitespace);
            XElement   xmlMemberElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.NormalClass.MethodOptional(System.Int32,System.String)' />", LoadOptions.PreserveWhitespace);
            Type       type             = typeof(NormalClass);
            DotNetType dotNetType       = new DotNetType(new DotNetQualifiedClassName("DataFilesTest.DotNetMethodTests.NormalClass"));

            dotNetType.AddMember(DotNetMethod.FromVisualStudioXml(xmlMemberElement));
            //act
            dotNetType.AddAssemblyInfo(type, dotNetType.Name);
            DotNetMethod result = dotNetType.Methods[0];

            //assert
            Assert.AreEqual(2, result.MethodName.Parameters.Count);
            Assert.AreEqual("System.Int32", result.MethodName.Parameters[0].FullTypeName);
            Assert.AreEqual("a", result.MethodName.Parameters[0].Name);
            Assert.AreEqual(ParameterCategory.Optional, result.MethodName.Parameters[0].Category);
            Assert.AreEqual(5, result.MethodName.Parameters[0].DefaultValue);
            Assert.AreEqual("System.String", result.MethodName.Parameters[1].FullTypeName);
            Assert.AreEqual("b", result.MethodName.Parameters[1].Name);
            Assert.AreEqual(ParameterCategory.Optional, result.MethodName.Parameters[1].Category);
            Assert.IsNull(result.MethodName.Parameters[1].DefaultValue);
            Assert.AreEqual("System.String b = null", result.MethodName.Parameters[1].SignatureWithName);
        }
Esempio n. 2
0
        public void RegisterFunction(string s)
        {
            MethodInfo   mi = GetType().GetMethod(s);
            DotNetMethod m  = new DotNetMethod(mi, DotNetObject.Marshal(this));

            vm.AddVar(s, m);
        }
Esempio n. 3
0
 public static MethodArgStack MethodPtr(DotNetMethod method)
 {
     return(new MethodArgStack()
     {
         type = StackItemType.MethodPtr, value = method
     });
 }
Esempio n. 4
0
        public void DotNetMethod_FromXml_GenericParameter()
        {
            //arrange
            XElement xmlElement       = XElement.Parse("<member name='M:Demo.DoubleGenericClass`2.op_Addition(`0,Demo.DoubleGenericClass{`0,`1})' />", LoadOptions.PreserveWhitespace);
            string   expectedFullName = "Demo.DoubleGenericClass<T,U>.op_Addition";
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            //assert
            Assert.AreEqual(expectedFullName, result.Name.FullName);
        }
Esempio n. 5
0
        public void DotNetMethodOperator_Equals_True()
        {
            //arrange
            string               xml     = "<member name='M:MyNamespace.MyClass.op_Addition(MyNamespace.MyClass,System.Int32)' />";
            XElement             element = XElement.Parse(xml, LoadOptions.PreserveWhitespace);
            DotNetMethodOperator a       = (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(element);
            DotNetMethodOperator b       = (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(element);
            //act
            bool result = (a == b);

            //assert
            Assert.IsTrue(result);
        }
Esempio n. 6
0
        public void DotNetMethod_FromAssembly_AbstractClassProtectedMethod()
        {
            //arrange
            XElement   xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.AbstractClass.MethodProtected()'></member>", LoadOptions.PreserveWhitespace);
            Type       type       = typeof(AbstractClass);
            MethodInfo methodInfo = type.GetDeclaredMethods().First(m => m.Name == "MethodProtected");
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            result.AddAssemblyInfo(methodInfo);
            //assert
            Assert.AreEqual(MethodCategory.Protected, result.Category);
        }
Esempio n. 7
0
        public void DotNetMethod_FromAssembly_ParamComment()
        {
            //arrange
            XElement   xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.ParameterClass.MethodOneNormalParameter(System.Int32)'><param name='a'>Comments</param></member>", LoadOptions.PreserveWhitespace);
            Type       type       = typeof(ParameterClass);
            MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "MethodOneNormalParameter");
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            result.AddAssemblyInfo(methodInfo);
            //assert
            Assert.AreEqual(1, result.ParameterComments.Count);
            Assert.IsNotNull(result.ParameterComments[0]);
        }
        public void DotNetMethodConstructor_FromAssembly_StaticConstructor()
        {
            //arrange
            XElement        xmlElement      = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodConstructorTests.ClassA.#cctor' />", LoadOptions.PreserveWhitespace);
            Type            type            = typeof(ClassA);
            ConstructorInfo constructorInfo = type.GetDeclaredConstructors().First(m => m.Name == ".cctor");
            //act
            DotNetMethod            result            = DotNetMethod.FromVisualStudioXml(xmlElement);
            DotNetMethodConstructor constructorResult = (result as DotNetMethodConstructor);

            constructorResult.AddAssemblyInfo(constructorInfo);
            //assert
            Assert.AreEqual(MethodCategory.Static, constructorResult.Category);
        }
Esempio n. 9
0
        public void DotNetMethod_FromAssembly_MethodOneGeneric_AddedToMethod()
        {
            //arrange
            XElement   xmlElement       = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.NormalClass.MethodOneGeneric``1' />", LoadOptions.PreserveWhitespace);
            string     expectedFullName = "DataFilesTest.DotNetMethodTests.NormalClass.MethodOneGeneric<CustomA>";
            Type       type             = typeof(NormalClass);
            MethodInfo methodInfo       = type.GetMethods().First(m => m.Name == "MethodOneGeneric");
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            result.AddAssemblyInfo(methodInfo);
            //assert
            Assert.AreEqual(expectedFullName, result.Name.FullName);
        }
Esempio n. 10
0
        public void DotNetMethodOperator_FromAssembly_ExplicitOperator()
        {
            //arrange
            XElement   xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodOperatorTests.ClassA.op_Explicit(DataFilesTest.DotNetMethodOperatorTests.ClassA)~System.Int64' />", LoadOptions.PreserveWhitespace);
            Type       type       = typeof(ClassA);
            MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "op_Explicit");
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            result.AddAssemblyInfo(methodInfo);
            //assert
            Assert.AreEqual("System.Single", result.MethodName.ReturnTypeName);
            Assert.AreEqual("DataFilesTest.DotNetMethodOperatorTests.ClassA", result.MethodName.Parameters[0].TypeName);
        }
Esempio n. 11
0
        public void DotNetMethod_FromAssembly_ZeroParameters()
        {
            //arrange
            XElement   xmlElement       = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.ParameterClass.MethodZeroParameters' />", LoadOptions.PreserveWhitespace);
            string     expectedFullName = "DataFilesTest.DotNetMethodTests.ParameterClass.MethodZeroParameters";
            Type       type             = typeof(ParameterClass);
            MethodInfo methodInfo       = type.GetMethods().First(m => m.Name == "MethodZeroParameters");
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            result.AddAssemblyInfo(methodInfo);
            //assert
            Assert.AreEqual(expectedFullName, result.Name.FullName);
            Assert.AreEqual(0, result.MethodName.Parameters.Count);
        }
Esempio n. 12
0
        public void DotNetMethodOperator_Equals_DifferentParameterCounts_False()
        {
            //arrange
            string               xmlA     = "<member name='M:MyNamespace.MyClass.op_Addition(MyNamespace.MyClass,System.Int32)' />";
            string               xmlB     = "<member name='M:MyNamespace.MyClass.op_Addition(MyNamespace.MyClass)' />";
            XElement             elementA = XElement.Parse(xmlA, LoadOptions.PreserveWhitespace);
            XElement             elementB = XElement.Parse(xmlB, LoadOptions.PreserveWhitespace);
            DotNetMethodOperator a        = (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(elementA);
            DotNetMethodOperator b        = (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(elementB);
            //act
            bool result = (a == b);

            //assert
            Assert.IsFalse(result);
        }
Esempio n. 13
0
        public void DotNetMethod_FromAssembly_ReturnNestedGeneric()
        {
            //arrange
            XElement   xmlElement             = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.NormalClass.MethodReturnNestedGeneric' />", LoadOptions.PreserveWhitespace);
            string     expectedFullName       = "DataFilesTest.DotNetMethodTests.NormalClass.MethodReturnNestedGeneric";
            string     expectedReturnFullName = "DataFilesTest.DotNetMethodTests.GenericOne<System.String>.NestedGeneric<System.Int32>";
            Type       type       = typeof(NormalClass);
            MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "MethodReturnNestedGeneric");
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            result.AddAssemblyInfo(methodInfo);
            //assert
            Assert.AreEqual(expectedFullName, result.Name.FullName);
            Assert.AreEqual(expectedReturnFullName, result.MethodName.ReturnTypeName.FullName);
        }
Esempio n. 14
0
        public void DotNetReferenceClassGeneric_FromAssembly_ReturnType()
        {
            //arrange
            XElement typeXmlElement   = XElement.Parse("<member name='T:DataFilesTest.DotNetReferenceClassGenericTests.ClassGeneric`1' />", LoadOptions.PreserveWhitespace);
            XElement methodXmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetReferenceClassGenericTests.ClassGeneric`1.MethodA' />", LoadOptions.PreserveWhitespace);
            Type     type             = typeof(ClassGeneric <>);
            //act
            DotNetType   typeResult   = DotNetType.FromVisualStudioXml(typeXmlElement);
            DotNetMethod methodResult = DotNetMethod.FromVisualStudioXml(methodXmlElement);

            typeResult.AddMember(methodResult);
            typeResult.AddAssemblyInfo(type, typeResult.Name);
            //assert
            Assert.AreEqual(MethodCategory.Normal, methodResult.Category);
            Assert.AreEqual("Apple", methodResult.MethodName.ReturnTypeName);
        }
Esempio n. 15
0
        public void DotNetMethod_FromAssembly_GenericClassGenericMethodOneParameterFromMethod()
        {
            //arrange
            XElement   xmlElement       = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.GenericOne`1.MethodMethodGeneric``1(``0)' />", LoadOptions.PreserveWhitespace);
            string     expectedFullName = "DataFilesTest.DotNetMethodTests.GenericOne<T>.MethodMethodGeneric<A>";
            Type       type             = typeof(GenericOne <>);
            MethodInfo methodInfo       = type.GetMethods().First(m => m.Name == "MethodMethodGeneric");
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            result.AddAssemblyInfo(methodInfo);
            //assert
            Assert.AreEqual(expectedFullName, result.Name.FullName);
            Assert.AreEqual(1, result.MethodName.Parameters.Count);
            Assert.AreEqual("A", result.MethodName.Parameters[0].FullTypeName);
            Assert.AreEqual("a", result.MethodName.Parameters[0].Name);
        }
Esempio n. 16
0
        public void DotNetMethod_FromAssembly_MethodOneGeneric_AddedToType()
        {
            //arrange
            XElement typeXmlElement   = XElement.Parse("<member name='T:DataFilesTest.DotNetMethodTests.NormalClass' />", LoadOptions.PreserveWhitespace);
            XElement methodXmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.NormalClass.MethodOneGeneric``1' />", LoadOptions.PreserveWhitespace);
            string   expectedFullName = "DataFilesTest.DotNetMethodTests.NormalClass.MethodOneGeneric<CustomA>";
            Type     type             = typeof(NormalClass);
            //act
            DotNetType   typeResult   = DotNetType.FromVisualStudioXml(typeXmlElement);
            DotNetMethod methodResult = DotNetMethod.FromVisualStudioXml(methodXmlElement);

            typeResult.AddMember(methodResult);

            Assert.IsTrue(methodResult.MatchesSignature(type.GetDeclaredMethods().First(m => m.Name == "MethodOneGeneric")));
            typeResult.AddAssemblyInfo(type, typeResult.Name);
            //assert
            Assert.AreEqual(expectedFullName, typeResult.Methods[0].Name.FullName);
        }
Esempio n. 17
0
        public void DotNetMethod_FromAssembly_RefParameter()
        {
            //arrange
            XElement   xmlTypeElement   = XElement.Parse("<member name='T:DataFilesTest.DotNetMethodTests.NormalClass' />", LoadOptions.PreserveWhitespace);
            XElement   xmlMemberElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.NormalClass.MethodRef(System.Int32@)' />", LoadOptions.PreserveWhitespace);
            Type       type             = typeof(NormalClass);
            DotNetType dotNetType       = new DotNetType(new DotNetQualifiedClassName("DataFilesTest.DotNetMethodTests.NormalClass"));

            dotNetType.AddMember(DotNetMethod.FromVisualStudioXml(xmlMemberElement));
            //act
            dotNetType.AddAssemblyInfo(type, dotNetType.Name);
            DotNetMethod result = dotNetType.Methods[0];

            //assert
            Assert.AreEqual(1, result.MethodName.Parameters.Count);
            Assert.AreEqual("System.Int32", result.MethodName.Parameters[0].FullTypeName);
            Assert.AreEqual("a", result.MethodName.Parameters[0].Name);
            Assert.AreEqual(ParameterCategory.Ref, result.MethodName.Parameters[0].Category);
        }
Esempio n. 18
0
        public void DotNetMethod_FromAssembly_ExtensionMethodParameters()
        {
            //arrange
            XElement   xmlElement = XElement.Parse("<member name='M:DataFilesTest.StaticTestClass.MethodExtension(System.String,System.String)'></member>", LoadOptions.PreserveWhitespace);
            Type       type       = typeof(StaticTestClass);
            MethodInfo methodInfo = type.GetDeclaredMethods().First(m => m.Name == "MethodExtension");
            //act
            DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement);

            result.AddAssemblyInfo(methodInfo);
            //assert
#if DATAFILES_TARGET_20 || DATAFILES_TARGET_30
            Assert.AreEqual(MethodCategory.Static, result.Category);
            Assert.AreEqual(ParameterCategory.Normal, result.MethodName.Parameters[0].Category);
#else
            Assert.AreEqual(MethodCategory.Extension, result.Category);
            Assert.AreEqual(ParameterCategory.Extension, result.MethodName.Parameters[0].Category);
#endif
            Assert.AreEqual(ParameterCategory.Normal, result.MethodName.Parameters[1].Category);
        }
Esempio n. 19
0
        public void DotNetMethod_ThirdPartyTypes()
        {
            //arrange
            string xmlDocumentationFilename = Path.Combine(Utilities.GetProjectDirectory(), "../ThirdPartyTest/bin/Debug/ThirdPartyTest.XML");
            string dllFilename           = Path.Combine(Utilities.GetProjectDirectory(), "../ThirdPartyTest/bin/Debug/ThirdPartyTest.dll");
            string thirdPartyDllFilename = Path.Combine(Utilities.GetProjectDirectory(), "../ThirdPartyTest/bin/Debug/Markdown.dll");
            //act
            DotNetDocumentationFile xmlDocumentation = new DotNetDocumentationFile(xmlDocumentationFilename);

            xmlDocumentation.AddAssemblyInfo(dllFilename, thirdPartyDllFilename);
            //assert
            DotNetType   type    = xmlDocumentation.Types[0];
            DotNetMethod methodA = type.Methods.First(m => m.Name.LocalName == "MethodA");
            DotNetMethod methodB = type.Methods.First(m => m.Name.LocalName == "MethodB");
            DotNetMethod methodC = type.Methods.First(m => m.Name.LocalName == "MethodC");

            Assert.AreEqual("HeyRed.MarkdownSharp.Markdown", methodA.MethodName.ReturnTypeName);
            Assert.AreEqual(0, methodA.MethodName.Parameters.Count);
            Assert.AreEqual("System.Void", methodB.MethodName.ReturnTypeName);
            Assert.AreEqual(1, methodB.MethodName.Parameters.Count);
            Assert.AreEqual("HeyRed.MarkdownSharp.Markdown", methodC.MethodName.ReturnTypeName);
            Assert.AreEqual(1, methodC.MethodName.Parameters.Count);
        }
Esempio n. 20
0
        public void DotNetMethodOperator_SortLINQ_OperatorOrder_ByParameters()
        {
            //arrange
            string xmlA = "<member name='M:MyNamespace.MyClass.op_Addition(MyNamespace.MyClass,System.Byte)' />";
            string xmlB = "<member name='M:MyNamespace.MyClass.op_Addition(MyNamespace.MyClass,System.Decimal)' />";
            string xmlC = "<member name='M:MyNamespace.MyClass.op_Addition(MyNamespace.MyClass,System.Int32)' />";
            string xmlD = "<member name='M:MyNamespace.MyClass.op_Addition(MyNamespace.MyClass,System.Int64)' />";
            List <DotNetMethodOperator> list = new List <DotNetMethodOperator>()
            {
                (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(XElement.Parse(xmlC, LoadOptions.PreserveWhitespace)),
                (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(XElement.Parse(xmlA, LoadOptions.PreserveWhitespace)),
                (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(XElement.Parse(xmlD, LoadOptions.PreserveWhitespace)),
                (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(XElement.Parse(xmlB, LoadOptions.PreserveWhitespace)),
            };

            //act
            list = list.OrderBy(x => x).ToList();
            //assert
            Assert.AreEqual("System.Byte", list[0].MethodName.Parameters[1].TypeName);
            Assert.AreEqual("System.Decimal", list[1].MethodName.Parameters[1].TypeName);
            Assert.AreEqual("System.Int32", list[2].MethodName.Parameters[1].TypeName);
            Assert.AreEqual("System.Int64", list[3].MethodName.Parameters[1].TypeName);
        }
Esempio n. 21
0
        public void DotNetMethodOperator_Sort_OperatorOrder_RegardlessOfParameters()
        {
            //arrange
            string xmlA = "<member name='M:MyNamespace.MyClass.op_Addition(MyNamespace.MyClass,System.Int32)' />";
            string xmlB = "<member name='M:MyNamespace.MyClass.op_Subtraction(MyNamespace.MyClass,System.Byte)' />";
            string xmlC = "<member name='M:MyNamespace.MyClass.op_Multiply(MyNamespace.MyClass,System.Int64)' />";
            string xmlD = "<member name='M:MyNamespace.MyClass.op_Division(MyNamespace.MyClass,System.Decimal)' />";
            List <DotNetMethodOperator> list = new List <DotNetMethodOperator>()
            {
                (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(XElement.Parse(xmlC, LoadOptions.PreserveWhitespace)),
                (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(XElement.Parse(xmlA, LoadOptions.PreserveWhitespace)),
                (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(XElement.Parse(xmlD, LoadOptions.PreserveWhitespace)),
                (DotNetMethodOperator)DotNetMethod.FromVisualStudioXml(XElement.Parse(xmlB, LoadOptions.PreserveWhitespace)),
            };

            //act
            list.Sort();
            //assert
            Assert.AreEqual("op_Addition", list[0].Name.LocalName);
            Assert.AreEqual("op_Subtraction", list[1].Name.LocalName);
            Assert.AreEqual("op_Multiply", list[2].Name.LocalName);
            Assert.AreEqual("op_Division", list[3].Name.LocalName);
        }
Esempio n. 22
0
        public void DotNetProperty_Assembly_ExplicitInterfaceImplementation_Properties()
        {
            //arrange
            Type       type       = typeof(ExplicitInterfaceImplementation);
            DotNetType dotNetType = DotNetType.FromVisualStudioXml(XElement.Parse("<member name='T:DataFilesTest.DotNetPropertyTests.ExplicitInterfaceImplementation'></member>", LoadOptions.PreserveWhitespace));

            dotNetType.AddMember(DotNetProperty.FromVisualStudioXml(XElement.Parse("<member name='P:DataFilesTest.DotNetPropertyTests.ExplicitInterfaceImplementation.DataFilesTest#DotNetPropertyTests#IInterfaceA#SharedProperty'></member>", LoadOptions.PreserveWhitespace)));
            dotNetType.AddMember(DotNetProperty.FromVisualStudioXml(XElement.Parse("<member name='P:DataFilesTest.DotNetPropertyTests.ExplicitInterfaceImplementation.DataFilesTest#DotNetPropertyTests#IInterfaceB#SharedProperty'></member>", LoadOptions.PreserveWhitespace)));
            dotNetType.AddMember(DotNetMethod.FromVisualStudioXml(XElement.Parse("<member name='M:DataFilesTest.DotNetPropertyTests.ExplicitInterfaceImplementation.DataFilesTest#DotNetPropertyTests#IInterfaceA#SharedMethod(System.Int32)'></member>", LoadOptions.PreserveWhitespace)));
            dotNetType.AddMember(DotNetMethod.FromVisualStudioXml(XElement.Parse("<member name='M:DataFilesTest.DotNetPropertyTests.ExplicitInterfaceImplementation.DataFilesTest#DotNetPropertyTests#IInterfaceB#SharedMethod(System.Int32)'></member>", LoadOptions.PreserveWhitespace)));
            //act
            dotNetType.AddAssemblyInfo(type, dotNetType.Name);
            //assert
            Assert.AreEqual(2, dotNetType.Properties.Count);
            Assert.AreEqual("DataFilesTest.DotNetPropertyTests.IInterfaceA", dotNetType.Properties[0].Name.ExplicitInterface);
            Assert.AreEqual("DataFilesTest.DotNetPropertyTests.IInterfaceB", dotNetType.Properties[1].Name.ExplicitInterface);
            Assert.AreEqual("System.Int32", dotNetType.Properties[0].TypeName);
            Assert.AreEqual("System.Int32", dotNetType.Properties[1].TypeName);
            Assert.AreEqual(2, dotNetType.Methods.Count);
            Assert.AreEqual("DataFilesTest.DotNetPropertyTests.IInterfaceA", dotNetType.Methods[0].Name.ExplicitInterface);
            Assert.AreEqual("DataFilesTest.DotNetPropertyTests.IInterfaceB", dotNetType.Methods[1].Name.ExplicitInterface);
            Assert.AreEqual("System.Int32", dotNetType.Methods[0].MethodName.ReturnTypeName);
            Assert.AreEqual("System.Int32", dotNetType.Methods[1].MethodName.ReturnTypeName);
        }
Esempio n. 23
0
        private static void TestRxObject(MethodArgStack[] Stack, ref MethodArgStack returnValue, DotNetMethod method)
        {
            var cctor = m.GetMethod("DotNetparserTester", "TestObject", ".ctor");

            if (cctor == null)
            {
                throw new NullReferenceException();
            }
            var s = new CustomList <MethodArgStack>();

            s.Add(MethodArgStack.String("value"));
            returnValue = clr.CreateObject(cctor, s);
        }
        private void Array_GetLowerBound(MethodArgStack[] Stack, ref MethodArgStack returnValue, DotNetMethod method)
        {
            var array = Stack[0];
            var bound = Stack[1];

            if (array.type != StackItemType.Array)
            {
                throw new Exception();
            }

            //todo
            returnValue = MethodArgStack.Int32(0);
        }
Esempio n. 25
0
 private static void TestsComplete(MethodArgStack[] Stack, ref MethodArgStack returnValue, DotNetMethod method)
 {
     if (NumbOfFailedTests == 0)
     {
         PrintWithColor("All tests are complete. Successed tests: " + NumbOfSuccesssTests + ", failed Tests: " + NumbOfFailedTests, ConsoleColor.Green);
     }
     else
     {
         PrintWithColor("All tests are complete. Successed tests: " + NumbOfSuccesssTests + ", failed Tests: " + NumbOfFailedTests, ConsoleColor.Red);
     }
 }
Esempio n. 26
0
 public void RegisterFunction(string s)
 {
     MethodInfo mi = GetType().GetMethod(s);
     DotNetMethod m = new DotNetMethod(mi, DotNetObject.Marshal(this));
     vm.AddVar(s, m);
 }
        public void DotNetDocumentationFile_CommentFromXml_Full()
        {
            //arrange
            XDocument document = XDocument.Load(Utilities.GetPathTo("data/DotNetDocumentationFile_Full.xml"), LoadOptions.PreserveWhitespace);
            //act
            DotNetDocumentationFile file = new DotNetDocumentationFile(document);

            //assert
            Assert.AreEqual(5, file.TypeCount);

            DotNetType typeA = file.Types[0];

            Assert.AreEqual(2, typeA.NestedTypeCount);
            Assert.AreEqual("Test.TypeA", typeA.Name.FullName);
            Assert.AreEqual(true, typeA.HasComments);
            Assert.AreEqual(1, typeA.Methods.Count);
            Assert.AreEqual(2, typeA.Fields.Count);
            Assert.AreEqual(3, typeA.Properties.Count);
            Assert.AreEqual(1, typeA.Events.Count);

            DotNetType typeB = typeA.NestedTypes[0];

            Assert.AreEqual(1, typeB.NestedTypeCount);
            Assert.AreEqual("Test.TypeA.NestedTypeB", typeB.Name.FullName);
            Assert.AreEqual(true, typeB.HasComments);
            Assert.AreEqual(1, typeB.Methods.Count);

            DotNetType typeC = typeB.NestedTypes[0];

            Assert.AreEqual(0, typeC.NestedTypeCount);
            Assert.AreEqual("Test.TypeA.NestedTypeB.SubNestedTypeC", typeC.Name.FullName);
            Assert.AreEqual(true, typeC.HasComments);
            Assert.AreEqual(2, typeC.Methods.Count);

            DotNetType typeD = file.Types[1];

            Assert.AreEqual("Test.SingleGenericTypeD<T>", typeD.Name.FullName);
            Assert.AreEqual(false, typeD.HasComments);
            Assert.AreEqual(1, typeD.Methods.Count);

            DotNetType typeE = file.Types[2];

            Assert.AreEqual("Test.DoubleGenericTypeE<T,U>", typeE.Name.FullName);
            Assert.AreEqual(false, typeE.HasComments);
            Assert.AreEqual(3, typeE.Methods.Count);

            DotNetMethod methodAA = typeA.Methods[0];

            Assert.AreEqual("Test.TypeA.MethodAA", methodAA.Name.FullName);
            Assert.AreEqual(true, methodAA.HasComments);
            Assert.AreEqual(false, methodAA is DotNetMethodConstructor);
            Assert.AreEqual(false, methodAA is DotNetMethodOperator);
            Assert.AreEqual(0, methodAA.MethodName.Parameters.Count);

            DotNetMethod methodBA = typeB.Methods[0];

            Assert.AreEqual("Test.TypeA.NestedTypeB.MethodBA", methodBA.Name.FullName);
            Assert.AreEqual(false, methodBA.HasComments);
            Assert.AreEqual(false, methodBA is DotNetMethodConstructor);
            Assert.AreEqual(false, methodBA is DotNetMethodOperator);
            Assert.AreEqual(2, methodBA.MethodName.Parameters.Count);

            DotNetMethod methodCA = typeC.Methods[0];

            Assert.AreEqual("Test.TypeA.NestedTypeB.SubNestedTypeC.MethodCA", methodCA.Name.FullName);
            Assert.AreEqual(false, methodCA.HasComments);
            Assert.AreEqual(false, methodCA is DotNetMethodConstructor);
            Assert.AreEqual(false, methodCA is DotNetMethodOperator);
            Assert.AreEqual(1, methodCA.MethodName.Parameters.Count);

            DotNetMethod methodCConstructor = typeC.Methods[1];

            Assert.AreEqual("Test.TypeA.NestedTypeB.SubNestedTypeC.#ctor", methodCConstructor.Name.FullName);
            Assert.AreEqual(false, methodCConstructor.HasComments);
            Assert.AreEqual(true, methodCConstructor is DotNetMethodConstructor);
            Assert.AreEqual(false, methodCConstructor is DotNetMethodOperator);
            Assert.AreEqual(0, methodCConstructor.MethodName.Parameters.Count);

            DotNetMethod methodDAddition = typeD.Methods[0];

            Assert.AreEqual("Test.SingleGenericTypeD<T>.op_Addition", methodDAddition.Name.FullName);
            Assert.AreEqual(false, methodDAddition.HasComments);
            Assert.AreEqual(false, methodDAddition is DotNetMethodConstructor);
            Assert.AreEqual(true, methodDAddition is DotNetMethodOperator);
            Assert.AreEqual(2, methodDAddition.MethodName.Parameters.Count);
            Assert.AreEqual("T", methodDAddition.MethodName.Parameters[0].FullTypeName);
            Assert.AreEqual("Test.SingleGenericTypeD<T>", methodDAddition.MethodName.Parameters[1].FullTypeName);

            DotNetMethod methodEConstructor = typeE.Methods[0];

            Assert.AreEqual("Test.DoubleGenericTypeE<T,U>.#ctor", methodEConstructor.Name.FullName);
            Assert.AreEqual(false, methodEConstructor.HasComments);
            Assert.AreEqual(true, methodEConstructor is DotNetMethodConstructor);
            Assert.AreEqual(false, methodEConstructor is DotNetMethodOperator);
            Assert.AreEqual(2, methodEConstructor.MethodName.Parameters.Count);
            Assert.AreEqual("U", methodEConstructor.MethodName.Parameters[0].FullTypeName);
            Assert.AreEqual("T", methodEConstructor.MethodName.Parameters[1].FullTypeName);

            DotNetMethod methodEA = typeE.Methods[1];

            Assert.AreEqual("Test.DoubleGenericTypeE<T,U>.MethodEA<A>", methodEA.Name.FullName);
            Assert.AreEqual(false, methodEA.HasComments);
            Assert.AreEqual(false, methodEA is DotNetMethodConstructor);
            Assert.AreEqual(false, methodEA is DotNetMethodOperator);
            Assert.AreEqual(3, methodEA.MethodName.Parameters.Count);
            Assert.AreEqual("System.String", methodEA.MethodName.Parameters[0].FullTypeName);
            Assert.AreEqual("A", methodEA.MethodName.Parameters[1].FullTypeName);
            Assert.AreEqual("U", methodEA.MethodName.Parameters[2].FullTypeName);

            DotNetMethod methodEB = typeE.Methods[2];

            Assert.AreEqual("Test.DoubleGenericTypeE<T,U>.MethodEB<A>", methodEB.Name.FullName);
            Assert.AreEqual(false, methodEB.HasComments);
            Assert.AreEqual(false, methodEB is DotNetMethodConstructor);
            Assert.AreEqual(false, methodEB is DotNetMethodOperator);
            Assert.AreEqual(1, methodEB.MethodName.Parameters.Count);
            Assert.AreEqual("System.Collections.Generic.List<Test.SingleGenericTypeD<T>>", methodEB.MethodName.Parameters[0].FullTypeName);
        }
 private void DebuggerBreak(MethodArgStack[] Stack, ref MethodArgStack returnValue, DotNetMethod method)
 {
     Debugger.Break();
 }
Esempio n. 29
0
        private static void TestSuccess(MethodArgStack[] Stack, ref MethodArgStack returnValue, DotNetMethod method)
        {
            var testName = (string)Stack[Stack.Length - 1].value;

            PrintWithColor("Test Success: " + testName, ConsoleColor.Green);
            NumbOfSuccesssTests++;
        }
Esempio n. 30
0
 private static void TestsComplete(MethodArgStack[] Stack, ref MethodArgStack returnValue, DotNetMethod method)
 {
     Console.WriteLine();
     PrintWithColor("All Tests Completed.", ConsoleColor.DarkYellow);
     Console.WriteLine();
     PrintWithColor("Passed tests: " + NumbOfSuccesssTests, ConsoleColor.Green);
     PrintWithColor("Failed tests: " + NumbOfFailedTests, ConsoleColor.Red);
 }
Esempio n. 31
0
        private static void TestFail(MethodArgStack[] Stack, ref MethodArgStack returnValue, DotNetMethod method)
        {
            var testName = (string)Stack[Stack.Length - 1].value;

            PrintWithColor("Test Failure: " + testName, ConsoleColor.Red);
            NumbOfFailedTests++;
        }