Beispiel #1
0
        public void 构造函数_T2_本类其它构造函数()
        {
            CtorBuilder builder = CodeSyntax.CreateCtor("T2")
                                  .WithAccess(MemberAccess.Public)
                                  .WithParams("string a")
                                  .WithThis("this()");

            var result = builder.ToFormatCode();

#if Log
            _tempOutput.WriteLine(result);
#endif
            Assert.Equal(@"public T2(string a): this()
{
}", result);
        }
Beispiel #2
0
        public void 构造函数_T3_父类构造函数()
        {
            CtorBuilder builder = CodeSyntax.CreateCtor("T2")
                                  .WithAccess(MemberAccess.Public)
                                  .WithParams("string a,string b")
                                  .WithBase("base(a)");

            var result = builder.ToFormatCode();

#if Log
            _tempOutput.WriteLine(result);
#endif
            Assert.Equal(@"public T2(string a, string b): base(a)
{
}", result);
        }
Beispiel #3
0
        public void 构造函数_T1()
        {
            CtorBuilder builder = CodeSyntax.CreateCtor("T2")
                                  .WithAccess(MemberAccess.Public)
                                  .WithBlock(@"Console.WriteLine(""666"");");

            var result = builder.ToFormatCode();

#if Log
            _tempOutput.WriteLine(result);
#endif
            Assert.Equal(@"public T2()
{
    Console.WriteLine(""666"");
}", result);
        }