/// <summary>
 /// Initializes a new instance of the <see cref="StyleCopStage"/> class.
 /// </summary>
 /// <param name="lifetime">
 /// The <see cref="Lifetime"/> of the daemon stage. This has solution scope.
 /// </param>
 /// <param name="apiPool">
 /// A reference to the main API entry points
 /// </param>
 /// <param name="referencedAnalyzersCache">Cache of referenced analyzers</param>
 /// <param name="threading">
 /// The threading API for timed actions.
 /// </param>
 public StyleCopStage(Lifetime lifetime, StyleCopApiPool apiPool, IReferencedAnalyzersCache referencedAnalyzersCache, IThreading threading)
 {
     this.lifetime = lifetime;
     this.apiPool  = apiPool;
     this.referencedAnalyzersCache = referencedAnalyzersCache;
     this.threading = threading;
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the StyleCopStageProcess class, using the specified <see cref="IDaemonProcess"/> .
        /// </summary>
        /// <param name="lifetime">
        /// The <see cref="Lifetime"/> of the owning <see cref="IDaemonProcess"/>
        /// </param>
        /// <param name="apiPool">
        /// A reference to the StyleCop runner.
        /// </param>
        /// <param name="daemon">
        /// A reference to the <see cref="IDaemon"/> manager.
        /// </param>
        /// <param name="daemonProcess">
        /// <see cref="IDaemonProcess"/> to execute within.
        /// </param>
        /// <param name="threading">
        /// A reference to the <see cref="IThreading"/> instance for timed actions.
        /// </param>
        /// <param name="file">
        /// The file to analyze.
        /// </param>
        public StyleCopStageProcess(Lifetime lifetime, StyleCopApiPool apiPool, IDaemon daemon, IDaemonProcess daemonProcess, IThreading threading, ICSharpFile file)
        {
            StyleCopTrace.In(daemonProcess, file);

            this.lifetime      = lifetime;
            this.apiPool       = apiPool;
            this.daemon        = daemon;
            this.daemonProcess = daemonProcess;
            this.threading     = threading;
            this.file          = file;

            StyleCopTrace.Out();
        }
        /// <summary>
        /// Processes all the cleanup.
        /// </summary>
        /// <param name="projectFile">
        /// The project file to clean.
        /// </param>
        /// <param name="file">
        /// The PSI file to clean.
        /// </param>
        /// <param name="fixXmlDocViolations">
        /// Flag to indicate if XML doc stubs should be created
        /// </param>
        private void InternalProcess(IProjectFile projectFile, ICSharpFile file, bool fixXmlDocViolations)
        {
            // Process the file for all the different Code Cleanups we have here
            // we do them in a very specific order. Do not change it.
            Lifetimes.Using(
                lifetime =>
            {
                StyleCopApiPool apiPool = projectFile.GetSolution().GetComponent <StyleCopApiPool>();
                Settings settings       = apiPool.GetInstance(lifetime).Settings.GetSettings(projectFile);

                ReadabilityRules.ExecuteAll(file, settings);
                MaintainabilityRules.ExecuteAll(file, settings);

                if (fixXmlDocViolations)
                {
                    DocumentationRules.ExecuteAll(file, settings);
                }

                LayoutRules.ExecuteAll(file, settings);
                SpacingRules.ExecuteAll(file, settings);
                OrderingRules.ExecuteAll(file, settings);
            });
        }