Пример #1
0
        /// <summary>
        /// The create.
        /// </summary>
        /// <param name="lifetime">
        /// The lifetime.
        /// </param>
        /// <param name="fileSystemTracker">
        /// The file System Tracker.
        /// </param>
        /// <returns>
        /// A new StyleCopCore object.
        /// </returns>
        public static StyleCopCore Create(Lifetime lifetime, IFileSystemTracker fileSystemTracker)
        {
            StyleCopTrace.In();

            ProjectSettingsFactory projectSettingsFactory = new ProjectSettingsFactory(lifetime, fileSystemTracker);
            SourceCodeFactory sourceCodeFactory = new SourceCodeFactory();

            ObjectBasedEnvironment environment = new ObjectBasedEnvironment(sourceCodeFactory.Create, projectSettingsFactory.Create);

            // TODO: Is there a nicer way of finding out the ReSharper install location?
            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), @"Extensions\StyleCop.StyleCop\StyleCopAddIns");
            string[] paths = { path };
            StyleCopObjectConsole styleCop = new StyleCopObjectConsole(environment, null, paths, false);

            projectSettingsFactory.StyleCopCore = styleCop.Core;

            return StyleCopTrace.Out(styleCop.Core);
        }
Пример #2
0
        /// <summary>
        /// The create.
        /// </summary>
        /// <param name="lifetime">
        /// The lifetime.
        /// </param>
        /// <param name="settingsStore">The settings store.</param>
        /// <param name="fileSystemTracker">
        /// The file System Tracker.
        /// </param>
        /// <returns>
        /// A new StyleCopCore object.
        /// </returns>
        public static StyleCopCore Create(Lifetime lifetime, ISettingsStore settingsStore, IFileSystemTracker fileSystemTracker)
        {
            StyleCopTrace.In();

            ProjectSettingsFactory projectSettingsFactory = new ProjectSettingsFactory(lifetime, fileSystemTracker);
            SourceCodeFactory      sourceCodeFactory      = new SourceCodeFactory();

            ObjectBasedEnvironment environment = new ObjectBasedEnvironment(
                sourceCodeFactory.Create,
                projectSettingsFactory.Create);

            IContextBoundSettingsStore settings = settingsStore.BindToContextTransient(ContextRange.ApplicationWide);
            bool   pluginsEnabled = settings.GetValue((StyleCopOptionsSettingsKey options) => options.PluginsEnabled);
            string pluginsPath    = settings.GetValue((StyleCopOptionsSettingsKey options) => options.PluginsPath);

            // TODO: Is there a nicer way of finding out the ReSharper install location?
            string standardPath =
                FileSystemPath.Parse(Assembly.GetCallingAssembly().Location)
                .Directory.Combine(@"Extensions\StyleCop.StyleCop\StyleCopAddins")
                .FullPath;

            var paths = new List <string> {
                standardPath
            };

            if (pluginsEnabled && !string.IsNullOrEmpty(pluginsPath))
            {
                paths.Add(pluginsPath);
            }

            StyleCopObjectConsole styleCop = new StyleCopObjectConsole(environment, null, paths, false);

            projectSettingsFactory.StyleCopCore = styleCop.Core;

            return(StyleCopTrace.Out(styleCop.Core));
        }