예제 #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="SolutionReader"/> class.
        /// </summary>
        /// <param name="pathToSln">The path to the StyleCop.Analayzers solution.</param>
        /// <param name="analyzerProjectName">The project name of the analyzer project.</param>
        /// <param name="codeFixProjectName">The project name of the code fix project.</param>
        /// <returns>A <see cref="Task{TResult}"/> representing the asynchronous operation.</returns>
        public static async Task <SolutionReader> CreateAsync(string pathToSln, string analyzerProjectName = "StyleCop.Analyzers", string codeFixProjectName = "StyleCop.Analyzers.CodeFixes")
        {
            SolutionReader reader = new SolutionReader();

            reader.SlnPath             = pathToSln;
            reader.AnalyzerProjectName = analyzerProjectName;
            reader.CodeFixProjectName  = codeFixProjectName;
            reader.workspace           = MSBuildWorkspace.Create();

            await reader.InitializeAsync().ConfigureAwait(false);

            return(reader);
        }
        /// <summary>
        /// Creates a new instance of the <see cref="SolutionReader"/> class.
        /// </summary>
        /// <param name="pathToSln">The path to the StyleCop.Analayzers sln</param>
        /// <param name="analyzerProjectName">The project name of the analyzer project</param>
        /// <param name="codeFixProjectName">The project name of the code fix project</param>
        /// <returns>A <see cref="Task{SolutionReader}"/> representing the asynchronous operation</returns>
        public static async Task<SolutionReader> CreateAsync(string pathToSln, string analyzerProjectName = "StyleCop.Analyzers", string codeFixProjectName = "StyleCop.Analyzers.CodeFixes")
        {
            SolutionReader reader = new SolutionReader();

            reader.SlnPath = pathToSln;
            reader.AnalyzerProjectName = analyzerProjectName;
            reader.CodeFixProjectName = codeFixProjectName;
            reader.workspace = MSBuildWorkspace.Create(properties: new Dictionary<string, string> { { "Configuration", "Release" } });

            await reader.InitializeAsync();

            return reader;
        }
예제 #3
0
        /// <summary>
        /// Creates a new instance of the <see cref="SolutionReader"/> class.
        /// </summary>
        /// <param name="pathToSln">The path to the StyleCop.Analayzers sln</param>
        /// <param name="analyzerProjectName">The project name of the analyzer project</param>
        /// <param name="codeFixProjectName">The project name of the code fix project</param>
        /// <returns>A <see cref="Task{SolutionReader}"/> representing the asynchronous operation</returns>
        public static async Task <SolutionReader> CreateAsync(string pathToSln, string analyzerProjectName = "StyleCop.Analyzers", string codeFixProjectName = "StyleCop.Analyzers.CodeFixes")
        {
            SolutionReader reader = new SolutionReader();

            reader.SlnPath             = pathToSln;
            reader.AnalyzerProjectName = analyzerProjectName;
            reader.CodeFixProjectName  = codeFixProjectName;
            reader.workspace           = MSBuildWorkspace.Create(properties: new Dictionary <string, string> {
                { "Configuration", "Release" }
            });

            await reader.InitializeAsync();

            return(reader);
        }
예제 #4
0
        internal static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Path to sln file required.");
                return(1);
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine($"Could not find solution file: {Path.GetFullPath(args[0])}");
                return(1);
            }

            MSBuildLocator.RegisterDefaults();
            SolutionReader reader = SolutionReader.CreateAsync(args[0]).Result;

            var diagnostics = reader.GetDiagnosticsAsync().Result;

            diagnostics = diagnostics.Sort((a, b) => a.Id.CompareTo(b.Id));

            Commit commit;
            string commitId;

            using (Repository repository = new Repository(Path.GetDirectoryName(args[0])))
            {
                commitId = repository.Head.Tip.Sha;
                commit   = repository.Head.Tip;

                var output = new
                {
                    diagnostics,
                    git = new
                    {
                        commit.Sha,
                        commit.Message,
                        commit.Author,
                        commit.Committer,
                        Parents = commit.Parents.Select(x => x.Sha),
                    },
                };

                Console.WriteLine(JsonConvert.SerializeObject(output, Formatting.Indented));
            }

            return(0);
        }
예제 #5
0
        /// <summary>
        /// The starting point of this application.
        /// </summary>
        /// <param name="args">The command line parameters.</param>
        internal static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Path to sln file required.");
                return;
            }

            SolutionReader reader = SolutionReader.CreateAsync(args[0]).Result;

            var diagnostics = reader.GetDiagnosticsAsync().Result;

            diagnostics = diagnostics.Sort((a, b) => a.Id.CompareTo(b.Id));

            Commit commit;
            string commitId;

            using (Repository repository = new Repository(Path.GetDirectoryName(args[0])))
            {
                commitId = repository.Head.Tip.Sha;
                commit   = repository.Head.Tip;

                var output = new
                {
                    diagnostics,
                    git = new
                    {
                        commit.Sha,
                        commit.Message,
                        commit.Author,
                        commit.Committer,
                        Parents = commit.Parents.Select(x => x.Sha)
                    }
                };

                Console.WriteLine(JsonConvert.SerializeObject(output));
            }
        }