Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Source-based File Templates #8

Open
khalidabuhakmeh opened this issue Aug 18, 2022 · 0 comments
Open

Support Source-based File Templates #8

khalidabuhakmeh opened this issue Aug 18, 2022 · 0 comments

Comments

@khalidabuhakmeh
Copy link

Similar to Source Templates, it would be nice to be able to ship File Templates inside of source code projects and NuGet Packages. This would help OSS projects ship boilerplate code and light-up experiences inside of ReSharper and Rider.

I'm still not sure 100% how to define variables, but an array of comma delimited values might work. Here's an example of a file template defined in code.

using JetBrains.Annotations;

public static class MySourceTemplates
{
    [FileTemplate(
        DefaultFileName="ClassTests.cs",
        Description = "Tests for $CLASS$", 
        Reformat=true, 
        ShortenQualifyingReferences=true, 
        Availability=new [] { "C# Projects", "F# Projects" }, 
        AddToNewMenu=true,
        Variables = new []
        {
            // Name, Macro, Editable (default false) 
            "HEADER,FileHeader",
            "CLASS,Current File Name,true",
            "NAMESPACE,"
        })]
    public static void xunit_test()
    {
        /* 
   $HEADER$namespace $NAMESPACE$
   {
     public class $CLASS$_TESTS {$END$}
   }
       */
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant