public void VBNetPartialPublicClass()
        {
            string          program = "Partial Public Class TestClass\nEnd Class\n";
            TypeDeclaration td      = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestClass", td.Name);
            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual(Modifier.Partial | Modifier.Public, td.Modifier);
        }
Beispiel #2
0
        public void GlobalAttributeVB()
        {
            string          program = @"<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Form1
	
End Class";
            TypeDeclaration decl    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("Microsoft.VisualBasic.CompilerServices.DesignerGenerated", decl.Attributes[0].Attributes[0].Name);
        }
Beispiel #3
0
        public void VBNetBigReDimStatementTest()
        {
            string          program         = @"
Class X
	Sub x
		ReDim sU(m - 1, n - 1)
		ReDim sW(n - 1)
		ReDim sV(n - 1, n - 1)
		ReDim rv1(n - 1)
		ReDim sMt(iNrCols - 1, 0)
		ReDim Preserve sMt(iNrCols - 1, iRowNr)
		ReDim sM(iRowNr - 1, iNrCols - 1)
		If (IsNothing(ColLengths)) Then ReDim ColLengths(0)
		If (ColLengths.Length = (SubItem + 1)) Then ReDim Preserve ColLengths(SubItem + 1)
		ReDim sTransform(2, iTransformType - 1)
		ReDim Preserve _Items(_Count)
		ReDim Preserve _Items(nCapacity)
		ReDim Preserve _Items(_Count)
		ReDim Preserve _Items(nCapacity)
		ReDim Preserve _Items(_Count)
		ReDim Preserve _Items(nCapacity)
		ReDim sU(m - 1, n - 1)
		ReDim sW(n - 1)
		ReDim sV(n - 1, n - 1)
		ReDim rv1(n - 1)
		ReDim sMt(iNrCols - 1, 0)
		ReDim Preserve sMt(iNrCols - 1, iRowNr)
		ReDim sM(iRowNr - 1, iNrCols - 1)
		If (IsNothing(ColLengths)) Then ReDim ColLengths(0)
		If (ColLengths.Length = (SubItem + 1)) Then ReDim Preserve ColLengths(SubItem + 1)
		ReDim sTransform(2, iTransformType - 1)
		ReDim Preserve _Items(_Count)
		ReDim Preserve _Items(nCapacity)
		ReDim Preserve _Items(_Count)
		ReDim Preserve _Items(nCapacity)
		ReDim Preserve _Items(_Count)
		ReDim Preserve _Items(nCapacity)
		ReDim Preserve Samples(Samples.GetUpperBound(0) + 1)
		ReDim Samples(0)
		ReDim BaseCssContent(BaseCssContentRows - 1)
		ReDim mabtRxBuf(Bytes2Read - 1)
		ReDim mabtRxBuf(Bytes2Read - 1)
		ReDim Preserve primarykey(primarykey.Length)
		ReDim Preserve primarykey(primarykey.Length)
		ReDim Preserve IntArray(10, 10, 20)
		ReDim Preserve IntArray(10, 10, 15)
		ReDim X(10, 10)
		ReDim Preserve IntArray(10, 10, 20)
		ReDim Preserve IntArray(10, 10, 15)
		ReDim X(10, 10)
	End Sub
End Class";
            TypeDeclaration typeDeclaration = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);
        }
        public void VBNetSimpleClassTypeDeclarationWithoutLastNewLineTest()
        {
            string program = "Class TestClass\n" +
                             "End Class";
            TypeDeclaration td = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestClass", td.Name);
            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual(1, td.StartLocation.Y, "start line");
            Assert.AreEqual(2, td.EndLocation.Y, "end line");
        }
        public void VBNetEnumWithSystemBaseClassDeclarationTest()
        {
            string program = "Enum TestEnum As System.UInt16\n" +
                             "End Enum\n";
            TypeDeclaration td = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestEnum", td.Name);
            Assert.AreEqual(ClassType.Enum, td.Type);
            Assert.AreEqual("System.UInt16", td.BaseTypes[0].Type);
            Assert.AreEqual(0, td.Children.Count);
        }
Beispiel #6
0
        public void AttributeOnModule()
        {
            string          program = @"
<HideModule> _
Public Module MyExtra

	Public i As Integer
	Public d As Double
	
End Module
";
            TypeDeclaration decl    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("HideModule", decl.Attributes[0].Attributes[0].Name);
        }
Beispiel #7
0
        public void AttributeOnStructure()
        {
            string          program = @"
<StructLayout( LayoutKind.Explicit )> _
Public Structure MyUnion

	<FieldOffset( 0 )> Public i As Integer
	< FieldOffset( 0 )> Public d As Double
	
End Structure 'MyUnion
";
            TypeDeclaration decl    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("StructLayout", decl.Attributes[0].Attributes[0].Name);
        }
        public void VBNetGenericClassWithConstraint()
        {
            string          declr = @"
Public Class Test(Of T As IMyInterface)

End Class
";
            TypeDeclaration td    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(declr);

            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual("Test", td.Name);

            Assert.AreEqual(1, td.Templates.Count);
            Assert.AreEqual("T", td.Templates[0].Name);
            Assert.AreEqual("IMyInterface", td.Templates[0].Bases[0].Type);
        }
        public void VBNetGenericClassTypeDeclarationTest()
        {
            string          declr = @"
Public Class Test(Of T)

End Class
";
            TypeDeclaration td    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(declr);

            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual("Test", td.Name);
            Assert.AreEqual(Modifier.Public, td.Modifier);
            Assert.AreEqual(0, td.BaseTypes.Count);
            Assert.AreEqual(1, td.Templates.Count);
            Assert.AreEqual("T", td.Templates[0].Name);
        }
Beispiel #10
0
        public void VBNetJuggedNamespaceTest()
        {
            string program = "Namespace N1 'TestNamespace\n" +
                             "    Namespace N2   ' Declares a namespace named N2 within N1.\n" +
                             "    End Namespace\n" +
                             "End Namespace\n";

            NamespaceDeclaration ns = ParseUtilVBNet.ParseGlobal <NamespaceDeclaration>(program);

            Assert.AreEqual("N1", ns.Name);

            Assert.IsTrue(ns.Children[0] is NamespaceDeclaration);

            ns = (NamespaceDeclaration)ns.Children[0];

            Assert.AreEqual("N2", ns.Name);
        }
Beispiel #11
0
        public void VBNetGenericMethodInInterface()
        {
            const string      program = @"Interface MyInterface
	Function MyMethod(Of T As {ISomeInterface})(a As T) As T
	End Interface"    ;
            TypeDeclaration   td      = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);
            MethodDeclaration md      = (MethodDeclaration)td.Children[0];

            Assert.AreEqual("T", md.TypeReference.Type);
            Assert.AreEqual(1, md.Parameters.Count);
            Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type);
            Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName);

            Assert.AreEqual(1, md.Templates.Count);
            Assert.AreEqual("T", md.Templates[0].Name);
            Assert.AreEqual(1, md.Templates[0].Bases.Count);
            Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type);
        }
        public void SimpleVBNetDelegateDeclarationTest()
        {
            string program = "Public Delegate Sub MyDelegate(ByVal a As Integer, ByVal secondParam As Integer, ByVal lastParam As MyObj)\n";

            TestDelegateDeclaration(ParseUtilVBNet.ParseGlobal <DelegateDeclaration>(program));
        }