コード例 #1
0
 public void Dispose()
 {
     this.styleCopConsole.ViolationEncountered -= this.OnViolationEncountered;
     this.styleCopConsole = null;
     this.environment = null;
     this.configuration = null;
     this.violations = null;
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the StyleCopObjectConsole class.
 /// </summary>
 /// <param name="environment">
 /// The environment.
 /// </param>
 /// <param name="defaultSettings">
 /// The default settings to use, or null to allow each project to specify its own settings.
 /// </param>
 /// <param name="addInPaths">
 /// The list of paths to search under for parser and analyzer addins.
 /// Can be null if no addin paths are provided.
 /// </param>
 /// <param name="loadFromDefaultPath">
 /// Indicates whether to load addins
 /// from the default application path.
 /// </param>
 public StyleCopObjectConsole(ObjectBasedEnvironment environment, Settings defaultSettings, ICollection<string> addInPaths, bool loadFromDefaultPath)
     : this(environment, defaultSettings, addInPaths, loadFromDefaultPath, null)
 {
     Param.Ignore(environment);
     Param.Ignore(defaultSettings);
     Param.Ignore(addInPaths);
     Param.Ignore(loadFromDefaultPath);
 }
コード例 #3
0
 public StyleCopRunner()
 {
     this.violations = new Dictionary<string, List<Violation>>();
     this.environment = new ObjectBasedEnvironment(this.SourceCodeFactory, this.SettingsFactory);
     this.configuration = new Configuration(new[] { "DEBUG", "TRACE" });
     this.styleCopConsole = new StyleCopObjectConsole(this.environment, null, null, true);
     this.styleCopConsole.ViolationEncountered += this.OnViolationEncountered;
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the StyleCopObjectConsole class.
 /// </summary>
 /// <param name="environment">
 /// The environment.
 /// </param>
 /// <param name="defaultSettings">
 /// The default settings to use, or null to allow each project to specify its own settings.
 /// </param>
 /// <param name="addInPaths">
 /// The list of paths to search under for parser and analyzer addins.
 /// Can be null if no addin paths are provided.
 /// </param>
 /// <param name="loadFromDefaultPath">
 /// Indicates whether to load addins
 /// from the default application path.
 /// </param>
 public StyleCopObjectConsole(ObjectBasedEnvironment environment, Settings defaultSettings, ICollection <string> addInPaths, bool loadFromDefaultPath)
     : this(environment, defaultSettings, addInPaths, loadFromDefaultPath, null)
 {
     Param.Ignore(environment);
     Param.Ignore(defaultSettings);
     Param.Ignore(addInPaths);
     Param.Ignore(loadFromDefaultPath);
 }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the StyleCopObjectConsole class.
        /// </summary>
        /// <param name="environment">
        /// The environment.
        /// </param>
        /// <param name="defaultSettings">
        /// The default settings to use, or null to allow each project to specify its own settings.
        /// </param>
        /// <param name="addInPaths">
        /// The list of paths to search under for parser and analyzer addins.
        /// Can be null if no addin paths are provided.
        /// </param>
        /// <param name="loadFromDefaultPath">
        /// Indicates whether to load addins
        /// from the default application path.
        /// </param>
        /// <param name="hostTag">
        /// An optional tag which can be set by the host.
        /// </param>
        public StyleCopObjectConsole(
            ObjectBasedEnvironment environment, Settings defaultSettings, ICollection <string> addInPaths, bool loadFromDefaultPath, object hostTag)
        {
            Param.RequireNotNull(environment, "environment");
            Param.Ignore(defaultSettings);
            Param.Ignore(addInPaths);
            Param.Ignore(loadFromDefaultPath);
            Param.Ignore(hostTag);

            this.Core = new StyleCopCore(environment, hostTag);
            this.CaptureViolations = false;
            this.Core.Initialize(addInPaths, loadFromDefaultPath);
            this.Core.WriteResultsCache = false;

            this.defaultSettings = defaultSettings;
        }
コード例 #6
0
        public void StTestObjectBasedSourceCodeWithNoSettings()
        {
            ObjectBasedEnvironment environment = new ObjectBasedEnvironment(this.SourceCodeFactory, this.ProjectSettingsFactory);

            StyleCopObjectConsole styleCop = new StyleCopObjectConsole(environment, null, new string[] { "%projectroot%\\test\\testbin" }, false);

            // Create the configuration.
            Configuration configuration = new Configuration(null);

            // Create a CodeProject.
            CodeProject project = new CodeProject(0, null, configuration);
            styleCop.Core.Environment.AddSourceCode(project, "source1.cs", 0);
            styleCop.Core.Environment.AddSourceCode(project, "source2.cs", 1);
            styleCop.Core.Environment.AddSourceCode(project, "source3.cs", 2);

            styleCop.Start(new CodeProject[] { project });
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the StyleCopObjectConsole class.
        /// </summary>
        /// <param name="environment">The environment.</param>
        /// <param name="defaultSettings">The default settings to use, or null to allow each project to specify its own settings.</param>
        /// <param name="addInPaths">The list of paths to search under for parser and analyzer addins.
        /// Can be null if no addin paths are provided.</param>
        /// <param name="loadFromDefaultPath">Indicates whether to load addins
        /// from the default application path.</param>
        /// <param name="hostTag">An optional tag which can be set by the host.</param>
        public StyleCopObjectConsole(
            ObjectBasedEnvironment environment,
            Settings defaultSettings,
            ICollection<string> addInPaths,
            bool loadFromDefaultPath,
            object hostTag)
        {
            Param.RequireNotNull(environment, "environment");
            Param.Ignore(defaultSettings);
            Param.Ignore(addInPaths);
            Param.Ignore(loadFromDefaultPath);
            Param.Ignore(hostTag);

            this.Core = new StyleCopCore(environment, hostTag);
            this.Core.Initialize(addInPaths, loadFromDefaultPath);
            this.Core.WriteResultsCache = false;
            this.InitCore();

            this.defaultSettings = defaultSettings;
        }