Change template classes in Visual Studio

7

Is there a way to configure Visual Studio to create classes with public ?

When you create a class by template, either from the dropdown menu of a mouse over a class name that does not exist yet, or by adding a class to a project, they are created without public .

Example:

class QualquerCoisa
{
}

Is there a way to get it created with public ?, like this:

public class QualquerCoisa
{
}

How?

    
asked by anonymous 13.11.2014 / 01:01

1 answer

9

Look for this file, it's the one you want to change:

C:\Program Files (x86)\Microsoft Visual Studio.0\Common7\IDE\ItemTemplates\CSharp\Code33\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 placed GitHub for future reference .

To use with other versions of VS simply change the version in the file path. Just remembering that Visual Studio 2010 behind the file is compressed in zip format. It is unlikely to fundamentally change in future releases like the new Visual Studio 2015 or the Community edition that is free for almost everyone. In addition to .Net pass have MIT license .

    
13.11.2014 / 01:09