I recently noticed that Visual Studio 2010 (Professional) inserts a FileHeader automatically in new class files. I don't know when this started but some time ago this wasn't enabled. Also, since then the using directives are added after the namespace.
This is the way the file looks like after generation:
// -----------------------------------------------------------------------
// <copyright file="Class1.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
namespace MyNamespace
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// <summary>
/// TODO: Update summary.
/// </summary>
public class Class1
{
}
}
And thats the way it should look like (and how I want it):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyNamespace
{
public class Class1
{
}
}
I disabled all extensions and all plugins, but the problem stays. Hopefully anyone here can tell my how to restore the previoous behaviour.
Thanks in advance
Visual studio uses templates to generate new files. You can read about how to create your own templates here http://stevesmithblog.com/blog/how-to-fix-visual-studio-file-templates/. The default templates are commonly stored in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates and it is these you'll want to edit if you want to globally replace the format.
For me the file headers showed up after installing Resharper
and Stylecop
.
To get rid of them I disabled the header inclusions in Resharper
(Code Cleanup section) and also made sure the file header rules are no longer enforced in StyleCop
. Next I modified the file templates stimms mentioned earlier. And finally I had to run devenv.exe /installvstemplates from the command line for Visual Studio to register the changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With