dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

Remove unneeded using statements #21

Closed sean-gilliam closed 9 years ago

sean-gilliam commented 9 years ago

This is probably a frivolous issue, but looking at HEAD there are ~3000 unused using statements spread across >800 files spanning the project. It would be nice to clean these up a bit.

Not picking on any particular class, but lets take /src/XMakeBuildEngine/BackEnd/BuildManager/BuildRequestData.cs

This:

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

using Microsoft.Build.Collections;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Shared;

can be shortened to this:

using System;
using System.Collections.Generic;

using Microsoft.Build.Collections;
using Microsoft.Build.Shared;
dannyvv commented 9 years ago

If someone is willing to pick this up. We are using https://github.com/dotnet/codeformatter to format our code. The best approach would be to add support for this to the formatter and run it on our codebase. CoreFx, CoreClr, Roslyn and various other projects would benefit then too.

AndyGerlicher commented 9 years ago

Looks like they have an issue on that already. Would be great to have! https://github.com/dotnet/codeformatter/issues/79

am11 commented 9 years ago

:+1:

Meanwhile, see the batch format extension: https://visualstudiogallery.msdn.microsoft.com/a7f75c34-82b4-4357-9c66-c18e32b9393e. (GH: https://github.com/yongfa365/BatchFormat) Once installed, open VS solution, close all files, right-click solution node in Solution Explorer and select: Batch Format > Remove and Sort Usings and Format Document. Problem solved! :)

Also, if you have .editorconfig in project root (https://github.com/editorconfig/editorconfig-visualstudio#readme), the BatchFormat extension will work as expected, as it calls IDE's default formatter to format the document.

Last but not the least, if you throw a .gitattributes file (containing same formatting rules) to the root of the repo, the folks using *nix contributing to this repo will never publish C# file without CRLF, yet there won't be no dis-ambiguity. Ex: https://github.com/madskristensen/WebEssentials2015/blob/master/.gitattributes. (hint: git does push-time formatting, so the code formatting in the repo remain consistent)

PS: now if dotnet/CodeFormatter is able to somehow acknowledge/engage all those artifacts (by providing export/import .editorconfig/.gitattributes), that would be super rad! :sunglasses:

a053a commented 9 years ago

Pull request https://github.com/Microsoft/msbuild/pull/60