Search code examples
c#commentsvisual-studio-2019auto-generate

auto generate comments at the top of the Program.cs file in Visual Studio 2019


I'm new to Visual Studio 2019 and C#. Is there a way to auto generate comments at the top of the project solution Program.cs file with the file name , author, date stamp, version, etc.,(ideally every time a new project or an individual class file is created)? I've done it in the past in Eclipse and JetBrain's products thru a simple template file but it doesn't appear to be that cut and dry in Visual Studio 2019.

I tried this just to test it: (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\ConsoleApplication\program.cs)

using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;
$if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;
$endif$

/** 
* $safeprojectname$
* $username$
* $time$
*/

namespace $safeprojectname$
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}

Didn't work.


Solution

  • You can use EditorConfig to Add file header.