public void Dispose()
 {
     this.styleCopConsole.ViolationEncountered -= this.OnViolationEncountered;
     this.styleCopConsole = null;
     this.environment = null;
     this.configuration = null;
     this.violations = null;
 }
 /// <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);
 }
 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;
 }
 /// <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);
 }
        /// <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;
        }
        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 });
        }
        /// <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;
        }