Change class template in Visual Studio

Asked

Viewed 871 times

9

There is a way to configure Visual Studio to create classes with public?

When creating a class by template, either by menu dropdown mouse over a class name not yet existing, or by adding a class in a project, they are created without the public.

Example:

class QualquerCoisa
{
}

Is there a way to make it be created with the public? , so:

public class QualquerCoisa
{
}

Like?

1 answer

10


Look for this file, it’s him you want to change:

C:\Program Files (x86)\Microsoft Visual Studio\12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs

I think it would look something like this:

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$
namespace $rootnamespace$
{
    public class $safeitemrootname$
    {
    }
}

I put in the Github for future reference.

To use with other versions of VS just change the version in the file path. Just remembering that from Visual Studio 2010 behind the file is compressed in format zip. It is unlikely to change fundamentally in future versions like the new Visual Studio 2015 or the community edition which is free to almost everyone. In addition to the . NET pass have mit license.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.