Beispiel #1
0
        /// <summary>
        /// Gathers the list of files to analyze and kicks off the worker thread.
        /// </summary>
        /// <param name="full">True if a full analyze should be performed.</param>
        /// <param name="type">Type of files that should be analyzed.</param>
        internal void Analyze(bool full, AnalysisType type)
        {
            Param.Ignore(full, type);
            StyleCopTrace.In(full, type);

            // Save any documents that have been changed.
            if (this.SaveOpenDocuments())
            {
                // Get the list of projects to be analyzed.
                // Depending on the AnalysisType we:
                //// 1. analyze all the files in the solution/project/folder
                //// 2. analyze the selected file in the solution browser/code pane
                //// 3. If its a single file we may still analyze multiple files. We do this if the selected file has a dependancy on another file.
                ////    so if you analyze a designer.cs file we actually analyze the parent file and all its dependants.
                ////    This is generally because we can only be sure of issues relating to partial
                ////    types if we have all the partial types to check against.
                IList <CodeProject> projects = ProjectUtilities.GetProjectList(this.core, type, out this.analysisFilePath, this);

                this.analysisType = type;
                this.ClearEnvironmentPriorToAnalysis();

                this.SignalAnalysisStarted();

                this.violationCount = 0;

                if (projects.Count == 0)
                {
                    this.NoFilesToAnalyze();
                }
                else
                {
                    AnalysisThread analyze = new AnalysisThread(full, projects, this.core);
                    analyze.Complete += this.AnalyzeComplete;
                    System.Threading.Thread thread = new System.Threading.Thread(analyze.AnalyzeProc);

                    if (thread != null)
                    {
                        thread.IsBackground = true;

                        this.violations = new List <ViolationInfo>();

                        thread.Start();
                    }
                }
            }

            StyleCopTrace.Out();
        }
Beispiel #2
0
        /// <summary>
        /// Gathers the list of files to analyze and kicks off the worker thread.
        /// </summary>
        /// <param name="full">True if a full analyze should be performed.</param>
        /// <param name="autoFix">True if auto-fix should be performed.</param>
        /// <param name="type">Type of files that should be analyzed.</param>
        internal void Analyze(bool full, bool autoFix, AnalysisType type)
        {
            Param.Ignore(full, autoFix, type);

            // Save any documents that have been changed.
            if (this.SaveOpenDocuments())
            {
                // Get the list of projects to be analyzed.
                IList <CodeProject> projects = ProjectUtilities.GetProjectList(this.core, type);

                this.ClearEnvironmentPriorToAnalysis();

                this.SignalAnalysisStarted();

                this.violationCount = 0;

                if (projects.Count == 0)
                {
                    this.NoFilesToAnalyze();
                }
                else
                {
                    AnalysisThread analyze = new AnalysisThread(full, autoFix, projects, this.core);
                    analyze.Complete += new EventHandler(this.AnalyzeComplete);
                    System.Threading.Thread thread = new System.Threading.Thread(new ThreadStart(analyze.AnalyzeProc));

                    if (thread != null)
                    {
                        thread.IsBackground = true;

                        this.violations = new List <ViolationInfo>();

#if DEBUGTHREADING
                        analyze.AnalyzeProc();
#else
                        thread.Start();
#endif
                    }
                }
            }
        }