CodeSmith Community
Your Code. Your Way. Faster!

New VS.NET Addin

Latest post 05-23-2006 9:06 AM by Napster. 25 replies.
  • 05-19-2005 2:26 PM

    • gaulu1
    • Top 500 Contributor
    • Joined on 12-09-2003
    • Posts 16
    • Points 33,025
    Here is my contribution to the CodeSmith Community.
     
    It's an add-in to VS.NET to generate code, base on CodeSmith template, to the active window.
     
    After the installation, you will find in the Tools menu, two new items: "AutoCodeSmith" and "AutoCodeSmith Settings".
     
    You use the settings form to to give an alias to a template file (.cst).
     
    Example
        Alias=a,  template= c:\codesmithtemplate\templateA.cst
     
        In the active Window, you can enter this line
     
        parm1 parm2 parm3 a <ctrl-enter>
     
    This will replace that line with the result of the codesmith template where property1 to property3 of the template are replace, in that order, by parm1 to parm3.
     
    I'll give you, with the installation, two simple templates: Property.cst and RegionTemplate.cst, respectivly with p and r alias (see in the settings form).
     
    Look at the RegionTemplate.cst template. The [@] indicate the position of the cursor after the insertion of the template output in the active window.
     
     
    The two example tempate installed with AutoCodeSmith can be used like that
     
    For the property template
       Username String p <ctrl-enter>
     
    For the region template
       Properties r <ctrl-enter>
     
    Please give me your feedback and if you find bugs, let me know.
     
    I hope it's clear enough and my english is not too bad.
     
    Luc
     
    2005-06-09- New version: 1.5
     
    1. AutoCodeSmith settings form redesign
    2. Default template values
    3. Parameters reorder
    4. CodeSmith 3.0 compatible
     
    2005-06-10- New version: 1.5.1
     
    1. No output problem fixed
     
    2005-06-21 - New version: 1.5.2

    Fixed a bug: Alias not correctly update in AutoCodeSmith Settings form when it change.
    Fixed a bug: Settings form close when up or down arrow in Parameters Order is click with no selected parmeters
    Improvement: In Settings form, remove command button is only available if a command is selected
     

    2005-07-01 New Version 1.5.3

    Fixed a bug: Unable to give a string with space. Surround the string with double quote Ex: "Foo bar".
    Improvement: Add docking capability to the Settings form

    2005-07-29 Version 1.5.4
    Improvement: Output is indented properly according to the indentation level of the the command string

    Message Edité (Gaulu1) : 8/15/2005 1:45:43 PM GMT

    • Post Points: 360
  • 05-25-2005 5:23 PM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-28-2002
    • Dallas, TX USA
    • Posts 2,197
    • Points 922,380

    RE: New VS.NET Addin

    Sweet! I was planning to add this functionality myself. Nice work! :-)

    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 05-25-2005 5:43 PM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-28-2002
    • Dallas, TX USA
    • Posts 2,197
    • Points 922,380

    RE: New VS.NET Addin

    Luc,

    I got it setup and running and it looks good. I have been planning to implement this functionality myself and so I had in my mind how I wanted it to work. You are very close, but here is some feedback:

    1. I prefer the template trigger to be first and the parameters to be after. ie. Instead of "UserName String p", I'd like to use "p string UserName".

    2. I was thinking that for the configuration of each template, you could map param1 to property X, param2 to property Y, etc. This way you could have additional properties on your template that wouldn't be set by the parameters. Also, I was thinking that in the configuration for the template, I would show the user a propertygrid for the template, and let them set any hard-coded properties that they wanted to. So they could have a template with a bunch of properties and get them all setup how they want them and then the parameters would be able to set any additional properties. The properties can be serialized and saved in your configuration file using the SavePropertiesToXml method of CodeTemplate.

    Thanks,
    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 05-25-2005 6:00 PM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-28-2002
    • Dallas, TX USA
    • Posts 2,197
    • Points 922,380

    RE: New VS.NET Addin

    Also, it would be cool if the output was indented properly according to the indentation level of the the command string. You can use the new Reponse.IndentLevel property in CodeSmith 3.0 to accomplish this.

    Thanks,
    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 05-25-2005 7:41 PM In reply to

    RE: New VS.NET Addin

    I have installed this on two machines, and nothing works. When asked to specify the folder I had installed CodeSmith in, I told it the v3.0 folder. What else do I need to do? Nothing showed up on the Tools menu, and I even tried using the two examples to no avail. This tool rocks, especially if I can get it to work. :P
    j a s o n   b u n t i n g
    • Post Points: 5
  • 05-25-2005 7:47 PM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-28-2002
    • Dallas, TX USA
    • Posts 2,197
    • Points 922,380

    RE: New VS.NET Addin

    Actually, I had this problem too. Point it to the bin directory inside of the CodeSmith installation directory and it will work.

    Thanks,
    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 05-25-2005 8:15 PM In reply to

    RE: New VS.NET Addin

    w00t! :P

    Sweetness, this is *nice*. I know squat about writing add ins for VS, but would it be hard to basically build a refactoring type tool for VS using this same type of construct? So, rather than type things in like that, simple enter:

    private string m_FirstName;

    Then, while on the line or maybe after highlighting it or right-clicking on it, simply run the same type of code? If not, no biggie, this is still pretty stinking cool. This would be a poor man's way of implementing the code snippets type thing that VS2005 will have (although not nearly as good, obviously).
    j a s o n   b u n t i n g
    • Post Points: 5
  • 05-25-2005 8:25 PM In reply to

    • gaulu1
    • Top 500 Contributor
    • Joined on 12-09-2003
    • Posts 16
    • Points 33,025

    RE: New VS.NET Addin

    ejsmith said...
    Luc,

    I got it setup and running and it looks good. I have been planning to implement this functionality myself and so I had in my mind how I wanted it to work. You are very close, but here is some feedback:

    1. I prefer the template trigger to be first and the parameters to be after. ie. Instead of "UserName String p", I'd like to use "p string UserName".

    2. I was thinking that for the configuration of each template, you could map param1 to property X, param2 to property Y, etc. This way you could have additional properties on your template that wouldn't be set by the parameters. Also, I was thinking that in the configuration for the template, I would show the user a propertygrid for the template, and let them set any hard-coded properties that they wanted to. So they could have a template with a bunch of properties and get them all setup how they want them and then the parameters would be able to set any additional properties. The properties can be serialized and saved in your configuration file using the SavePropertiesToXml method of CodeTemplate.

    Thanks,
    Eric J. Smith

     
    1. If everybody ask for it i'll change this
     
    2. You read in my mind. It's exactly what I'm working on now for the next version. Almost done.
     
    Luc
    • Post Points: 5
  • 05-25-2005 9:14 PM In reply to

    RE: New VS.NET Addin

    Hey, I can't get any template other than the properties one to work. I have tried the Region template supplied, as well as my own (all it does is place a comment in the file) and no go. Any ideas?

    Thanks!
    j a s o n   b u n t i n g
    • Post Points: 5
  • 05-26-2005 9:07 PM In reply to

    • gaulu1
    • Top 500 Contributor
    • Joined on 12-09-2003
    • Posts 16
    • Points 33,025

    RE: New VS.NET Addin

    ejsmith said...



    2. ... you could map param1 to property X, param2 to property Y, etc. This way you could have additional properties on your template that wouldn't be set by the parameters. ...

    It's not true. It's not require that you set all parameters. If you give only one parameter, it will set the first property. If you give two parameters, they will set the first and the second, if you ...
     
    But the next version I'm working on will be more flexible. You will be able to reorder the prameters and you also will be able to specified default values for the template properties.
     
    Luc
    • Post Points: 5
  • 06-10-2005 2:56 AM In reply to

    • gaulu1
    • Top 500 Contributor
    • Joined on 12-09-2003
    • Posts 16
    • Points 33,025

    RE: New VS.NET Addin

    New version available. See the first post of this thread.
    • Post Points: 5
  • 06-10-2005 5:05 AM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-28-2002
    • Dallas, TX USA
    • Posts 2,197
    • Points 922,380

    RE: New VS.NET Addin

    I just tried the new version and can't seem to get it to work. It doesn't seem to pull the properties up when I select an alias and when I press Ctrl-Enter, nothing happens either. It's like it can't compile the template, but it's not giving any feedback as to why.

    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 06-11-2005 12:41 AM In reply to

    • gaulu1
    • Top 500 Contributor
    • Joined on 12-09-2003
    • Posts 16
    • Points 33,025

    RE: New VS.NET Addin

    ejsmith said...
    I just tried the new version and can't seem to get it to work. It doesn't seem to pull the properties up when I select an alias and when I press Ctrl-Enter, nothing happens either. It's like it can't compile the template, but it's not giving any feedback as to why.

    Eric J. Smith

    See first post of this thread. Problem fixed in v1.5.1
     
    To see any error generate by AutoCodeSmith, open View-->Other Windows-->Output.
     
    In the dropdown list of the output pane, select AutoCodeSmith.
     
    Luc
    • Post Points: 5
  • 06-13-2005 4:19 PM In reply to

    • Ran W
    • Not Ranked
    • Joined on 07-27-2004
    • Posts 1
    • Points 5

    RE: New VS.NET Addin

    hi

    Great add in.

    Can you make a version for vs 2005 beta ?

    • Post Points: 5
  • 06-13-2005 4:57 PM In reply to

    • gaulu1
    • Top 500 Contributor
    • Joined on 12-09-2003
    • Posts 16
    • Points 33,025

    RE: New VS.NET Addin

    I'm very busy on other projects, but it's in my todo list to make a VS 2005 version.
     
    Stay tuned.
     
    Luc
    • Post Points: 35
Page 1 of 2 (26 items) 1 2 Next > | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems