private void NamespaceCreateButton_Click(object sender, EventArgs e) { _currentCompileUnitBuilder = new CompileUnitBuilder(NamespaceBox.Text); NamespaceBox.Enabled = false; NamespaceCreateButton.Enabled = false; ToggelClassesPanel(); UpdateClasses(); }
public void IfNewIntanceOfCompileUnitBuilderShouldHaveNamespaceWithGivenNamespaceName() { var builder = new CompileUnitBuilder(NamespaceName); var target = builder.GetCompileUnit(); Assert.AreEqual(target.Namespaces.Count, 1); Assert.AreEqual(target.Namespaces[0].Name, NamespaceName); }
public void IfUsingIsAddedNamespaceShouldHaveGivenUsing() { const string usingName = "system"; var builder = new CompileUnitBuilder(NamespaceName); var target = builder.AddUsing(usingName).GetCompileUnit(); Assert.AreEqual(target.Namespaces[0].Imports.Count, 1); }
public void IsNewTypeIsAddedNamespaceHaveTypeWithGivenType() { const string typeName = "testType"; var builder = new CompileUnitBuilder(NamespaceName); var classDeclaration = new CodeTypeDeclaration(typeName); var target = builder.AddClass(classDeclaration).GetCompileUnit(); Assert.AreEqual(1, target.Namespaces[0].Types.Count); Assert.AreEqual(typeName, target.Namespaces[0].Types[0].Name); }
private void button1_Click(object sender, EventArgs e) { var language = GenerateCodeBox.Text; string sExt = ""; saveFileDialog1.FileName = "MyNewClass"; switch (language) { case "CSharp": sExt = "CSharp(*.cs|*.cs"; break; case "CPP": sExt = "CPP(*.cpp)|*.cpp"; break; case "VB": sExt = "Visual Basic(*.vb)|*.vb"; break; case "JScript": sExt = "JScript(*.js)|*.js"; break; default: language = "CSharp"; sExt = "CSharp(*.cs|*.cs"; break; } saveFileDialog1.Filter = sExt; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { var path = saveFileDialog1.FileName; _currentCompileUnitBuilder.PublishCode(path); } _currentCompileUnitBuilder = null; NamespaceBox.Text = ""; ClassesBox.Items.Clear(); ToggelClassPanel(); }
static void Main() { var cb = new ClassBuilder("EntryPoint", TypeAttributes.Public, false); var pi = new ParameterItem(); pi.Name = "s"; pi.Type = typeof(string); IStatementLine[] Statements = new IStatementLine[] { new ExpressionStatementLine(), new ReturnStatementLine() }; var methodInvoke = new MethodInvokeExpressionLine(); methodInvoke.MethodName = "WriteLine"; var test = new TypeReferenceExpressionLine(); test.Type = "System.Console"; methodInvoke.TargetObject = test; var methodInvokeParam = new VariableReferenceExpressionLine(); methodInvokeParam.VariableName = "s"; methodInvoke.Parameters = new IExpressionLine[] { methodInvokeParam }; Statements[1].Expressions.Add(0, new VariableReferenceExpressionLine() { VariableName = "s" }); Statements[0].Expressions.Add(0, methodInvoke); cb.AddMethod <string>("Print", new ParameterItem[] { pi }, MemberAttributes.Public | MemberAttributes.Static, Statements); var cub = new CompileUnitBuilder("Bla"); var typeDecl = cb.GetDeclaration(); cub.AddClass(typeDecl); cub.PublishCode("c:\\Users\\Sytse\\Documents\\GitHubVisualStudio\\Minor_CodeGen\\CodeGen\\test.cs"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new CodeGenStudio()); }
public void IfUsingIsAddedWithAWhitespacedStringAsUsingShouldThowException() { var builder = new CompileUnitBuilder(NamespaceName); builder.AddUsing(" "); }
public void IfUsingIsAddedWithNullAsUsingShouldThowException() { var builder = new CompileUnitBuilder(NamespaceName); builder.AddUsing(null); }
public void IfClassDeclarationIsNullShouldThrowException() { var builder = new CompileUnitBuilder(NamespaceName); builder.AddClass(null); }
public void IfNewIntanceOfCompileUnitBuilderWithAWhitspaceStringAsNamespaceNameShouldThrowException() { var builder = new CompileUnitBuilder(" "); }
public void IfNewIntanceOfCompileUnitBuilderWithAnEmptyStringAsNamespaceNameShouldThrowException() { var builder = new CompileUnitBuilder(string.Empty); }
public void IfNewIntanceOfCompileUnitBuilderWithNullAsNamespaceNameShouldThrowException() { var builder = new CompileUnitBuilder(null); }