/// <summary> /// Performs the QuickFix, inserts the configured modifier into the location specified by the violation. /// </summary> /// <param name="solution"> /// Current Solution. /// </param> /// <param name="textControl"> /// Current Text Control to modify. /// </param> public void Execute(ISolution solution, ITextControl textControl) { JB::JetBrains.DataFlow.LifetimeDefinition definition = JB::JetBrains.DataFlow.Lifetimes.Define(solution.GetLifetime()); JB::JetBrains.DataFlow.Lifetime lifetime = definition.Lifetime; try { unsafe { ChangeInspectionSeverityDialog dialog = new ChangeInspectionSeverityDialog(lifetime, this.commonIconsComponent); IContextBoundSettingsStore contextBoundSettingsStore = this.settingsStore.BindToContextTransient(ContextRange.Smart(textControl.Document.ToDataContext())); HighlightingSettingsManager.ConfigurableSeverityItem item = this.highlightingSettingsManager.GetSeverityItem(this.HighlightID); dialog.Severity = this.highlightingSettingsManager.GetConfigurableSeverity(this.HighlightID, contextBoundSettingsStore); dialog.SeverityOptionsTitle = string.Format(item.FullTitle + ":"); dialog.CanBeError = !item.SolutionAnalysisRequired; if (dialog.ShowDialog(User32Dll.GetForegroundWindow()) == true) { IContextBoundSettingsStore store = contextBoundSettingsStore; if (dialog.SelectedSettingsLayer != null) { store = dialog.SelectedSettingsLayer.Model.SettingsStoreContext; } store.SetIndexedValue(HighlightingSettingsAccessor.InspectionSeverities, this.HighlightID, dialog.Severity); } } } finally { definition.Terminate(); } }
/// <summary> /// The initializer for this ShellComponent. /// </summary> /// <param name="lifetime"> /// The lifetime for this object. /// </param> public void Init(JB::JetBrains.DataFlow.Lifetime lifetime) { RegistryUtils registryUtils = new RegistryUtils(); object oneTimeInitializationRequiredRegistryKey = registryUtils.CUGetValue("LastInitializationDate"); DateTime initializationDate = Convert.ToDateTime(oneTimeInitializationRequiredRegistryKey); string todayAsString = DateTime.Today.ToString("yyyy-MM-dd"); string value = registryUtils.LMGetValue("InstallDate") as string; DateTime lastInstalledDate; try { lastInstalledDate = Convert.ToDateTime(value); // If the installer stored a date that has now been read back in and seems to be in the future // then use the LocalUserInstallDate value. if (lastInstalledDate > DateTime.Today) { lastInstalledDate = GetInstallDateFromLocalUserRegistry(registryUtils, todayAsString); } } catch (FormatException ex) { // In some locales the installer saves the date in a format we can't parse back out. // Use today as the installed date and store it in the HKCU key. lastInstalledDate = GetInstallDateFromLocalUserRegistry(registryUtils, todayAsString); } if (oneTimeInitializationRequiredRegistryKey == null || initializationDate < lastInstalledDate) { SettingsStore settingsStore = Shell.Instance.GetComponent <SettingsStore>(); IContextBoundSettingsStoreLive settings = settingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide); bool checkReSharperCodeStyleOptionsAtStartUp = settings.GetValue((StyleCopOptionsSettingsKey key) => key.CheckReSharperCodeStyleOptionsAtStartUp); if (checkReSharperCodeStyleOptionsAtStartUp) { if (!StyleCopOptionsPage.CodeStyleOptionsValid(settings)) { DialogResult result = MessageBox.Show( @"Your ReSharper code style settings are not completely compatible with StyleCop. Would you like to reset them now?", @"StyleCop", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { StyleCopOptionsPage.CodeStyleOptionsReset(settings); } } } } registryUtils.CUSetValue("LastInitializationDate", todayAsString); }
/// <summary> /// Initializes a new instance of the StyleCopCodeStyleChecker class. /// </summary> /// <param name="lifetime"> /// The lifetime for this instance. /// </param> public StyleCopCodeStyleChecker(JB::JetBrains.DataFlow.Lifetime lifetime) { StyleCopReferenceHelper.EnsureStyleCopIsLoaded(); this.Init(lifetime); }