Permalink
Browse files

Added DotNet global tool for code formatting. (#29403)

Added DotNet global tool for code formatting.

Tool can be run on a project, solution, or folder containing a
project or solution. Tool pulls formatting configuration from an
.editorconfig if present, otherwise formats with roslyn defaults.
  • Loading branch information...
JoeRobich committed Oct 10, 2018
1 parent 7db4484 commit 0f340a52c25aba3e0e7886d214df4e8d815e1627
Showing with 2,884 additions and 78 deletions.
  1. +7 −0 Roslyn.sln
  2. +56 −1 THIRD-PARTY-NOTICES.txt
  3. +1 −1 build/Targets/Imports.targets
  4. +4 −0 build/Targets/Packages.props
  5. +3 −3 src/Compilers/Core/Portable/FileSystem/PathUtilities.cs
  6. +1 −1 src/Compilers/Core/Portable/InternalUtilities/FileNameUtilities.cs
  7. +1 −1 src/NuGet/VisualStudio/VS.ExternalAPIs.Roslyn.Package.csproj
  8. +126 −70 src/Setup/Roslyn.ThirdPartyNotices/ThirdPartyNotices.rtf
  9. +158 −0 src/Tools/dotnet-format/CodeFormatter.cs
  10. +60 −0 src/Tools/dotnet-format/Logging/SimpleConsoleLogger.cs
  11. +16 −0 src/Tools/dotnet-format/Logging/SimpleConsoleLoggerFactoryExtensions.cs
  12. +28 −0 src/Tools/dotnet-format/Logging/SimpleConsoleLoggerProvider.cs
  13. +95 −0 src/Tools/dotnet-format/MSBuild/MSBuildCoreLoader.cs
  14. +78 −0 src/Tools/dotnet-format/MSBuild/MSBuildEnvironment.cs
  15. +104 −0 src/Tools/dotnet-format/MSBuild/MSBuildWorkspaceFinder.cs
  16. +93 −0 src/Tools/dotnet-format/Options/EditorConfigOptionsApplier.cs
  17. +109 −0 src/Tools/dotnet-format/Program.cs
  18. +50 −0 src/Tools/dotnet-format/README.md
  19. +250 −0 src/Tools/dotnet-format/Resources.Designer.cs
  20. +180 −0 src/Tools/dotnet-format/Resources.resx
  21. +64 −0 src/Tools/dotnet-format/dotnet-format.csproj
  22. +107 −0 src/Tools/dotnet-format/xlf/Resources.cs.xlf
  23. +107 −0 src/Tools/dotnet-format/xlf/Resources.de.xlf
  24. +107 −0 src/Tools/dotnet-format/xlf/Resources.es.xlf
  25. +107 −0 src/Tools/dotnet-format/xlf/Resources.fr.xlf
  26. +107 −0 src/Tools/dotnet-format/xlf/Resources.it.xlf
  27. +107 −0 src/Tools/dotnet-format/xlf/Resources.ja.xlf
  28. +107 −0 src/Tools/dotnet-format/xlf/Resources.ko.xlf
  29. +107 −0 src/Tools/dotnet-format/xlf/Resources.pl.xlf
  30. +107 −0 src/Tools/dotnet-format/xlf/Resources.pt-BR.xlf
  31. +107 −0 src/Tools/dotnet-format/xlf/Resources.ru.xlf
  32. +107 −0 src/Tools/dotnet-format/xlf/Resources.tr.xlf
  33. +107 −0 src/Tools/dotnet-format/xlf/Resources.zh-Hans.xlf
  34. +107 −0 src/Tools/dotnet-format/xlf/Resources.zh-Hant.xlf
  35. +1 −0 src/VisualStudio/Setup/Roslyn.VisualStudio.Setup.csproj
  36. +4 −0 src/Workspaces/Core/MSBuild/Host/SimpleAnalyzerAssemblyLoaderService.cs
  37. +4 −1 src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj
@@ -395,6 +395,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PortableFacades.Setup", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Compilers.Setup", "src\Setup\DevDivVsix\CompilersPackage\Microsoft.CodeAnalysis.Compilers.Setup.csproj", "{03607817-6800-40B6-BEAA-D6F437CD62B7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-format", "src\Tools\dotnet-format\dotnet-format.csproj", "{4A9B5423-11BF-4E1D-B231-C9A2FDD78EC4}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4
@@ -1056,6 +1058,10 @@ Global
{03607817-6800-40B6-BEAA-D6F437CD62B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03607817-6800-40B6-BEAA-D6F437CD62B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03607817-6800-40B6-BEAA-D6F437CD62B7}.Release|Any CPU.Build.0 = Release|Any CPU
{4A9B5423-11BF-4E1D-B231-C9A2FDD78EC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A9B5423-11BF-4E1D-B231-C9A2FDD78EC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A9B5423-11BF-4E1D-B231-C9A2FDD78EC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A9B5423-11BF-4E1D-B231-C9A2FDD78EC4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1244,6 +1250,7 @@ Global
{B9843F65-262E-4F40-A0BC-2CBEF7563A44} = {C52D8057-43AF-40E6-A01B-6CDBB7301985}
{952808C5-799A-4CAA-964C-2AA78458CEC7} = {BE25E872-1667-4649-9D19-96B83E75A44E}
{03607817-6800-40B6-BEAA-D6F437CD62B7} = {BE25E872-1667-4649-9D19-96B83E75A44E}
{4A9B5423-11BF-4E1D-B231-C9A2FDD78EC4} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29}
@@ -22,4 +22,59 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License notice for DotNetTools
-------------------------------------
https://github.com/aspnet/DotNetTools
Copyright (c) .NET Foundation and Contributors
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
License notice for DocFX
-------------------------------------
https://github.com/dotnet/docfx
Copyright (c) Microsoft Corporation
This software is licensed subject to the MIT license, available at
https://opensource.org/licenses/MIT
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License notice for MSBuild Locator
-------------------------------------
https://github.com/Microsoft/MSBuildLocator
Copyright (c) Microsoft Corporation. All rights reserved.
This software is licensed subject to the MIT license, available at
https://opensource.org/licenses/MIT
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -15,7 +15,7 @@
<!-- Only generate our runtimeconfig.json files for net core apps. It's unnecessary in desktop projects
but gets included in lots of output items like VSIX. -->
<GenerateRuntimeConfigurationFiles Condition="'$(TargetFramework)' != 'netcoreapp1.1' AND '$(TargetFramework)' != 'netcoreapp2.0'">false</GenerateRuntimeConfigurationFiles>
<GenerateRuntimeConfigurationFiles Condition="'$(TargetFramework)' != 'netcoreapp1.1' AND '$(TargetFramework)' != 'netcoreapp2.0' AND '$(TargetFramework)' != 'netcoreapp2.1'">false</GenerateRuntimeConfigurationFiles>
<!-- Place VS insertion (CoreXT) packages to a separate directory -->
<PackageOutputPath Condition="'$(IsVisualStudioInsertionPackage)' == 'true'">$(ArtifactsConfigurationDir)DevDivPackages\Roslyn\</PackageOutputPath>
@@ -63,6 +63,8 @@
<MicrosoftDotNetVersionToolsVersion>1.0.27-prerelease-01811-02</MicrosoftDotNetVersionToolsVersion>
<MicrosoftDotNetBuildTasksFeedVersion>2.1.0-prerelease-02419-02</MicrosoftDotNetBuildTasksFeedVersion>
<MicrosoftDotNetSignToolVersion>1.0.0-beta.18455.10</MicrosoftDotNetSignToolVersion>
<MicrosoftExtensionsDependencyInjectionVersion>2.1.1</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsLoggingVersion>2.1.1</MicrosoftExtensionsLoggingVersion>
<MicrosoftIdentityModelClientsActiveDirectoryVersion>3.13.8</MicrosoftIdentityModelClientsActiveDirectoryVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.8.27812-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>14.3.25407-alpha</MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>
@@ -172,6 +174,7 @@
<SystemCollectionsVersion>4.3.0</SystemCollectionsVersion>
<SystemCollectionsConcurrentVersion>4.3.0</SystemCollectionsConcurrentVersion>
<SystemCollectionsImmutableVersion>1.5.0</SystemCollectionsImmutableVersion>
<SystemCommandLineExperimentalVersion>0.1.0-alpha-63227-01</SystemCommandLineExperimentalVersion>
<SystemConsoleVersion>4.3.0</SystemConsoleVersion>
<SystemDataCommonVersion>4.3.0</SystemDataCommonVersion>
<SystemDiagnosticsContractsVersion>4.3.0</SystemDiagnosticsContractsVersion>
@@ -355,6 +358,7 @@
https://vside.myget.org/F/vssdk/api/v3/index.json;
https://vside.myget.org/F/vs-impl/api/v3/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
https://dotnet.myget.org/F/system-commandline/api/v3/index.json;
</RestoreSources>
</PropertyGroup>
@@ -109,7 +109,7 @@ public static string GetFileName(string path, bool includeExtension = true)
/// Get directory name from path.
/// </summary>
/// <remarks>
/// Unlike <see cref="System.IO.Path.GetDirectoryName"/> it doesn't check for invalid path characters
/// Unlike <see cref="System.IO.Path.GetDirectoryName(string)"/> it doesn't check for invalid path characters
/// </remarks>
/// <returns>Prefix of path that represents a directory</returns>
public static string GetDirectoryName(string path)
@@ -627,8 +627,8 @@ private static bool PathCharEqual(char x, char y)
return true;
}
return IsUnixLikePlatform
? x == y
return IsUnixLikePlatform
? x == y
: char.ToUpperInvariant(x) == char.ToUpperInvariant(y);
}
@@ -172,7 +172,7 @@ internal static int IndexOfFileName(string path)
/// <summary>
/// Get file name from path.
/// </summary>
/// <remarks>Unlike <see cref="System.IO.Path.GetFileName"/> doesn't check for invalid path characters.</remarks>
/// <remarks>Unlike <see cref="System.IO.Path.GetFileName(string)"/> doesn't check for invalid path characters.</remarks>
internal static string GetFileName(string path, bool includeExtension = true)
{
int fileNameStart = IndexOfFileName(path);
@@ -85,7 +85,7 @@
<_File Include="$(_Dlls)Microsoft.CodeAnalysis.VisualBasic.Workspaces\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll" TargetDir="" />
<_File Include="$(_Dlls)Microsoft.CodeAnalysis.VisualBasic\Microsoft.CodeAnalysis.VisualBasic.dll" TargetDir="" />
<_File Include="$(_Dlls)Microsoft.CodeAnalysis.Workspaces.Desktop\Microsoft.CodeAnalysis.Workspaces.Desktop.dll" TargetDir="" />
<_File Include="$(_Dlls)Microsoft.CodeAnalysis.Workspaces.MSBuild\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll" TargetDir="" />
<_File Include="$(_Dlls)Microsoft.CodeAnalysis.Workspaces.MSBuild\net46\Microsoft.CodeAnalysis.Workspaces.MSBuild.dll" TargetDir="" />
<_File Include="$(_Dlls)Microsoft.CodeAnalysis.Workspaces\Microsoft.CodeAnalysis.Workspaces.dll" TargetDir="" />
<_File Include="$(_Dlls)Microsoft.VisualStudio.LanguageServices.CSharp\Microsoft.VisualStudio.LanguageServices.CSharp.dll" TargetDir="" />
<_File Include="$(_Dlls)Microsoft.VisualStudio.LanguageServices.Implementation\Microsoft.VisualStudio.LanguageServices.Implementation.dll" TargetDir="" />
Oops, something went wrong.

0 comments on commit 0f340a5

Please sign in to comment.