Beispiel #1
0
        public void PrimitiveTypes_FullNames()
        {
            const string code = @"public class Class1 
            {
                public System.Int32 a = 0;
                public System.String b = """";
                public System.Int16 c = 0;
                public System.Int64 d = 0;
                public System.Single e = 0;
                public System.Double f = 0;
                public System.Bool g = false;
                public System.Char h = 'c';
				public System.Byte i = 0;
				public System.Object j = null;
				public System.Decimal k = 0m;
            }";

            CSharpParser parser = new CSharpParser();

            parser.FormatSettings.ReorderBaseConstructs = false;
            parser.ParseCodeAsync(code).WaitOne();

            ICodeRoot codeRoot = parser.CreatedCodeRoot;
            Class     clazz    = (Class)codeRoot.WalkChildren()[0];

            Field con = (Field)clazz.WalkChildren()[0];

            Assert.That(con.Name, Is.EqualTo("a"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Int32"));

            con = (Field)clazz.WalkChildren()[1];
            Assert.That(con.Name, Is.EqualTo("b"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.String"));

            con = (Field)clazz.WalkChildren()[2];
            Assert.That(con.Name, Is.EqualTo("c"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Int16"));

            con = (Field)clazz.WalkChildren()[3];
            Assert.That(con.Name, Is.EqualTo("d"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Int64"));

            con = (Field)clazz.WalkChildren()[4];
            Assert.That(con.Name, Is.EqualTo("e"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Single"));

            con = (Field)clazz.WalkChildren()[5];
            Assert.That(con.Name, Is.EqualTo("f"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Double"));

            con = (Field)clazz.WalkChildren()[6];
            Assert.That(con.Name, Is.EqualTo("g"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Bool"));

            con = (Field)clazz.WalkChildren()[7];
            Assert.That(con.Name, Is.EqualTo("h"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Char"));

            con = (Field)clazz.WalkChildren()[8];
            Assert.That(con.Name, Is.EqualTo("i"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Byte"));

            con = (Field)clazz.WalkChildren()[9];
            Assert.That(con.Name, Is.EqualTo("j"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Object"));

            con = (Field)clazz.WalkChildren()[10];
            Assert.That(con.Name, Is.EqualTo("k"));
            Assert.That(con.DataType.Name, Is.EqualTo("System.Decimal"));
        }