Beispiel #1
0
        public AsyncConverterConfigureAwaitPage([NotNull] Lifetime lifetime, [NotNull] OptionsSettingsSmartContext store,
                                                IPromptWinForm promptWinForms)
            : base(lifetime, store)
        {
            AddHeader("In class and method will be ignored ConfigureAwait suggestion");
            var editItemViewModelFactory = new DefaultCollectionEditItemViewModelFactory(null);
            var buttonProviderFactory    = new DefaultButtonProviderFactory(lifetime, promptWinForms, editItemViewModelFactory);
            var attributeTypes           = new StringCollectionEditViewModel(lifetime, "Attributes:",
                                                                             buttonProviderFactory, editItemViewModelFactory);

            foreach (var type in store.EnumIndexedValues(AsyncConverterSettingsAccessor.ConfigureAwaitIgnoreAttributeTypes))
            {
                attributeTypes.AddItem(type);
            }

            attributeTypes.Items.CollectionChanged += (o, e) =>
            {
                foreach (
                    var entryIndex in
                    OptionsSettingsSmartContext.EnumEntryIndices(AsyncConverterSettingsAccessor.ConfigureAwaitIgnoreAttributeTypes)
                    .ToArray())
                {
                    OptionsSettingsSmartContext.RemoveIndexedValue(AsyncConverterSettingsAccessor.ConfigureAwaitIgnoreAttributeTypes,
                                                                   entryIndex);
                }
                foreach (
                    var editItemViewModel in
                    attributeTypes.Items)
                {
                    OptionsSettingsSmartContext.SetIndexedValue(AsyncConverterSettingsAccessor.ConfigureAwaitIgnoreAttributeTypes,
                                                                editItemViewModel.PresentableName, editItemViewModel.PresentableName);
                }
            };
            AddCustomOption(attributeTypes);
        }
Beispiel #2
0
        public AsyncSuffixOptionsPage([NotNull] Lifetime lifetime, [NotNull] OptionsSettingsSmartContext store,
                                      IWindowsHookManager windowsHookManager, FormValidators formValidators, IUIApplication iuiApplication)
            : base(lifetime, store)
        {
            AddHeader("Tests");
            AddBoolOption(
                (AsyncSuffixSettings options) => options.ExcludeTestMethodsFromAnalysis,
                "Exclude test methods from analysis");
            var editItemViewModelFactory = new DefaultCollectionEditItemViewModelFactory(null);
            var buttonProviderFactory    = new DefaultButtonProviderFactory(lifetime, windowsHookManager, formValidators,
                                                                            iuiApplication, editItemViewModelFactory);
            var customAsyncTypes = new StringCollectionEditViewModel(lifetime, "Treat these types as async:",
                                                                     buttonProviderFactory, editItemViewModelFactory);

            store.EnumEntryIndices(AsyncSuffixSettingsAccessor.CustomAsyncTypes)
            .ToArray()
            .ForEach(x => customAsyncTypes.AddItem(x));
            customAsyncTypes.Items.CollectionChanged += (o, e) =>
            {
                foreach (
                    var entryIndex in
                    OptionsSettingsSmartContext.EnumEntryIndices(AsyncSuffixSettingsAccessor.CustomAsyncTypes)
                    .ToArray())
                {
                    OptionsSettingsSmartContext.RemoveIndexedValue(AsyncSuffixSettingsAccessor.CustomAsyncTypes,
                                                                   entryIndex);
                }
                foreach (
                    var editItemViewModel in
                    customAsyncTypes.Items)
                {
                    OptionsSettingsSmartContext.SetIndexedValue(AsyncSuffixSettingsAccessor.CustomAsyncTypes,
                                                                editItemViewModel.PresentableName, editItemViewModel.PresentableName);
                }
            };
            AddHeader("Custom types");
            AddCustomOption(customAsyncTypes);
        }
 public AsyncSuffixOptionsPage([NotNull] Lifetime lifetime, [NotNull] OptionsSettingsSmartContext store,
     IWindowsHookManager windowsHookManager, FormValidators formValidators, IUIApplication iuiApplication)
     : base(lifetime, store)
 {
     AddHeader("Tests");
     AddBoolOption(
         (AsyncSuffixSettings options) => options.ExcludeTestMethodsFromAnalysis,
         "Exclude test methods from analysis");
     var editItemViewModelFactory = new DefaultCollectionEditItemViewModelFactory(null);
     var buttonProviderFactory = new DefaultButtonProviderFactory(lifetime, windowsHookManager, formValidators,
         iuiApplication, editItemViewModelFactory);
     var customAsyncTypes = new StringCollectionEditViewModel(lifetime, "Treat these types as async:",
         buttonProviderFactory, editItemViewModelFactory);
     store.EnumEntryIndices(AsyncSuffixSettingsAccessor.CustomAsyncTypes)
         .ToArray()
         .ForEach(x => customAsyncTypes.AddItem(x));
     customAsyncTypes.Items.CollectionChanged += (o, e) =>
     {
         foreach (
             var entryIndex in
                 OptionsSettingsSmartContext.EnumEntryIndices(AsyncSuffixSettingsAccessor.CustomAsyncTypes)
                     .ToArray())
         {
             OptionsSettingsSmartContext.RemoveIndexedValue(AsyncSuffixSettingsAccessor.CustomAsyncTypes,
                 entryIndex);
         }
         foreach (
             var editItemViewModel in
                 customAsyncTypes.Items)
         {
             OptionsSettingsSmartContext.SetIndexedValue(AsyncSuffixSettingsAccessor.CustomAsyncTypes,
                 editItemViewModel.PresentableName, editItemViewModel.PresentableName);
         }
     };
     AddHeader("Custom types");
     AddCustomOption(customAsyncTypes);
 }
