Scripty icon indicating copy to clipboard operation
Scripty copied to clipboard

Auto run custom tool when *.cs document saving

Open tylike opened this issue 8 years ago • 3 comments

Thank you for mentioning a great tool. Can you provide settings for automatically running the custom tool when the document is saved (*. cs or can be set) in the VSIX? In my project, I use interfaces to define the domain structure, and they are stored in *. CS, so I want to be able to automate the CSX file to generate other CS files when any CS file is saved. For example, I can write some default interface implementation code. In this way, we don't have to wait until the default interface for C # 8.0 is implemented. Once saved, we can generate more code, for example, to generate a user interface, based on code that has already been written. After generating the code, you can also have IntelliSense capabilities that look like we've expanded C #.:D Thank you so much!

tylike avatar Oct 17 '17 15:10 tylike

I am lookING for same feature

npelletm avatar Oct 29 '17 23:10 npelletm

If I'm understanding correctly, the Custom Tool should be able to do this. You can get it here and usage instructions are in the readme.

daveaglick avatar Oct 31 '17 01:10 daveaglick

Yes, I've seen the custom tool. A better experience is like this (just a little bit of advice): xxx.csproj 1.The project contains Scripty. setting. CSX

Context. Onsaving = (Savingargs, syntaxTree) =>
{
   //Returns true if a condition is met, and Scripty templates runs
   if (Savingargs. FileName. EndsWith (". cs"))
   {
        Savingargs. Runcsxtemplate = true;
        Savingargs. Templates. Add ("T1. CSX");
        Savingargs. Templates. Add ("T2. CSX");
    }
}

2.The programmer creates a ICustomer. cs file:

public interface ICustomer{
    string Name{get;set;}
}

3.when ICustomer.cs saved. custom tool run scripty t1.csx file.create ICustomer.g.cs file:

public class Customer:ICustomer{
    public string Name{get;set;}
}

Usually, there are many interfaces to write, which may be simpler if you do not set custom tool in the Properties window in vs.

It might be something like this (https://github.com/daveaglick/Scripty/issues/4) you were thinking about.

tylike avatar Nov 03 '17 16:11 tylike