Skip to content

Support Source-based File Templates #8

Description

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$}
   }
       */
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions