Example #1
0
        private static async Task <int> FormatAsync(FormatCommandLineOptions options)
        {
            if (!options.TryGetProjectFilter(out ProjectFilter projectFilter))
            {
                return(1);
            }

            string endOfLine = options.EndOfLine;

            if (endOfLine != null &&
                endOfLine != "lf" &&
                endOfLine != "crlf")
            {
                WriteLine($"Unknown end of line '{endOfLine}'.", Verbosity.Quiet);
                return(1);
            }

            var command = new FormatCommand(options, projectFilter);

            IEnumerable <string> properties = options.Properties;

            CommandResult result = await command.ExecuteAsync(options.Path, options.MSBuildPath, properties);

            return((result.Kind == CommandResultKind.Success) ? 0 : 1);
        }
Example #2
0
        private static async Task <int> FormatAsync(FormatCommandLineOptions options)
        {
            if (!options.TryGetProjectFilter(out ProjectFilter projectFilter))
            {
                return(1);
            }

            string endOfLine = options.EndOfLine;

            if (endOfLine != null &&
                endOfLine != "lf" &&
                endOfLine != "crlf")
            {
                WriteLine($"Unknown end of line '{endOfLine}'.", Verbosity.Quiet);
                return(1);
            }

            var command = new FormatCommand(options, projectFilter);

            IEnumerable <string> properties = options.Properties;

            if (options.GetSupportedDiagnostics().Any())
            {
                string ruleSetPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "format.ruleset");

                properties = properties.Concat(new string[] { $"CodeAnalysisRuleSet={ruleSetPath}" });
            }

            CommandResult result = await command.ExecuteAsync(options.Path, options.MSBuildPath, properties);

            return((result.Kind == CommandResultKind.Success) ? 0 : 1);
        }
Example #3
0
        private static async Task <int> FormatAsync(FormatCommandLineOptions options)
        {
            if (!options.TryGetProjectFilter(out ProjectFilter projectFilter))
            {
                return(ExitCodes.Error);
            }

            if (!TryParsePaths(options.Paths, out ImmutableArray <string> paths))
            {
                return(ExitCodes.Error);
            }

            if (options.EndOfLine != null)
            {
                WriteLine($"Option '--{OptionNames.EndOfLine}' is obsolete.", ConsoleColors.Yellow);
                CommandLineHelpers.WaitForKeyPress();
            }

            var command = new FormatCommand(options, projectFilter);

            IEnumerable <string> properties = options.Properties;

            CommandStatus status = await command.ExecuteAsync(paths, options.MSBuildPath, properties);

            return(GetExitCode(status));
        }
Example #4
0
        private static async Task <int> FormatAsync(FormatCommandLineOptions options)
        {
            if (!options.TryGetProjectFilter(out ProjectFilter projectFilter))
            {
                return(ExitCodes.Error);
            }

            if (!TryParsePaths(options.Paths, out ImmutableArray <string> paths))
            {
                return(ExitCodes.Error);
            }

            string endOfLine = options.EndOfLine;

            if (endOfLine != null &&
                endOfLine != "lf" &&
                endOfLine != "crlf")
            {
                WriteLine($"Unknown end of line '{endOfLine}'.", Verbosity.Quiet);
                return(ExitCodes.Error);
            }

            var command = new FormatCommand(options, projectFilter);

            IEnumerable <string> properties = options.Properties;

            CommandStatus status = await command.ExecuteAsync(paths, options.MSBuildPath, properties);

            return(GetExitCode(status));
        }