Exemple #1
0
        private static void VerifySolution(ICommandLineParameters commandLineParameters)
        {
            var solutionInfo = SolutionParser.LoadFromFile(SolutionCopConsole, commandLineParameters.PathToSolution);

            if (solutionInfo.IsParsed)
            {
                var pathToConfigFile = commandLineParameters.PathToConfigFile;
                if (string.IsNullOrEmpty(pathToConfigFile))
                {
                    pathToConfigFile = Path.Combine(Path.GetDirectoryName(commandLineParameters.PathToSolution), "SolutionCop.xml");
                    SolutionCopConsole.LogInfo("Custom path to config file is not specified, using default one: {0}", pathToConfigFile);
                }

                var reporter = CreateBuildServerReporter(commandLineParameters.ReportFormat);

                var verificationResult = new ProjectsVerifier(SolutionCopConsole, reporter).VerifyProjects(
                    pathToConfigFile,
                    solutionInfo.ProjectFilePaths.ToArray(),
                    (errors, validationResults) =>
                {
                    if (errors.Any())
                    {
                        SolutionCopConsole.LogError("***** Full list of errors: *****");
                        errors.ForEach(x => SolutionCopConsole.LogError(x));
                        reporter.SolutionVerificationFailed(string.Concat("FAILED - ", Path.GetFileName(pathToConfigFile)));
                    }
                    else
                    {
                        SolutionCopConsole.LogInfo("No errors found!");
                        reporter.SolutionVerificationPassed(string.Concat("PASSED - ", Path.GetFileName(pathToConfigFile)));
                    }
                });
                Environment.Exit(verificationResult == VerificationResult.ErrorsFound ? -1 : 0);
            }
            else
            {
                SolutionCopConsole.LogError("Cannot parse solution file.");
                Environment.Exit(-1);
            }
        }
Exemple #2
0
 private void PrintAvailableParameters(ICommandLineParameters parameters)
 {
     if (parameters.Parameters.Count() > 0) {
         System.Console.WriteLine();
         System.Console.WriteLine("arguments:");
         foreach (var param in parameters.Parameters) {
             System.Console.Write("  /" + param.Name);
             if (param.Required) {
                 System.Console.Write(" required");
             }
             if (param.HasValue) {
                 System.Console.Write(" default: " + param.DefaultValue);
             }
             System.Console.WriteLine();
         }
     }
 }
Exemple #3
0
        private void InterpretParameters(ICommandLineParameters parameters, ParsedCommandLineParameters parsedParameters, Bounce bounce)
        {
            parsedParameters.IfParameterDo("loglevel", loglevel => bounce.LogOptions.LogLevel = ParseLogLevel(loglevel));
            parsedParameters.IfParameterDo("command-output", commandOutput => bounce.LogOptions.CommandOutput = commandOutput.ToLower() == "true");
            parsedParameters.IfParameterDo("logformat", logformat => bounce.LogFactory = GetLogFactoryByName(logformat));

            parameters.ParseCommandLineArguments(parsedParameters.Parameters);
        }
Exemple #4
0
 private void InterpretParameters(ICommandLineParameters parameters, ParsedCommandLineParameters parsedParameters, Bounce bounce)
 {
     LogOptionCommandLineTranslator.ParseCommandLine(parsedParameters, bounce);
     bounce.ParametersGiven = parameters.ParseCommandLineArguments(parsedParameters.Parameters);
 }
Exemple #5
0
 private void InterpretParameters(ICommandLineParameters parameters, ParsedCommandLineParameters parsedParameters, Bounce bounce)
 {
     LogOptionCommandLineTranslator.ParseCommandLine(parsedParameters, bounce);
     bounce.ParametersGiven = parameters.ParseCommandLineArguments(parsedParameters.Parameters);
 }