Beispiel #4
0
        public ConfigurationSenseOptionsPage(
            [NotNull] Lifetime lifetime,
            [NotNull] OptionsSettingsSmartContext optionsSettingsSmartContext,
            IComponentContainer componentContainer,
            ProjectModelElementPresentationService presentationService,
            IUIApplication iuiApplication)
            : base(lifetime, optionsSettingsSmartContext)
        {
            var solution = componentContainer.TryGetComponent <ISolution>();

            if (solution == null)
            {
                AddHeader("To edit the list of additional configuration files you should open a solution.");
                return;
            }

            var editItemViewModelFactory = new FilesAndDirsCollectionEditItemViewModelFactory(iuiApplication.ShellLocks, presentationService);
            var buttonProviderFactory    = new FilesAndDirsButtonProviderFactory(
                lifetime,
                iuiApplication.ShellLocks,
                solution,
                editItemViewModelFactory,
                false);

            var customConfigurationFiles = new StringCollectionEditViewModel(
                lifetime,
                @"Additional configuration files. 
You don't need to add appsettings.json, web.config and app.config to the list, they're scanned by default. 
Only *.json and *.xml files are supported.",
                buttonProviderFactory,
                editItemViewModelFactory);

            using (ReadLockCookie.Create())
            {
                foreach (var x in optionsSettingsSmartContext.GetAdditionalConfigurationFiles(solution.GetId()))
                {
                    var element = solution.FindElementByPersistentID(x);
                    if (element == null)
                    {
                        continue;
                    }

                    customConfigurationFiles.AddItem(element.Name, behindValue: element);
                }
            }

            customConfigurationFiles.Items.CollectionChanged += (o, e) =>
            {
                var hashSet = new HashSet <string>();
                foreach (var item in customConfigurationFiles.Items)
                {
                    var filesAndDirsItem = (FilesAndDirsItemViewModel)item;
                    if (filesAndDirsItem.ProjectElement is IProjectFile projectFile &&
                        (projectFile.LanguageType.Is <JsonProjectFileType>() ||
                         projectFile.LanguageType.Is <XmlProjectFileType>()))
                    {
                        hashSet.Add(projectFile.GetPersistentID());
                    }
                }

                OptionsSettingsSmartContext.SaveCustomConfigurationFiles(solution.GetId(), hashSet);
            };

            AddHeader("Configuration files");
            AddCustomOption(customConfigurationFiles);
        }