• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# VisualBasic.VBParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NArrange.VisualBasic.VBParser的典型用法代码示例。如果您正苦于以下问题:C# VBParser类的具体用法?C# VBParser怎么用?C# VBParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VBParser类属于NArrange.VisualBasic命名空间,在下文中一共展示了VBParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExpectedBlockCloseTest

        public void ExpectedBlockCloseTest()
        {
            StringReader reader = new StringReader(
                "namespace SampleNamespace");

            VBParser parser = new VBParser();
            parser.Parse(reader);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:8,代码来源:VBParserTests.cs


示例2: ParseSingleNamespaceTest

        public void ParseSingleNamespaceTest()
        {
            VBParser parser = new VBParser();

            VBTestFile testFile = VBTestUtilities.GetSingleNamespaceFile();
            using (TextReader reader = testFile.GetReader())
            {
                ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

                Assert.IsNotNull(elements, "Code element collection should not be null.");
                Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed.");

                NamespaceElement namespaceElement = elements[0] as NamespaceElement;
                Assert.IsNotNull(namespaceElement, "Expected a NamespaceElement.");
                Assert.AreEqual("SampleNamespace", namespaceElement.Name, "Unexpected namespace name.");
                Assert.IsNotNull(namespaceElement.Children, "Children collection should not be null.");
                Assert.AreEqual(0, namespaceElement.Children.Count, "Children collection should not be null.");
            }
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:19,代码来源:VBParserTests.cs


示例3: ParseAssemblyAttributesTest

        public void ParseAssemblyAttributesTest()
        {
            VBParser parser = new VBParser();

            VBTestFile testFile = VBTestUtilities.GetAssemblyAttributesFile();
            using (TextReader reader = testFile.GetReader())
            {
                ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

                Assert.IsNotNull(elements, "Code element collection should not be null.");
                Assert.AreEqual(15, elements.Count, "An unexpected number of elements were parsed.");

                //
                // Using statements
                //
                UsingElement usingElement;

                usingElement = elements[0] as UsingElement;
                Assert.IsNotNull(usingElement, "Element is not a UsingElement.");
                Assert.AreEqual("System.Reflection", usingElement.Name, "Unexpected name.");

                usingElement = elements[1] as UsingElement;
                Assert.IsNotNull(usingElement, "Element is not a UsingElement.");
                Assert.AreEqual("System.Runtime.CompilerServices", usingElement.Name, "Unexpected name.");

                usingElement = elements[2] as UsingElement;
                Assert.IsNotNull(usingElement, "Element is not a UsingElement.");
                Assert.AreEqual("System.Runtime.InteropServices", usingElement.Name, "Unexpected name.");

                //
                // Attributes
                //
                AttributeElement attributeElement;

                attributeElement = elements[3] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
                Assert.AreEqual("assembly", attributeElement.Target, "Unexpected attribute target.");
                Assert.AreEqual("AssemblyTitle", attributeElement.Name, "Unexpected attribute name.");
                Assert.AreEqual("\"NArrange.Core.Tests\"", attributeElement.BodyText, "Unexpected attribute text.");
                Assert.AreEqual(3, attributeElement.HeaderComments.Count,
                    "An unexpected number of header comment lines were parsed.");

                attributeElement = elements[4] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
                Assert.AreEqual("assembly", attributeElement.Target, "Unexpected attribute target.");
                Assert.AreEqual("AssemblyDescription", attributeElement.Name, "Unexpected attribute name.");
                Assert.AreEqual("\"\"", attributeElement.BodyText, "Unexpected attribute text.");
                Assert.AreEqual(0, attributeElement.HeaderComments.Count,
                    "An unexpected number of header comment lines were parsed.");

                attributeElement = elements[5] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
                Assert.AreEqual("assembly", attributeElement.Target, "Unexpected attribute target.");
                Assert.AreEqual("AssemblyConfiguration", attributeElement.Name, "Unexpected attribute name.");
                Assert.AreEqual("\"\"", attributeElement.BodyText, "Unexpected attribute text.");
                Assert.AreEqual(0, attributeElement.HeaderComments.Count,
                    "An unexpected number of header comment lines were parsed.");

                attributeElement = elements[6] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
                Assert.AreEqual("assembly", attributeElement.Target, "Unexpected attribute target.");
                Assert.AreEqual("AssemblyCompany", attributeElement.Name, "Unexpected attribute name.");
                Assert.AreEqual("\"\"", attributeElement.BodyText, "Unexpected attribute text.");
                Assert.AreEqual(0, attributeElement.HeaderComments.Count,
                    "An unexpected number of header comment lines were parsed.");

                attributeElement = elements[7] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
                Assert.AreEqual("assembly", attributeElement.Target, "Unexpected attribute target.");
                Assert.AreEqual("AssemblyProduct", attributeElement.Name, "Unexpected attribute name.");
                Assert.AreEqual("\"NArrange.Core.Tests\"", attributeElement.BodyText, "Unexpected attribute text.");
                Assert.AreEqual(0, attributeElement.HeaderComments.Count,
                    "An unexpected number of header comment lines were parsed.");

                attributeElement = elements[8] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
                Assert.AreEqual("assembly", attributeElement.Target, "Unexpected attribute target.");
                Assert.AreEqual("AssemblyCopyright", attributeElement.Name, "Unexpected attribute name.");
                Assert.AreEqual("\"Copyright ©  2007\"", attributeElement.BodyText, "Unexpected attribute text.");
                Assert.AreEqual(0, attributeElement.HeaderComments.Count,
                    "An unexpected number of header comment lines were parsed.");

                attributeElement = elements[9] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
                Assert.AreEqual("assembly", attributeElement.Target, "Unexpected attribute target.");
                Assert.AreEqual("AssemblyTrademark", attributeElement.Name, "Unexpected attribute name.");
                Assert.AreEqual("\"\"", attributeElement.BodyText, "Unexpected attribute text.");
                Assert.AreEqual(0, attributeElement.HeaderComments.Count,
                    "An unexpected number of header comment lines were parsed.");

                attributeElement = elements[10] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
                Assert.AreEqual("assembly", attributeElement.Target, "Unexpected attribute target.");
                Assert.AreEqual("AssemblyCulture", attributeElement.Name, "Unexpected attribute name.");
                Assert.AreEqual("\"\"", attributeElement.BodyText, "Unexpected attribute text.");
                Assert.AreEqual(0, attributeElement.HeaderComments.Count,
                    "An unexpected number of header comment lines were parsed.");

                attributeElement = elements[11] as AttributeElement;
                Assert.IsNotNull(attributeElement, "Element is not an AttributeElement.");
//.........这里部分代码省略.........
开发者ID:MarcStan,项目名称:NArrange,代码行数:101,代码来源:VBParserTests.cs


示例4: ParseClassUnspecifiedAccessTest

        public void ParseClassUnspecifiedAccessTest()
        {
            StringReader reader = new StringReader(
                "class Test\r\n" +
                "class Nested\r\n" +
                "end class\r\n" +
                "end class");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

            Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed.");
            TypeElement typeElement = elements[0] as TypeElement;
            Assert.IsNotNull(typeElement, "Element is not a TypeElement.");
            Assert.AreEqual("Test", typeElement.Name, "Unexpected name.");
            Assert.AreEqual(CodeAccess.None, typeElement.Access, "Unexpected code access.");
            Assert.AreEqual(TypeElementType.Class, typeElement.Type, "Unexpected type element type.");

            Assert.AreEqual(1, typeElement.Children.Count, "An unexpected number of child elements were parsed.");
            TypeElement nestedtypeElement = typeElement.Children[0] as TypeElement;
            Assert.IsNotNull(nestedtypeElement, "Element is not a TypeElement.");
            Assert.AreEqual("Nested", nestedtypeElement.Name, "Unexpected name.");
            Assert.AreEqual(CodeAccess.None, nestedtypeElement.Access, "Unexpected code access.");
            Assert.AreEqual(TypeElementType.Class, nestedtypeElement.Type, "Unexpected type element type.");
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:25,代码来源:VBParserTests.cs


示例5: ParseClassUnclosedTypeParameterTest

        public void ParseClassUnclosedTypeParameterTest()
        {
            StringReader reader = new StringReader(
                "Public Class Test(Of T\r\nEnd Class");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:8,代码来源:VBParserTests.cs


示例6: ParseClassSimpleTest

        public void ParseClassSimpleTest()
        {
            StringReader reader = new StringReader(
                "public class Test\r\n" +
                "end class");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

            Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed.");
            TypeElement typeElement = elements[0] as TypeElement;
            Assert.IsNotNull(typeElement, "Element is not a TypeElement.");
            Assert.AreEqual("Test", typeElement.Name, "Unexpected name.");
            Assert.AreEqual(CodeAccess.Public, typeElement.Access, "Unexpected code access.");
            Assert.AreEqual(TypeElementType.Class, typeElement.Type, "Unexpected type element type.");
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:16,代码来源:VBParserTests.cs


示例7: ParseClassMultipleTypeParameterTest3

        public void ParseClassMultipleTypeParameterTest3()
        {
            StringReader reader = new StringReader(
                "Partial Public Class NewClass(Of T as {new, IDisposable}, S as new, R)\r\n" +
                "End Class");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

            TypeElement classElement = elements[0] as TypeElement;
            Assert.IsNotNull(classElement, "Expected a class element");
            Assert.AreEqual(TypeElementType.Class, classElement.Type, "Expected a class.");
            Assert.AreEqual("NewClass", classElement.Name, "Unexpected class name.");
            Assert.AreEqual(CodeAccess.Public, classElement.Access, "Unexpected access.");
            Assert.IsTrue(classElement.IsPartial, "Expected a partial class.");
            Assert.AreEqual(3, classElement.TypeParameters.Count, "Unexpected number of type parameters.");
            Assert.AreEqual("T", classElement.TypeParameters[0].Name);
            Assert.AreEqual(2, classElement.TypeParameters[0].Constraints.Count);
            Assert.AreEqual("new", classElement.TypeParameters[0].Constraints[0]);
            Assert.AreEqual("IDisposable", classElement.TypeParameters[0].Constraints[1]);
            Assert.AreEqual("S", classElement.TypeParameters[1].Name);
            Assert.AreEqual(1, classElement.TypeParameters[1].Constraints.Count);
            Assert.AreEqual("new", classElement.TypeParameters[1].Constraints[0]);
            Assert.AreEqual("R", classElement.TypeParameters[2].Name);
            Assert.AreEqual(0, classElement.TypeParameters[2].Constraints.Count);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:26,代码来源:VBParserTests.cs


示例8: ParseClassMultipleTypeParameterInvalidTest3

        public void ParseClassMultipleTypeParameterInvalidTest3()
        {
            StringReader reader = new StringReader(
                "Partial Public Class NewClass(Of T as new, IDisposable, S as new, IComparable})\r\n" +
                "End Class");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

            Assert.Fail();
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:11,代码来源:VBParserTests.cs


示例9: ParseUsingEmptyTypeOrNamespaceTest

        public void ParseUsingEmptyTypeOrNamespaceTest()
        {
            StringReader reader = new StringReader(
                "Imports Test = \r\n");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:8,代码来源:VBParserTests.cs


示例10: ParseUnkownKeywordTest

        public void ParseUnkownKeywordTest()
        {
            StringReader reader = new StringReader("Blah");

            VBParser parser = new VBParser();
            parser.Parse(reader);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:7,代码来源:VBParserTests.cs


示例11: ParseUnhandledPreprocessorTest

        public void ParseUnhandledPreprocessorTest()
        {
            StringReader reader = new StringReader(
                "Public Class Test\r\n" +
                "#Const TEST = 1\r\n" +
                "End Class");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:10,代码来源:VBParserTests.cs


示例12: ParseTypeImplementsTest

        public void ParseTypeImplementsTest()
        {
            StringReader reader = new StringReader(
                "Public Class TestClass : Implements IList\r\n" +
                "\tImplements IDisposable, IBindingList\r\n" +
                "End Class");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

            Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed.");
            TypeElement typeElement = elements[0] as TypeElement;
            Assert.IsNotNull(typeElement, "Expected a type element.");
            Assert.AreEqual(TypeElementType.Class, typeElement.Type, "Unexpected type element type.");
            Assert.AreEqual(3, typeElement.Interfaces.Count);
            Assert.AreEqual("IList", typeElement.Interfaces[0].Name);
            Assert.AreEqual("IDisposable", typeElement.Interfaces[1].Name);
            Assert.AreEqual("IBindingList", typeElement.Interfaces[2].Name);
            foreach (InterfaceReference interfaceReference in typeElement.Interfaces)
            {
                Assert.AreEqual(InterfaceReferenceType.Interface, interfaceReference.ReferenceType);
            }
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:23,代码来源:VBParserTests.cs


示例13: ParseSubTest

        public void ParseSubTest()
        {
            StringReader reader = new StringReader(
                "Private Sub DoSomething()\r\n" +
                "End Sub");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

            Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed.");
            MethodElement methodElement = elements[0] as MethodElement;
            Assert.IsNotNull(methodElement, "Element is not a MethodElement.");
            Assert.AreEqual("DoSomething", methodElement.Name, "Unexpected name.");
            Assert.AreEqual(CodeAccess.Private, methodElement.Access, "Unexpected code access.");
            Assert.IsNull(methodElement.Type, "Unexpected member type.");

            reader = new StringReader(
                "Sub DoSomething()\r\n" +
                "End Sub");

            elements = parser.Parse(reader);

            Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed.");
            methodElement = elements[0] as MethodElement;
            Assert.IsNotNull(methodElement, "Element is not a MethodElement.");
            Assert.AreEqual("DoSomething", methodElement.Name, "Unexpected name.");
            Assert.AreEqual(CodeAccess.None, methodElement.Access, "Unexpected code access.");
            Assert.IsNull(methodElement.Type, "Unexpected member type.");
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:29,代码来源:VBParserTests.cs


示例14: ParseSubExternalTest

        public void ParseSubExternalTest()
        {
            string[] variations =
            {
                "Public Declare Ansi Sub ExternalSub Lib \"Some.dll\" Alias \"doit\" (ByVal filename As String)",
                "Public Declare Ansi Sub _\r\nExternalSub Lib _\r\n\"Some.dll\" Alias _\r\n \"doit\" (ByVal filename As String)"
            };

            foreach (string variation in variations)
            {
                StringReader reader = new StringReader(variation);

                VBParser parser = new VBParser();
                ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

                Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed.");
                MethodElement methodElement = elements[0] as MethodElement;
                Assert.IsNotNull(methodElement, "Element is not a MethodElement.");
                Assert.AreEqual("ExternalSub", methodElement.Name, "Unexpected name.");
                Assert.AreEqual(CodeAccess.Public, methodElement.Access, "Unexpected code access.");
                Assert.AreEqual("ByVal filename As String", methodElement.Parameters, "Unexpected parameters.");
                Assert.IsNull(methodElement.Type, "Unexpected return type.");
                Assert.AreEqual("Ansi", methodElement[VBExtendedProperties.ExternalModifier], "Unexpected external modifier.");
                Assert.AreEqual("Some.dll", methodElement[VBExtendedProperties.ExternalLibrary], "Unexpected external library.");
                Assert.AreEqual("doit", methodElement[VBExtendedProperties.ExternalAlias], "Unexpected external alias.");
            }
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:27,代码来源:VBParserTests.cs


示例15: ParseStructDefinitionTest

        public void ParseStructDefinitionTest()
        {
            VBParser parser = new VBParser();

            VBTestFile testFile = VBTestUtilities.GetStructDefinitionFile();
            using (TextReader reader = testFile.GetReader())
            {
                ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

                Assert.IsNotNull(elements, "Code element collection should not be null.");
                Assert.AreEqual(2, elements.Count, "An unexpected number of elements were parsed.");

                UsingElement using1 = elements[0] as UsingElement;
                Assert.IsNotNull(using1, "Expected a UsingElement.");
                Assert.AreEqual("System", using1.Name, "Unexpected using name.");

                NamespaceElement namespaceElement = elements[1] as NamespaceElement;
                Assert.IsNotNull(namespaceElement, "Expected a NamespaceElement.");
                Assert.AreEqual("SampleNamespace", namespaceElement.Name, "Unexpected namespace name.");

                Assert.IsNotNull(namespaceElement.Children, "Namespace Children collection should not be null.");
                Assert.AreEqual(1, namespaceElement.Children.Count, "An unexpected number of namespace child elements were parsed.");

                TypeElement structElement = namespaceElement.Children[0] as TypeElement;
                Assert.IsNotNull(structElement, "Expected a TypeElement.");
                Assert.AreEqual(TypeElementType.Structure, structElement.Type, "Expected type to be a structure.");
                Assert.IsFalse(structElement.IsStatic, "Structure should not be static.");
                Assert.IsFalse(structElement.IsSealed, "Structures should not be sealed.");
                Assert.AreEqual("SampleStruct", structElement.Name, "Unexpected structure name.");
                Assert.AreEqual(3, structElement.HeaderComments.Count,
                    "An unexpected number of class header comment lines were parsed.");
                foreach (ICommentElement comment in structElement.HeaderComments)
                {
                    Assert.AreEqual(CommentType.XmlLine, comment.Type, "Structure header comment should be an XML comment.");
                }
                Assert.AreEqual(CodeAccess.Public, structElement.Access, "Unexpected code access level.");
            }
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:38,代码来源:VBParserTests.cs


示例16: ParseUsingInvalidTest

        public void ParseUsingInvalidTest()
        {
            StringReader reader = new StringReader(
                "Imports System Text\r\n");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:8,代码来源:VBParserTests.cs


示例17: ParseClassMissingRegionNameTest

        public void ParseClassMissingRegionNameTest()
        {
            StringReader reader = new StringReader(
                "Public Class Test\r\n" +
                "\t#Region\r\n" +
                "\t#Endregion\r\n" +
                "End Class");

            VBParser parser = new VBParser();
            ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:11,代码来源:VBParserTests.cs


示例18: ParseUsingRedefineTest

        public void ParseUsingRedefineTest()
        {
            string[] usingVariations = new string[]
            {
                "Imports Redefined = System.Text.Encoder",
                "Imports Redefined = System.Text.Encoder\r\n",
                "Imports  Redefined = System.Text.Encoder",
                "Imports _\r\nRedefined = System.Text.Encoder",
                "Imports _\r\n\tRedefined = System.Text.Encoder",
                "Imports _ \t\r\nRedefined = System.Text.Encoder",
                "Imports Redefined _\r\n= System.Text.Encoder",
                "Imports Redefined _ \t\r\n= System.Text.Encoder",
                "Imports Redefined _\r\n= _\r\nSystem.Text.Encoder",
                "Imports Redefined _ \t\r\n= _ \t\r\nSystem.Text.Encoder"
            };

            foreach (string usingStr in usingVariations)
            {
                StringReader reader = new StringReader(usingStr);
                VBParser parser = new VBParser();
                ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

                Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed.");
                UsingElement usingElement = elements[0] as UsingElement;
                Assert.IsNotNull(usingElement, "Element is not a UsingElement.");
                Assert.AreEqual("Redefined", usingElement.Name);
                Assert.AreEqual("System.Text.Encoder", usingElement.Redefine);
            }
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:29,代码来源:VBParserTests.cs


示例19: ParseClassMultipleTypeParameterTest1

        public void ParseClassMultipleTypeParameterTest1()
        {
            string[] variations = new string[]
            {
                "Partial Public Class NewClass(Of T as new,R,S as new,Q)\r\n" +
                "End Class",
                "Partial Public Class NewClass(Of T as new, R, S as new, Q)\r\n" +
                "End Class"
            };

            foreach (string variation in variations)
            {
                StringReader reader = new StringReader(variation);

                VBParser parser = new VBParser();
                ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

                TypeElement classElement = elements[0] as TypeElement;
                Assert.IsNotNull(classElement, "Expected a class element");
                Assert.AreEqual(TypeElementType.Class, classElement.Type, "Expected a class.");
                Assert.AreEqual("NewClass", classElement.Name, "Unexpected class name.");
                Assert.AreEqual(CodeAccess.Public, classElement.Access, "Unexpected access.");
                Assert.IsTrue(classElement.IsPartial, "Expected a partial class.");
                Assert.AreEqual(4, classElement.TypeParameters.Count, "Unexpected number of type parameters.");
                Assert.AreEqual("T", classElement.TypeParameters[0].Name);
                Assert.AreEqual(1, classElement.TypeParameters[0].Constraints.Count);
                Assert.AreEqual("new", classElement.TypeParameters[0].Constraints[0]);
                Assert.AreEqual("R", classElement.TypeParameters[1].Name);
                Assert.AreEqual(0, classElement.TypeParameters[1].Constraints.Count);
                Assert.AreEqual("S", classElement.TypeParameters[2].Name);
                Assert.AreEqual(1, classElement.TypeParameters[2].Constraints.Count);
                Assert.AreEqual("new", classElement.TypeParameters[2].Constraints[0]);
                Assert.AreEqual("Q", classElement.TypeParameters[3].Name);
                Assert.AreEqual(0, classElement.TypeParameters[3].Constraints.Count);
            }
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:36,代码来源:VBParserTests.cs


示例20: ParseUsingTest

        public void ParseUsingTest()
        {
            string[] usingVariations = new string[]
            {
                "Imports System.Text",
                "Imports System.Text\r\n",
                "Imports  System.Text",
                "Imports _\r\nSystem.Text",
                "Imports _\r\n\tSystem.Text",
                "Imports _ \t\r\n\tSystem.Text"
            };

            foreach (string usingStr in usingVariations)
            {
                StringReader reader = new StringReader(usingStr);

                VBParser parser = new VBParser();
                ReadOnlyCollection<ICodeElement> elements = parser.Parse(reader);

                Assert.AreEqual(1, elements.Count, "An unexpected number of elements were parsed from '{0}'", usingStr);
                UsingElement usingElement = elements[0] as UsingElement;
                Assert.IsNotNull(usingElement, "Element is not a UsingElement.  '{0}'", usingStr);
                Assert.AreEqual("System.Text", usingElement.Name, "Unexpected name from '{0}'", usingStr);
                Assert.IsFalse(usingElement.IsMovable, "VB should not support moving import directives.");
            }
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:26,代码来源:VBParserTests.cs



注:本文中的NArrange.VisualBasic.VBParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Wave.AudioFileReader类代码示例发布时间:2022-05-26
下一篇:
C# CSharp.CSharpParser类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap