Talkin' bout MyGeneration

Posts   
 
    
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 24-Sep-2004 16:21:58   

Hi All,

Does anybody use llbl and MyGeneration together to create the DAL / BL?

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 26-Sep-2004 17:46:33   

ok, since I have no replies, I take it that nobody uses MyGeneration.

I have not use it but I was seeing if it was worth looking into. It seems that some of you guys use CodeSmith which looks very interesting as well.

So, having said that, have some of you created scripts for creating the spit (generated controls) region for things like two grids. The first grid being an Order Master the second grid being the Order Detail for example? If so, I think it would be great if someone could publish this like that.

Thanks,

Fishy

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 27-Sep-2004 12:21:34   

Fishy wrote:

ok, since I have no replies, I take it that nobody uses MyGeneration.

It's sort of a clone of codesmith. It uses the same principle: generate a class with code from a template, in memory, compile it in memory to an assembly and call the method you added to start the code with. Pretty simple simple_smile . I'm halfway through such a task performer, the parser is ready, I just have to add some preprocessor directives and the actual assembly compile code and it's ready to rock simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 27-Sep-2004 19:27:17   

Otis wrote:

It's sort of a clone of codesmith. It uses the same principle: generate a class with code from a template, in memory, compile it in memory to an assembly and call the method you added to start the code with. Pretty simple simple_smile . I'm halfway through such a task performer, the parser is ready, I just have to add some preprocessor directives and the actual assembly compile code and it's ready to rock simple_smile

So, let me understand this, you are creating a task performer that will allow llblgen to behave like codesmith?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 27-Sep-2004 20:10:04   

Cadmium wrote:

Otis wrote:

It's sort of a clone of codesmith. It uses the same principle: generate a class with code from a template, in memory, compile it in memory to an assembly and call the method you added to start the code with. Pretty simple simple_smile . I'm halfway through such a task performer, the parser is ready, I just have to add some preprocessor directives and the actual assembly compile code and it's ready to rock simple_smile

So, let me understand this, you are creating a task performer that will allow llblgen to behave like codesmith?

Yes. simple_smile . And you'll get the full sourcecode of it. I will use it for basic gui templates.

Frans Bouma | Lead developer LLBLGen Pro
hlesesne avatar
hlesesne
User
Posts: 47
Joined: 22-Jul-2004
# Posted on: 28-Sep-2004 14:26:05   

SWEET!

smile

erichar11
User
Posts: 268
Joined: 08-Dec-2003
# Posted on: 28-Sep-2004 17:43:24   

I'm glad you mentioned this, I was about to purchase codesmith stuck_out_tongue_winking_eye

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 28-Sep-2004 21:35:21   

Otis wrote:

Cadmium wrote:

Otis wrote:

It's sort of a clone of codesmith. It uses the same principle: generate a class with code from a template, in memory, compile it in memory to an assembly and call the method you added to start the code with. Pretty simple simple_smile . I'm halfway through such a task performer, the parser is ready, I just have to add some preprocessor directives and the actual assembly compile code and it's ready to rock simple_smile

So, let me understand this, you are creating a task performer that will allow llblgen to behave like codesmith?

Yes. simple_smile . And you'll get the full sourcecode of it. I will use it for basic gui templates.

Would you mine elaborating on this? Because my imagination is running wild frowning as to what this_ could_ mean.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 28-Sep-2004 22:12:08   

It means that you can create templates in C#, using asp style constructs, accessing any object in the project object, and emitting whatever you'd like. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 28-Sep-2004 22:23:32   

Otis wrote:

It means that you can create templates in C#, using asp style constructs, accessing any object in the project object, and emitting whatever you'd like. simple_smile

Very cool. I guess I better learn C#.

brettlj
User
Posts: 27
Joined: 08-Feb-2004
# Posted on: 29-Sep-2004 04:53:57   

Ok, I think we're getting to the point where LLCoolGen is a more appropriate name, it is getting cooler on a monthly basis. sunglasses

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 03-Oct-2004 17:08:17   

All right!

Almost there! smile

Generator config for test:


<generatorConfiguration>
    <name>Lpt template tester config</name>
    <description>Tests the new Lpt (C# based templates) engine.</description>
    <vendor>Solutions Design</vendor>
    <version>1.0.2004.1.100304</version>
    <tasks>
        <taskGroup description="Test generation group">
            <task name="TestsDirectoryCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.DirectoryCreator">
                <parameter name="folderToCreate" value="TestClasses"/>
                <parameter name="failWhenExistent" value="false"/>
                <parameter name="clearWhenExistent" value="false"/>
            </task>
            <task name="TestsGenerator" assemblyFilename="SD.LLBLGen.Pro.LptParser.dll" taskPerformerClass="SD.LLBLGen.Pro.LptParser.CsTemplateEngine">
                <parameter name="destinationFolder" value="TestClasses"/>
                <parameter name="failWhenExistent" value="false"/>
                <parameter name="filenameFormat" value="testclass.[extension]"/>
                <parameter name="templateID" value="LPT_TestTemplate"/>
                <parameter name="emitType" value="generic"/>
            </task>
        </taskGroup>
    </tasks>
</generatorConfiguration>

Templateset config for test:


<templateSetDefinition>
    <vendor>Solutions Design</vendor>
    <name>Lpt Test template set</name>
    <version>1.0.2004.1.100304</version>
    <trueKeyword>true</trueKeyword>
    <falseKeyword>false</falseKeyword>
    <thisKeyword>this</thisKeyword>
    <nullKeyword>null</nullKeyword>
    <targetLanguageDescription>C#</targetLanguageDescription>
    <fileExtension>cs</fileExtension>
    <arrayIndexOperatorOpenChar>[</arrayIndexOperatorOpenChar>
    <arrayIndexOperatorCloseChar>]</arrayIndexOperatorCloseChar>
    <hasArrayIndexOperatorOnIdentifier>false</hasArrayIndexOperatorOnIdentifier>
    <lineConcatenator></lineConcatenator>
    <templateBindings>
        <!-- test template bindings -->
        <templateBinding templateID="LPT_TestTemplate" templateFilename="..\..\..\LptTemplates\testtemplate.lpt" />
        <templateBinding templateID="LPT_TestTemplate2" templateFilename="..\..\..\LptTemplates\testtemplate2.lpt" />
    </templateBindings>
</templateSetDefinition>

testtemplate.lpt (lpt is from LLBLGen Pro Template stuck_out_tongue_winking_eye )


<$ C:\Myprojects\VS.NET Projects\LLBLGen Pro\RuntimeLibraries\DotNet11\SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll $>

<[ System.IO ]>
<[ System.Text ]>
<[ SD.LLBLGen.Pro.ORMSupportClasses ]>

<# LPT_TestTemplate2 #>

//////////////////////
// this is testcode
// Project name: <%=_executingGenerator.ProjectDefinition.ProjectName%>
//////////////////////
using System;

public class Doh
{
    public Doh() 
    {
<%
    for(int i=0;i<10;i++)
    {
        %>
        // Does: <%=WriteNonsense()%>
        Console.WriteLine("lalala");
        <%
    }
    
    %>
    // some sense: <%= WriteSense()%>
    <%
%>
    }
}

<~
public string WriteNonsense()
{
    return "Foo!";
}
~>

testtemplate2.lpt


<~
public string WriteSense()
{
    return "Bar!";
}
~>

will be parsed / generated into this C# code:


using SD.LLBLGen.Pro.ORMSupportClasses;
using SD.LLBLGen.Pro.ApplicationCore;
using SD.LLBLGen.Pro.DBDriverCore;
using System;
using System.Collections;
using SD.LLBLGen.Pro.GeneratorCore;
using System.Text;
using SD.LLBLGen.Pro.LptParser;
using System.IO;


public class LPT_TestTemplate2 : ITemplateClass {
    private StreamWriter __outputWriter;
    private IGenerator _executingGenerator;
    private Hashtable _parameters;

    public LPT_TestTemplate2() {
        __outputWriter=null;_executingGenerator=null;_parameters=null;
    }


public string WriteSense()
{
    return "Bar!";
}
    private void __ScriptCode() {
    }


    public void ___RUN(IGenerator executingGenerator, Hashtable parameters, StreamWriter outputWriter) {
        __outputWriter = outputWriter; _parameters = parameters; _executingGenerator=executingGenerator;
        __ScriptCode();
    }

}
public class LPT_TestTemplate : ITemplateClass {
    private StreamWriter __outputWriter;
    private IGenerator _executingGenerator;
    private Hashtable _parameters;

    public LPT_TestTemplate() {
        __outputWriter=null;_executingGenerator=null;_parameters=null;
    }


public string WriteSense()
{
    return "Bar!";
}

public string WriteNonsense()
{
    return "Foo!";
}
    private void __ScriptCode() {
        __outputWriter.Write("\n//////////////////////");
        __outputWriter.Write("\n// this is testcode");
        __outputWriter.Write("\n// Project name: ");
__outputWriter.Write(_executingGenerator.ProjectDefinition.ProjectName);
        __outputWriter.Write("\n//////////////////////");
        __outputWriter.Write("\nusing System;");
        __outputWriter.Write("\npublic class Doh");
        __outputWriter.Write("\n{");
        __outputWriter.Write("\n    public Doh() ");
        __outputWriter.Write("\n    {");

    for(int i=0;i<10;i++)
    {
        
        __outputWriter.Write("\n        // Does: ");
__outputWriter.Write(WriteNonsense());
        __outputWriter.Write("\n        Console.WriteLine(\"lalala\");");
        __outputWriter.Write("\n        ");

    }
    
    
        __outputWriter.Write("\n    // some sense: ");
__outputWriter.Write( WriteSense());
        __outputWriter.Write("\n    ");


        __outputWriter.Write("\n    }");
        __outputWriter.Write("\n}");
    }


    public void ___RUN(IGenerator executingGenerator, Hashtable parameters, StreamWriter outputWriter) {
        __outputWriter = outputWriter; _parameters = parameters; _executingGenerator=executingGenerator;
        __ScriptCode();
    }

}

... which is then compiled into a library assembly and executed by the engine, which results into this code in the file testclass.cs:



//////////////////////
// this is testcode
// Project name: TestDB
//////////////////////
using System;
public class Doh
{
    public Doh() 
    {
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
        // Does: Foo!
        Console.WriteLine("lalala");
        
    // some sense: Bar!
    
    }
}

!! smile !!

Needless to say, I'm very happy smile . I hope to finalize the code on monday and upload a beta. simple_smile

(there are more parameters thinkable for this, these will come up in the coming days I think when people start testing the bits simple_smile )

Note: the syntaxis is as simple as 1 2 3 simple_smile (beat that, codesmith! smile ) <$ referenced assembly $> , for referencing additional assemblies <[ referenced namespace ]> , for referencing namespaces (using ... ) <# include template id #> , for including (can be nested) other templates <% C# code %> , non-output C# code. <%= C# code %>, output C# code. Single statement, do not append a ';' <~ C# code ~> , code block, used to specify member variables for the template class, methods to use etc. etc.

all <% %> code will be added to a single method, (as well as the literal text between %> and <% simple_smile ) which is called by ___RUN(). ___RUN() is called by the engine to execute the template.

That's about it simple_smile

Frans Bouma | Lead developer LLBLGen Pro
bertcord avatar
bertcord
User
Posts: 206
Joined: 01-Dec-2003
# Posted on: 03-Oct-2004 22:30:04   

This looks awesome! Cant wait to check it out!

Otis wrote:

I will use it for basic gui templates.

What basic templates are you planning?

bert

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 03-Oct-2004 23:53:12   

I am totally new to code generators. So this may sound like a stupid flushed question.

Will I be able to output vb.net code or just c#, I'm guessing I'll be able to output anything I want but I just want to be sure.

Thanks,

Fishy.

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 03-Oct-2004 23:56:17   

Forget that last message flushed flushed I just scrolled up and saw the answer flushed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Oct-2004 10:31:54   

bertcord wrote:

This looks awesome! Cant wait to check it out!

simple_smile It is beyond what I expected simple_smile

I'm not sure what I'll do with the language thing. I think it's best to make it a bit more generic and also support VB.NET as a template language. This is not hard to do: check the extension in the template set config and for 'cs' go the C# compiler route and for 'vb' go the VB.NET compiler route. Usage of the compiled code is the same simple_smile

Otis wrote:

I will use it for basic gui templates.

What basic templates are you planning?

Just some basic gui stuff, entity editing forms for webapplications. But no plans are finalized yet.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Oct-2004 16:11:59   

I've made it more general so it now also supports VB.NET template code simple_smile


<$ C:\Myprojects\VS.NET Projects\LLBLGen Pro\RuntimeLibraries\DotNet11\SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll $>

<[ System.IO ]>
<[ System.Text ]>
<[ SD.LLBLGen.Pro.ORMSupportClasses ]>

<# LPT_TestTemplate2 #>

' //////////////////////
' // this is testcode
' // Project name: <%=_executingGenerator.ProjectDefinition.ProjectName%>
' //////////////////////
Imports System

Public Class Doh

    Public Sub New() 
<%
    Dim i As Integer
    For i=0 to 9
        %>
        ' Does: <%=WriteNonsense()%>
        Console.WriteLine("lalala")
        <%
    Next i
    
    %>
    ' some sense: <%= WriteSense()%>
    <%
%>
    End Sub
End Class

<~
Public Function WriteNonsense() As String
    Return "Foo!"
End Function
~>

output:


' //////////////////////
' // this is testcode
' // Project name: TestDB
' //////////////////////
Imports System
Public Class Doh
    Public Sub New() 
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
        ' Does: Foo!
        Console.WriteLine("lalala")
        
    ' some sense: Bar!
    
    End Sub
End Class

Frans Bouma | Lead developer LLBLGen Pro
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 04-Oct-2004 16:31:59   

That's great that it works using vb.net scripts.

I take it that we will have access to Entities and EntityCollections.

So, for example, a Lookup helper class could be generated which would create an Infragistic's ValueList object. Perhaps this would be done using the Custom Properties to identify which fields should be part of the valuelist. Would the be correct?

Would you have an IDE for this? Could you incorporate this within the llblgen IDE?

Thanks,

Fishy.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Oct-2004 17:08:00   

Fishy wrote:

That's great that it works using vb.net scripts.

It was 50 lines of code extra simple_smile

I take it that we will have access to Entities and EntityCollections.

You have access to the IGenerator object, which has a reference to the project object, the tasks being executed, the template set... and you've access to the parameters passed to the task.

So, for example, a Lookup helper class could be generated which would create an Infragistic's ValueList object. Perhaps this would be done using the Custom Properties to identify which fields should be part of the valuelist. Would the be correct?

Yes, you could do that.

Would you have an IDE for this? Could you incorporate this within the llblgen IDE?

I'm thinking about it. Or at least a simple tool to find bugs in the template code. With the command line generator you can easily test if your templates contain errors, and a parameter can be set to write the generated template sourcecode to disk, so you can examine that as well. It's not a priority though.

Frans Bouma | Lead developer LLBLGen Pro
bertcord avatar
bertcord
User
Posts: 206
Joined: 01-Dec-2003
# Posted on: 04-Oct-2004 19:10:54   

Otis wrote:

I will use it for basic gui templates.

What basic templates are you planning?

Just some basic gui stuff, entity editing forms for webapplications. But no plans are finalized yet.

Just keep me in the loop of what you are planning becasue if you are planning on doing some ASP.net edit forums I am sure they will be better than what I got stuck_out_tongue_winking_eye , and I will spend my time on other things like my server controls

Otis wrote:

You have access to the IGenerator object, which has a reference to the project object, the tasks being executed, the template set... and you've access to the parameters passed to the task.

very kewl, this will make the transition of my ASP.Net codesmith templete to LLBLGen easy (famous last words right? smile )

Otis wrote:

Fishy wrote:

Would you have an IDE for this? Could you incorporate this within the llblgen IDE?

I'm thinking about it. Or at least a simple tool to find bugs in the template code. With the command line generator you can easily test if your templates contain errors, and a parameter can be set to write the generated template sourcecode to disk, so you can examine that as well. It's not a priority though

I think this would be awesome, and without it (for me a least) make it difficult to develop templates. My style of development is what I call instant gratification, sometimes I will write a few lines and then want to see it work. Yeah yeah...I know that's not good, and I am sure Otis that you can write an entire program from start to finish...but not I...and since I do this mostly as a hobby then I do what makes me happy...

sooo anyhow have you seen this control http://www.actiprosoftware.com/Products/DotNet/SyntaxEditor/Default.aspx

Bert

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Oct-2004 21:22:41   

bertcord wrote:

Otis wrote:

I will use it for basic gui templates.

What basic templates are you planning?

Just some basic gui stuff, entity editing forms for webapplications. But no plans are finalized yet.

Just keep me in the loop of what you are planning becasue if you are planning on doing some ASP.net edit forums I am sure they will be better than what I got stuck_out_tongue_winking_eye , and I will spend my time on other things like my server controls

simple_smile Well, we're not the greatest in ASP.NET over here, but we'll give it a try. I have to say, the screenshots of your templates looked amazingly good.

Otis wrote:

You have access to the IGenerator object, which has a reference to the project object, the tasks being executed, the template set... and you've access to the parameters passed to the task.

very kewl, this will make the transition of my ASP.Net codesmith templete to LLBLGen easy (famous last words right? smile )

It should be easy. Just remove the declaration crap at the top of your templates and replace it with easier statements, and the <script runat="template"> things can be changed to <~ and ~> simple_smile And because it supports includes, you can create very powerful templates with not that much code simple_smile

Otis wrote:

Fishy wrote:

Would you have an IDE for this? Could you incorporate this within the llblgen IDE?

I'm thinking about it. Or at least a simple tool to find bugs in the template code. With the command line generator you can easily test if your templates contain errors, and a parameter can be set to write the generated template sourcecode to disk, so you can examine that as well. It's not a priority though

I think this would be awesome, and without it (for me a least) make it difficult to develop templates. My style of development is what I call instant gratification, sometimes I will write a few lines and then want to see it work. Yeah yeah...I know that's not good, and I am sure Otis that you can write an entire program from start to finish...but not I...and since I do this mostly as a hobby then I do what makes me happy... sooo anyhow have you seen this control http://www.actiprosoftware.com/Products/DotNet/SyntaxEditor/Default.aspx

Yes I've seen that control, it looks promising simple_smile .

What works best is that you first write out what you want to generate, then create a template for that. This saves a lot fo trial & error time. The commandline generator can help you out with finding errors/producing results for now, it's not a gui with tabs, but that can come simple_smile

Btw, I've uploaded the beta to the Extras section. I've added a small example and a readme with information. I hope to fix an issue with combined templates in one template set tomorrow.

There is no separate forum for the beta yet. I'll add that now.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Oct-2004 21:47:25   
Frans Bouma | Lead developer LLBLGen Pro