madskristensen / AddAnyFile

A Visual Studio extension
Apache License 2.0
262 stars 119 forks source link

[Feature] The created file should conform to the .editorconfig rules (or other defaults set by the user) #105

Open sander1095 opened 2 years ago

sander1095 commented 2 years ago

Description

If you currently create a .cs file, the file is just created without conforming to the rules of an .editorconfig in the project. This is a bit of shame, because it requires either manual editing of the created file or changes to the templates of this extension. This wastes the developers time and makes the extension difficult to use for multiple projecs with different code styles.

I think it would be a nice addition to make the file conform to the .editorconfig of the project, or the formatting preferences of the user's IDE. Perhaps an abstraction for this already exists because format document in VS listens to the editorconfig or if that odes not exist, to the VS settings.

This also covers #50 and #67.

Steps to reproduce

Expected behavior:

Actual behavior:

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SomeNamespace
{
    public class Foo
    {

    }
}

If this extension would format the file according to the rules of the editorconfig (and format it after creation), it could look like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SomeNamespace;

public class Foo
{

}

Benefits

sander1095 commented 2 years ago

Perhaps this should be a new issue, but perhaps the extension should also take a look if something like ImplicitUsings are used in the project. That way the using statements might not be required if they are already imported globally.

ahmad2smile commented 2 years ago

Was just looking for if there are possible settings I could set to make it not use blocked/braces based namespace.