示例#1
0
        public static void Main(string[] args)
        {
            PrintGreeting();

            if (args.Length == 0)
            {
                PrintUsage();
                Environment.Exit(0);
            }

            string slnFile = Path.GetFullPath(args[0]);

            if (!File.Exists(slnFile))
            {
                Console.WriteLine("Specified parameter is expected to be an existing Visual Studio solution file.");
                Console.WriteLine("Parameter: {0}", args[0]);
                Environment.Exit(-1);
            }

            Console.WriteLine("Analyzing solution {0}", slnFile);
            Console.WriteLine();

            ISolution     solution = SolutionReader.Read(slnFile);
            List <IIssue> issues   = new List <IIssue>();

            foreach (IRule rule in RulesRepository.GetAllRules())
            {
                issues.AddRange(rule.Apply(solution));
            }

            if (issues.Count == 0)
            {
                Console.WriteLine("No issues were found.");
            }
            else
            {
                string lastFile = null;
                foreach (IIssue issue in issues.OrderBy(x => x.File))
                {
                    if (lastFile != issue.File)
                    {
                        Console.WriteLine("File: {0}", issue.File);
                        lastFile = issue.File;
                    }

                    Console.WriteLine("[{0}] {1}", issue.Code, issue.Text);
                }

                Environment.ExitCode = -1;
            }
        }
示例#2
0
        public void ReadsSolutionFileSuccessfully()
        {
            var testFile = @"TestFiles/Solutions/sampleSolution.testsln";

            var logger = new DummyLogger {
                MinimumLogLevel = LogLevel.Warning
            };

            var reader = new SolutionReader();

            reader.Read(testFile, logger);

            //Should be no warnings or errors
            Assert.IsFalse(logger.LogEntries.Any());
        }
示例#3
0
        private void buttonSolutionFile_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = "Solution files (*.sln)|*.sln";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.textSolutionFile.Text = dialog.FileName;

                if (File.Exists(this.textSolutionFile.Text))
                {
                    SolutionReader reader   = new SolutionReader();
                    var            solution = reader.Read(this.textSolutionFile.Text);
                    if (solution.FileVersion == SolutionFileVersion.VisualStudio2008)
                    {
                        this.radioVersion2008.Checked = true;
                    }
                    else if (solution.FileVersion == SolutionFileVersion.VisualStudio2010)
                    {
                        this.radioVersion2010.Checked = true;
                    }
                    else if (solution.FileVersion == SolutionFileVersion.VisualStudio2012)
                    {
                        this.radioVersion2012.Checked = true;
                    }

                    string settingsPath = Path.ChangeExtension(this.textSolutionFile.Text, SolutionOptions.FileExtension);
                    if (File.Exists(settingsPath))
                    {
                        var options = LoadSettings(settingsPath);
                        AssignOptionsToControls(options);
                        this.checkSaveSettings.Checked = true;
                    }
                }
            }

            ValidateControls();
        }