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); }
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); }
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); }