diff --git a/NuGet.config b/NuGet.config
index fbddcee588..25922a466c 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -6,7 +6,6 @@
-
diff --git a/eng/Versions.props b/eng/Versions.props
index 5660034e7e..f21a4a823c 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -9,19 +9,20 @@
3.6.0-1.20114.6
+ 3.1.1
- 0.1.0-alpha-63729-01
- 0.1.0-alpha-63729-01
- 1.2.2
- 1.0.0-beta1-63812-02
- 2.1.1
- 2.1.1
+ 2.0.0-beta1.20104.2
+ 0.3.0-alpha.20104.2
+ 1.2.6
+ 1.0.1-beta1.20114.4
+ $(MicrosoftExtensionsVersion)
+ $(MicrosoftExtensionsVersion)
1.1.20180503.2
- 3.0.0-beta2.20077.2
+ 3.0.0-beta2.20114.1
$(MicrosoftNETCoreCompilersPackageVersion)
4.7.0
diff --git a/src/Logging/NullScope.cs b/src/Logging/NullScope.cs
new file mode 100644
index 0000000000..c725014212
--- /dev/null
+++ b/src/Logging/NullScope.cs
@@ -0,0 +1,19 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.
+
+using System;
+
+namespace Microsoft.CodeAnalysis.Tools.Logging
+{
+ internal class NullScope : IDisposable
+ {
+ public static NullScope Instance { get; } = new NullScope();
+
+ private NullScope()
+ {
+ }
+
+ public void Dispose()
+ {
+ }
+ }
+}
diff --git a/src/Logging/SimpleConsoleLogger.cs b/src/Logging/SimpleConsoleLogger.cs
index 9920bd56b0..1d483c4624 100644
--- a/src/Logging/SimpleConsoleLogger.cs
+++ b/src/Logging/SimpleConsoleLogger.cs
@@ -6,7 +6,6 @@
using System.CommandLine;
using System.CommandLine.Rendering;
using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Logging.Abstractions.Internal;
namespace Microsoft.CodeAnalysis.Tools.Logging
{
@@ -71,13 +70,13 @@ void LogToTerminal(string message, LogLevel logLevel)
{
var messageColor = _logLevelColorMap[logLevel];
_terminal.ForegroundColor = messageColor;
- _terminal.Out.WriteLine($" {message}");
+ _terminal.Out.Write($" {message}{Environment.NewLine}");
_terminal.ResetColor();
}
void LogToConsole(string message)
{
- _console.Out.WriteLine($" {message}");
+ _console.Out.Write($" {message}{Environment.NewLine}");
}
}
}
diff --git a/src/Program.cs b/src/Program.cs
index 8691130480..fac1165238 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Immutable;
using System.CommandLine;
-using System.CommandLine.Builder;
using System.CommandLine.Invocation;
using System.IO;
using System.Linq;
@@ -24,25 +23,43 @@ internal class Program
private static async Task Main(string[] args)
{
- var parser = new CommandLineBuilder(new Command("dotnet-format", handler: CommandHandler.Create(typeof(Program).GetMethod(nameof(Run)))))
- .UseParseDirective()
- .UseHelp()
- .UseDebugDirective()
- .UseSuggestDirective()
- .RegisterWithDotnetSuggest()
- .UseParseErrorReporting()
- .UseExceptionHandler()
- .AddOption(new Option(new[] { "--folder", "-f" }, Resources.The_folder_to_operate_on_Cannot_be_used_with_the_workspace_option, new Argument(() => null)))
- .AddOption(new Option(new[] { "--workspace", "-w" }, Resources.The_solution_or_project_file_to_operate_on_If_a_file_is_not_specified_the_command_will_search_the_current_directory_for_one, new Argument(() => null)))
- .AddOption(new Option(new[] { "--include", "--files" }, Resources.A_comma_separated_list_of_relative_file_or_folder_paths_to_include_in_formatting_All_files_are_formatted_if_empty, new Argument(() => null)))
- .AddOption(new Option(new[] { "--exclude" }, Resources.A_comma_separated_list_of_relative_file_or_folder_paths_to_exclude_from_formatting, new Argument(() => null)))
- .AddOption(new Option(new[] { "--check", "--dry-run" }, Resources.Formats_files_without_saving_changes_to_disk_Terminate_with_a_non_zero_exit_code_if_any_files_were_formatted, new Argument()))
- .AddOption(new Option(new[] { "--report" }, Resources.Accepts_a_file_path_which_if_provided_will_produce_a_format_report_json_file_in_the_given_directory, new Argument(() => null)))
- .AddOption(new Option(new[] { "--verbosity", "-v" }, Resources.Set_the_verbosity_level_Allowed_values_are_quiet_minimal_normal_detailed_and_diagnostic, new Argument() { Arity = ArgumentArity.ExactlyOne }.FromAmong(_verbosityLevels)))
- .UseVersionOption()
- .Build();
-
- return await parser.InvokeAsync(args).ConfigureAwait(false);
+ var rootCommand = new RootCommand
+ {
+ new Option(new[] { "--folder", "-f" }, Resources.The_folder_to_operate_on_Cannot_be_used_with_the_workspace_option)
+ {
+ Argument = new Argument(() => null)
+ },
+ new Option(new[] { "--workspace", "-w" }, Resources.The_solution_or_project_file_to_operate_on_If_a_file_is_not_specified_the_command_will_search_the_current_directory_for_one)
+ {
+ Argument = new Argument(() => null)
+ },
+ new Option(new[] { "--include", "--files" }, Resources.A_comma_separated_list_of_relative_file_or_folder_paths_to_include_in_formatting_All_files_are_formatted_if_empty)
+ {
+ Argument = new Argument(() => null)
+ },
+ new Option(new[] { "--exclude" }, Resources.A_comma_separated_list_of_relative_file_or_folder_paths_to_exclude_from_formatting)
+ {
+ Argument = new Argument(() => null)
+ },
+ new Option(new[] { "--check", "--dry-run" }, Resources.Formats_files_without_saving_changes_to_disk_Terminate_with_a_non_zero_exit_code_if_any_files_were_formatted)
+ {
+ Argument = new Argument()
+ },
+ new Option(new[] { "--report" }, Resources.Accepts_a_file_path_which_if_provided_will_produce_a_format_report_json_file_in_the_given_directory)
+ {
+ Argument = new Argument(() => null)
+ },
+ new Option(new[] { "--verbosity", "-v" }, Resources.Set_the_verbosity_level_Allowed_values_are_quiet_minimal_normal_detailed_and_diagnostic)
+ {
+ Argument = new Argument() { Arity = ArgumentArity.ExactlyOne }.FromAmong(_verbosityLevels)
+ },
+ };
+
+ rootCommand.Description = "dotnet-format";
+ rootCommand.Handler = CommandHandler.Create(typeof(Program).GetMethod(nameof(Run)));
+
+ // Parse the incoming args and invoke the handler
+ return await rootCommand.InvokeAsync(args);
}
public static async Task Run(string folder, string workspace, string verbosity, bool check, string include, string exclude, string report, IConsole console = null)
diff --git a/src/dotnet-format.csproj b/src/dotnet-format.csproj
index 134a7176db..e5f4e9c410 100644
--- a/src/dotnet-format.csproj
+++ b/src/dotnet-format.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/tests/Formatters/AbstractFormatterTests.cs b/tests/Formatters/AbstractFormatterTests.cs
index 8e80649371..0ba94d8987 100644
--- a/tests/Formatters/AbstractFormatterTests.cs
+++ b/tests/Formatters/AbstractFormatterTests.cs
@@ -8,6 +8,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Testing;
@@ -15,6 +16,7 @@
using Microsoft.CodeAnalysis.Tools.Formatters;
using Microsoft.CodeAnalysis.Tools.Tests.Utilities;
using Microsoft.CodeAnalysis.Tools.Utilities;
+using Microsoft.CodeAnalysis.VisualBasic;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.CodingConventions;
using Microsoft.VisualStudio.Composition;
@@ -24,6 +26,14 @@ namespace Microsoft.CodeAnalysis.Tools.Tests.Formatters
{
public abstract class AbstractFormatterTest
{
+ private static readonly MetadataReference CorlibReference = MetadataReference.CreateFromFile(typeof(object).Assembly.Location).WithAliases(ImmutableArray.Create("global", "corlib"));
+ private static readonly MetadataReference SystemReference = MetadataReference.CreateFromFile(typeof(System.Diagnostics.Debug).Assembly.Location).WithAliases(ImmutableArray.Create("global", "system"));
+ private static readonly MetadataReference SystemCoreReference = MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location);
+ private static readonly MetadataReference CodeAnalysisReference = MetadataReference.CreateFromFile(typeof(Compilation).Assembly.Location);
+
+ private static readonly MetadataReference SystemCollectionsImmutableReference = MetadataReference.CreateFromFile(typeof(ImmutableArray).Assembly.Location);
+ private static readonly MetadataReference MicrosoftVisualBasicReference = MetadataReference.CreateFromFile(typeof(Microsoft.VisualBasic.Strings).Assembly.Location);
+
private static readonly Lazy ExportProviderFactory;
static AbstractFormatterTest()
@@ -235,15 +245,15 @@ protected virtual Solution CreateSolution(ProjectId projectId, string language)
.CurrentSolution
.AddProject(ProjectInfo.Create(projectId, VersionStamp.Create(), DefaultTestProjectName, DefaultTestProjectName, language, filePath: DefaultTestProjectPath))
.WithProjectCompilationOptions(projectId, compilationOptions)
- .AddMetadataReference(projectId, MetadataReferences.CorlibReference)
- .AddMetadataReference(projectId, MetadataReferences.SystemReference)
- .AddMetadataReference(projectId, MetadataReferences.SystemCoreReference)
- .AddMetadataReference(projectId, MetadataReferences.CodeAnalysisReference)
- .AddMetadataReference(projectId, MetadataReferences.SystemCollectionsImmutableReference);
+ .AddMetadataReference(projectId, CorlibReference)
+ .AddMetadataReference(projectId, SystemReference)
+ .AddMetadataReference(projectId, SystemCoreReference)
+ .AddMetadataReference(projectId, CodeAnalysisReference)
+ .AddMetadataReference(projectId, SystemCollectionsImmutableReference);
if (language == LanguageNames.VisualBasic)
{
- solution = solution.AddMetadataReference(projectId, MetadataReferences.MicrosoftVisualBasicReference);
+ solution = solution.AddMetadataReference(projectId, MicrosoftVisualBasicReference);
}
foreach (var transform in OptionsTransforms)
diff --git a/tests/Utilities/TestLogger.cs b/tests/Utilities/TestLogger.cs
index 1994692591..3e01b696a7 100644
--- a/tests/Utilities/TestLogger.cs
+++ b/tests/Utilities/TestLogger.cs
@@ -2,8 +2,8 @@
using System;
using System.Text;
+using Microsoft.CodeAnalysis.Tools.Logging;
using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Logging.Abstractions.Internal;
namespace Microsoft.CodeAnalysis.Tools.Tests.Utilities
{