diff --git a/README.md b/README.md index dc86411f..e71684dc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Viasfora -A Visual Studio 2012 - 2017 extension that enhances the +A Visual Studio 2020 extension that enhances the text editing experience! __Official Site__: http://viasfora.com/ diff --git a/appveyor.yml b/appveyor.yml index 47904d5a..61ad0137 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ configuration: Release platform: Any CPU -image: Visual Studio 2017 +image: Visual Studio 2022 environment: EnableNuGetPackageRestore: true diff --git a/src/Viasfora.Core/Commands/TextViewCommandListener.cs b/src/Viasfora.Core/Commands/TextViewCommandListener.cs index 32ff106a..4030dae4 100644 --- a/src/Viasfora.Core/Commands/TextViewCommandListener.cs +++ b/src/Viasfora.Core/Commands/TextViewCommandListener.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio; using Microsoft.VisualStudio.Editor; using Microsoft.VisualStudio.OLE.Interop; +using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.TextManager.Interop; using Microsoft.VisualStudio.Utilities; @@ -54,6 +55,7 @@ public TextViewCommandHandler(TextViewCommandListener provider, IVsTextView view } public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { + ThreadHelper.ThrowIfNotOnUIThread(); var cmdId = (int)prgCmds[0].cmdID; var handler = this.provider.FindHandler(pguidCmdGroup, cmdId); if ( handler != null ) { @@ -87,6 +89,7 @@ public void SetOleCmdText(IntPtr pCmdText, string text) { } public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { + ThreadHelper.ThrowIfNotOnUIThread(); int hr = VSConstants.S_OK; var cmdId = (int)nCmdID; var handler = this.provider.FindHandler(pguidCmdGroup, cmdId); diff --git a/src/Viasfora.Core/Compatibility/SComponentModel.cs b/src/Viasfora.Core/Compatibility/SComponentModel.cs index 08e88cdd..15e5491e 100644 --- a/src/Viasfora.Core/Compatibility/SComponentModel.cs +++ b/src/Viasfora.Core/Compatibility/SComponentModel.cs @@ -1,9 +1,6 @@ using Microsoft.VisualStudio.Shell; using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; namespace Winterdom.Viasfora.Compatibility { @@ -15,8 +12,12 @@ public class SComponentModel { private object sComponentModel; public SComponentModel() { + ThreadHelper.ThrowIfNotOnUIThread(); this.sComponentModel = ServiceProvider.GlobalProvider.GetService(new Guid(SComponentModelHost)); + if ( this.sComponentModel == null ) { + throw new InvalidOperationException("SComponentModelHost not available"); + } } public T GetService() { diff --git a/src/Viasfora.Core/Design/UIElementDialogPage.cs b/src/Viasfora.Core/Design/UIElementDialogPage.cs deleted file mode 100644 index 831d6c22..00000000 --- a/src/Viasfora.Core/Design/UIElementDialogPage.cs +++ /dev/null @@ -1,290 +0,0 @@ -// -// Code taken from -// http://social.msdn.microsoft.com/Forums/vstudio/en-US/6af9718e-8778-4233-875d-b38c03e9f4ba/vs-plugin-unable-to-access-wpf-user-control-in-option-dialog?forum=vsx -// -using System; -using System.ComponentModel; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Forms.Integration; -using System.Windows.Input; -using System.Windows.Interop; -using System.Windows.Media; -using Microsoft.VisualStudio.Shell; - -using Forms = System.Windows.Forms; -using IWin32Window = System.Windows.Forms.IWin32Window; - -namespace Winterdom.Viasfora.Design { - /// - /// Event args used by . - /// - public class DialogKeyEventArgs : RoutedEventArgs { - internal DialogKeyEventArgs(RoutedEvent evt, Key key) - : base(evt) { - Key = key; - } - - /// - /// Gets the key being pressed within the UIElementDialogPage. - /// - public Key Key { - get; - private set; - } - } - - /// - /// Class which is used to seamlessly host WPF content inside a native dialog - /// running an IsDialogMessage-style message loop. UIElementDialogPage enables - /// tabbing into and out of the WPF child HWND, and enables keyboard navigation - /// within the WPF child HWND. - /// - //[ComVisible(true)] - public abstract class UIElementDialogPage : DialogPage { - /// - /// Routed event used to determine whether or not key input in the dialog should be handled by the dialog or by - /// the content of this page. If this event is marked as handled, the keypress should be handled by the content, - /// and DLGC_WANTALLKEYS will be returned from WM_GETDLGCODE. If the event is not handled, then only arrow keys, - /// tabbing, and character input will be handled within this dialog page. - /// - public static readonly RoutedEvent DialogKeyPendingEvent = EventManager.RegisterRoutedEvent("DialogKeyPending", RoutingStrategy.Bubble, typeof(EventHandler), typeof(UIElementDialogPage)); - - private ElementHost m_elementHost; - - static UIElementDialogPage() { - // Common controls that require centralized handling should have handlers here. - EventManager.RegisterClassHandler(typeof(ComboBox), DialogKeyPendingEvent, (EventHandler)HandleComboBoxDialogKey); - EventManager.RegisterClassHandler(typeof(DatePicker), DialogKeyPendingEvent, (EventHandler)HandleDatePickerDialogKey); - } - - /// - /// Returns the handle to the UI control hosted in the ToolsOption page. - /// - [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - protected override IWin32Window Window { - get { - if (m_elementHost == null) { - m_elementHost = new DialogPageElementHost(); - m_elementHost.Dock = Forms.DockStyle.Fill; - - UIElement child = Child; - if (child != null) { - // The child is the root of a visual tree, so it has no parent from whom to - // inherit its TextFormattingMode; set it appropriately. - // NOTE: We're setting this value on an element we didn't create; we should consider - // creating a wrapping ContentPresenter to nest the external Visual in. - TextOptions.SetTextFormattingMode(child, TextFormattingMode.Display); - - HookChildHwndSource(child); - m_elementHost.Child = child; - } - } - - return m_elementHost; - } - } - - /// - /// Gets the WPF child element to be hosted inside the dialog page. - /// - protected abstract UIElement Child { - get; - } - - /// - /// Observes for HwndSource changes on the given UIElement, - /// and adds and removes an HwndSource hook when the HwndSource - /// changes. - /// - /// The UIElement to observe. - void HookChildHwndSource(UIElement child) { - // The delegate reference is stored on the UIElement, and the lifetime - // of the child is equal to the lifetime of this UIElementDialogPage, - // so we are not leaking memory by not calling RemoveSourceChangedHandler. - PresentationSource.AddSourceChangedHandler(child, OnSourceChanged); - } - - void OnSourceChanged(object sender, SourceChangedEventArgs e) { - HwndSource oldSource = e.OldSource as HwndSource; - HwndSource newSource = e.NewSource as HwndSource; - if (oldSource != null) { - oldSource.RemoveHook(SourceHook); - } - if (newSource != null) { - newSource.AddHook(SourceHook); - } - } - - IntPtr SourceHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { - // Handle WM_GETDLGCODE in order to allow for arrow and tab navigation inside the dialog page. - // By returning this code, Windows will pass arrow and tab keys to our HWND instead of handling - // them for its own default tab and directional navigation. - switch (msg) { - case NativeMethods.WM_GETDLGCODE: - int dlgCode = NativeMethods.DLGC_WANTARROWS | NativeMethods.DLGC_WANTTAB | NativeMethods.DLGC_WANTCHARS; - - // Ask the currently-focused element if it wants to handle all keys or not. The DialogKeyPendingEvent - // is a routed event starting with the focused control. If any control in the route handles - // this message, then we'll add DLGC_WANTALLKEYS to request that this pending message - // be delivered to our content instead of the default dialog procedure. - IInputElement currentElement = Keyboard.FocusedElement; - if (currentElement != null) { - DialogKeyEventArgs args = new DialogKeyEventArgs(DialogKeyPendingEvent, KeyInterop.KeyFromVirtualKey(wParam.ToInt32())); - currentElement.RaiseEvent(args); - - if (args.Handled) { - dlgCode |= NativeMethods.DLGC_WANTALLKEYS; - } - } - - handled = true; - return new IntPtr(dlgCode); - } - - return IntPtr.Zero; - } - - private static void HandleComboBoxDialogKey(object sender, DialogKeyEventArgs e) { - // If the ComboBox is dropped down and Enter or Escape are pressed, we should - // cancel or commit the selection change rather than allowing the default button - // or cancel button to be invoked. - ComboBox comboBox = (ComboBox)sender; - if ((e.Key == Key.Enter || e.Key == Key.Escape) && comboBox.IsDropDownOpen) { - e.Handled = true; - } - } - - private static void HandleDatePickerDialogKey(object sender, DialogKeyEventArgs e) { - // If the DatePicker is dropped down and Enter or Escape are pressed, we should - // cancel or commit the selection change rather than allowing the default button - // or cancel button to be invoked. - DatePicker datePicker = (DatePicker)sender; - if ((e.Key == Key.Enter || e.Key == Key.Escape) && datePicker.IsDropDownOpen) { - e.Handled = true; - } - } - - protected void MoveFocusToNext() { - if (this.Child != null) { - this.Child.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); - } - } - - /// - /// Subclass of ElementHost designed to work around focus problems with ElementHost. - /// - class DialogPageElementHost : ElementHost { - protected override void WndProc(ref Forms.Message m) { - base.WndProc(ref m); - - if (m.Msg == NativeMethods.WM_SETFOCUS) { - IntPtr oldHandle = m.WParam; - - // Get the handle to the child WPF element that we are hosting - // After that get the next and previous items that would fall before - // and after the WPF control in the tools->options page tabbing order - HwndSource source = PresentationSource.FromVisual(Child) as HwndSource; - if (source != null && oldHandle != IntPtr.Zero) { - IntPtr nextTabElement = GetNextFocusElement(source.Handle, forward: true); - IntPtr previousTabElement = GetNextFocusElement(source.Handle, forward: false); - - UIElement rootElement = source.RootVisual as UIElement; - - // If we tabbed back from the next element then set focus to the last item - if (rootElement != null && nextTabElement == oldHandle) { - rootElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Last)); - } - - // If we tabbed in from the previous element then set focus to the first item - else if (rootElement != null && previousTabElement == oldHandle) { - rootElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); - } - } - } - } - - protected override void OnHandleCreated(EventArgs e) { - base.OnHandleCreated(e); - - // Set up an IKeyboardInputSite that understands how to tab outside the WPF content. - // (see the notes on DialogKeyboardInputSite for more detail). - // NOTE: This should be done after calling base.OnHandleCreated, which is where - // ElementHost sets up its own IKeyboardInputSite. - HwndSource source = PresentationSource.FromVisual(Child) as HwndSource; - if (source != null) { - ((IKeyboardInputSink)source).KeyboardInputSite = new DialogKeyboardInputSite(source); - } - } - - // From a given handle get the next focus element either forward or backward - internal static IntPtr GetNextFocusElement(IntPtr handle, bool forward) { - IntPtr hDlg = NativeMethods.GetAncestor(handle, NativeMethods.GA_ROOT); - if (hDlg != IntPtr.Zero) { - // Find the next dialog item in the parent dialog (searching in the correct direction) - // This can return IntPtr.Zero if there are no more items in that direction - return NativeMethods.GetNextDlgTabItem(hDlg, handle, !forward); - } - - return IntPtr.Zero; - } - } - - /// - /// The default IKeyboardInputSite that ElementHost uses relies on being hosted - /// in a pure Windows Forms window for tabbing outside the ElementHost's WPF content. - /// However, this DialogPageElementHost is hosted inside a Win32 dialog, and should - /// rely on the Win32 navigation logic directly. This replaces the default - /// IKeyboardInputSite with one that has specialized handling for OnNoMoreTabStops. - /// - class DialogKeyboardInputSite : IKeyboardInputSite { - HwndSource _source; - public DialogKeyboardInputSite(HwndSource source) { - _source = source; - } - - /// - /// Gets the IKeyboardInputSink associated with this site. - /// - public IKeyboardInputSink Sink => _source; - - public void Unregister() { - // We have nothing to unregister, so do nothing. - } - - public bool OnNoMoreTabStops(TraversalRequest request) { - // First, determine if we are tabbing forward or backwards - // outside of our content. - bool forward = true; - if (request != null) { - switch (request.FocusNavigationDirection) { - case FocusNavigationDirection.Next: - case FocusNavigationDirection.Right: - case FocusNavigationDirection.Down: - forward = true; - break; - - case FocusNavigationDirection.Previous: - case FocusNavigationDirection.Left: - case FocusNavigationDirection.Up: - forward = false; - break; - } - } - - // Based on the direction, tab forward or backwards in our parent dialog. - IntPtr nextHandle = DialogPageElementHost.GetNextFocusElement(_source.Handle, forward); - if (nextHandle != IntPtr.Zero) { - // If we were able to find another control, send focus to it and inform - // WPF that we moved focus outside the HwndSource. - NativeMethods.SetFocus(nextHandle); - return true; - } - - // If we couldn't find a dialog item to focus, inform WPF that it should - // continue cycling inside its own tab order. - return false; - } - } - } -} \ No newline at end of file diff --git a/src/Viasfora.Core/KnownFeatures.cs b/src/Viasfora.Core/KnownFeatures.cs deleted file mode 100644 index 4231452f..00000000 --- a/src/Viasfora.Core/KnownFeatures.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace Winterdom.Viasfora { - public static class KnownFeatures { - public const String TooltipApi = nameof(TooltipApi); - } -} diff --git a/src/Viasfora.Core/Margins/DevViewMargin.cs b/src/Viasfora.Core/Margins/DevViewMargin.cs index 1a4681ea..077c8dc0 100644 --- a/src/Viasfora.Core/Margins/DevViewMargin.cs +++ b/src/Viasfora.Core/Margins/DevViewMargin.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Windows; +using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Projection; using Microsoft.VisualStudio.Utilities; @@ -104,6 +105,7 @@ private void OnGraphBuffersChanged(object sender, GraphBuffersChangedEventArgs e } private void OnViewBuffer(object sender, EventArgs e) { + ThreadHelper.ThrowIfNotOnUIThread(); var buffer = GetSelectedBuffer(); if ( buffer != null ) { OpenBufferInEditor(buffer); diff --git a/src/Viasfora.Core/Outlining/UserOutliningManager.cs b/src/Viasfora.Core/Outlining/UserOutliningManager.cs index e9f03675..7652a42a 100644 --- a/src/Viasfora.Core/Outlining/UserOutliningManager.cs +++ b/src/Viasfora.Core/Outlining/UserOutliningManager.cs @@ -1,4 +1,5 @@ using System; +using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Text; using Winterdom.Viasfora.Settings; @@ -20,6 +21,7 @@ public static IOutliningManager GetManager(ITextBuffer buffer) { } protected override void OnSpanAdded(SnapshotSpan span) { + ThreadHelper.ThrowIfNotOnUIThread(); UpdateUserSettings(span.Snapshot.TextBuffer, span.Snapshot); } protected override void OnRegionRemoved(SnapshotPoint point) { diff --git a/src/Viasfora.Core/ReSharper.cs b/src/Viasfora.Core/ReSharper.cs index a577c2eb..b258a035 100644 --- a/src/Viasfora.Core/ReSharper.cs +++ b/src/Viasfora.Core/ReSharper.cs @@ -11,6 +11,7 @@ public static class ReSharper { public static bool Installed => isInstalled.Value; private static bool GetInstalled() { + ThreadHelper.ThrowIfNotOnUIThread(); IVsShell vsShell = (IVsShell) ServiceProvider.GlobalProvider.GetService(typeof(SVsShell)); if ( vsShell != null ) { diff --git a/src/Viasfora.Core/Resources/ComboBox.xaml b/src/Viasfora.Core/Resources/ComboBox.xaml index b6041969..b80dc28b 100644 --- a/src/Viasfora.Core/Resources/ComboBox.xaml +++ b/src/Viasfora.Core/Resources/ComboBox.xaml @@ -1,5 +1,5 @@  diff --git a/src/Viasfora.Core/Text/CurrentColumnAdornment.cs b/src/Viasfora.Core/Text/CurrentColumnAdornment.cs index e18039a1..e632c7b2 100644 --- a/src/Viasfora.Core/Text/CurrentColumnAdornment.cs +++ b/src/Viasfora.Core/Text/CurrentColumnAdornment.cs @@ -80,6 +80,9 @@ void OnViewClosed(object sender, EventArgs e) { } if ( this.view != null ) { this.view.Caret.PositionChanged -= OnCaretPositionChanged; + if ( this.view.Options != null ) { + this.view.Options.OptionChanged -= OnSettingsChanged; + } if ( this.view.TextViewModel?.EditBuffer != null ) { this.view.TextViewModel.EditBuffer.PostChanged -= OnBufferPostChanged; } @@ -146,7 +149,7 @@ private void CreateDrawingObjects() { fill.StrokeThickness = 0; } private void RedrawAdornments() { - if ( this.view.TextViewLines != null ) { + if ( !this.view.InLayout && this.view.TextViewLines != null ) { this.layer.RemoveAllAdornments(); var caret = this.view.Caret.Position; this.CreateVisuals(caret.VirtualBufferPosition); diff --git a/src/Viasfora.Core/Text/KeywordTagger.cs b/src/Viasfora.Core/Text/KeywordTagger.cs index 85528b3d..e8ed784a 100644 --- a/src/Viasfora.Core/Text/KeywordTagger.cs +++ b/src/Viasfora.Core/Text/KeywordTagger.cs @@ -96,7 +96,7 @@ private bool IsString(ILanguageWithStrings langStr, string name) { if ( langStr != null ) { return langStr.IsStringClassification(name); } - return name.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0; + return name.IndexOf("string", StringComparison.OrdinalIgnoreCase) >= 0; } private bool IsInterestingTag(ILanguage lang, IClassificationType classification) { diff --git a/src/Viasfora.Core/Text/KeywordTaggerProvider.cs b/src/Viasfora.Core/Text/KeywordTaggerProvider.cs index 2b87beab..1a7a6bd3 100644 --- a/src/Viasfora.Core/Text/KeywordTaggerProvider.cs +++ b/src/Viasfora.Core/Text/KeywordTaggerProvider.cs @@ -60,12 +60,23 @@ public ItalicsFormatter(ITextView textView, IClassificationFormatMap map, IVsfSe // Delay activating until after the textView // gets focus. Otherwise, VS may crash/hang this.textView.GotAggregateFocus += OnTextViewFocus; + this.textView.Closed += OnTextViewClosed; } private void OnTextViewFocus(object sender, EventArgs e) { this.textView.GotAggregateFocus -= OnTextViewFocus; FixIt(); } + + private void OnTextViewClosed(object sender, EventArgs e) { + if ( this.textView != null ) { + this.textView.Closed -= OnTextViewClosed; + this.textView.GotAggregateFocus -= OnTextViewFocus; + this.textView = null; + this.settings.SettingsChanged -= OnSettingsChanged; + this.formatMap.ClassificationFormatMappingChanged -= OnMappingChanged; + } + } public void AddClassification(String name) { this.classificationTypes.Add(name); @@ -104,7 +115,8 @@ private void FixItalics() { // To avoid this, delay resetting the working flag // until after some small time has passed. Task.Delay(500).ContinueWith( - (parentTask) => this.working = false + (parentTask) => this.working = false, + TaskScheduler.Default ); } } diff --git a/src/Viasfora.Core/Text/PresentationMode.cs b/src/Viasfora.Core/Text/PresentationMode.cs index 8ceb097a..b414dbb2 100644 --- a/src/Viasfora.Core/Text/PresentationMode.cs +++ b/src/Viasfora.Core/Text/PresentationMode.cs @@ -61,7 +61,11 @@ private void SetZoomLevel(IWpfTextView textView) { if (this.state.PresentationModeTurnedOn) { if (!pmEnabled()) { textView.ZoomLevel = zoomLevel; - textView.Set(new PresentationModeViewState(true)); + if ( textViewState != null ) { + textViewState.Enabled = true; + } else { + textView.Set(new PresentationModeViewState(true)); + } } } else { if ( pmEnabled() ) { diff --git a/src/Viasfora.Core/Text/PresentationModeFontChanger.cs b/src/Viasfora.Core/Text/PresentationModeFontChanger.cs index 107834af..60886b83 100644 --- a/src/Viasfora.Core/Text/PresentationModeFontChanger.cs +++ b/src/Viasfora.Core/Text/PresentationModeFontChanger.cs @@ -1,4 +1,5 @@ using Microsoft.VisualStudio; +using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; using System; using Winterdom.Viasfora.Contracts; @@ -44,6 +45,7 @@ private void EnsureFontsAndColors() { } private void TurnOnCategory(FontCategory category, double zoomLevel) { + ThreadHelper.ThrowIfNotOnUIThread(); EnsureFontsAndColors(); Guid categoryId = category.Id; @@ -73,6 +75,7 @@ private void TurnOnCategory(FontCategory category, double zoomLevel) { } private void TurnOffCategory(FontCategory category, bool notifyChanges) { + ThreadHelper.ThrowIfNotOnUIThread(); EnsureFontsAndColors(); Guid categoryId = category.Id; var flags = __FCSTORAGEFLAGS.FCSF_LOADDEFAULTS; diff --git a/src/Viasfora.Core/Text/PresentationModeState.cs b/src/Viasfora.Core/Text/PresentationModeState.cs index 8024a2a2..4efd0231 100644 --- a/src/Viasfora.Core/Text/PresentationModeState.cs +++ b/src/Viasfora.Core/Text/PresentationModeState.cs @@ -42,6 +42,7 @@ public void TurnOff(bool notifyChanges) { } public T GetService() { + ThreadHelper.ThrowIfNotOnUIThread(); return (T)ServiceProvider.GlobalProvider.GetService(typeof(T)); } diff --git a/src/Viasfora.Core/TextEditor.cs b/src/Viasfora.Core/TextEditor.cs index 07065009..589fae38 100644 --- a/src/Viasfora.Core/TextEditor.cs +++ b/src/Viasfora.Core/TextEditor.cs @@ -28,8 +28,12 @@ public static ITextSelection GetCurrentSelection() { return view.Selection; } public static ITextView GetCurrentView() { + ThreadHelper.ThrowIfNotOnUIThread(); var textManager = (IVsTextManager) ServiceProvider.GlobalProvider.GetService(typeof(SVsTextManager)); + if (textManager == null) { + return null; + } int hr = textManager.GetActiveView(1, null, out IVsTextView textView); if ( hr != Constants.S_OK || textView == null ) @@ -50,6 +54,7 @@ public static bool SupportsOutlines(ITextView view) { } public static String GetFileName(ITextBuffer buffer) { + ThreadHelper.ThrowIfNotOnUIThread(); if ( buffer.Properties.TryGetProperty(typeof(IVsTextBuffer), out IVsTextBuffer adapter) ) { if ( adapter is IPersistFileFormat pff ) { String filename; @@ -122,6 +127,7 @@ public static bool IsNonProjectionOrElisionBuffer(ITextBuffer buffer) { } public static void DisplayMessageInStatusBar(string message) { + ThreadHelper.ThrowIfNotOnUIThread(); IVsStatusbar bar = (IVsStatusbar) ServiceProvider.GlobalProvider.GetService(typeof(SVsStatusbar)); if ( bar != null ) { @@ -139,6 +145,7 @@ public static void OpenBufferInPlainTextEditorAsReadOnly(ITextBuffer buffer) { OpenBufferInEditorAsReadOnly(buffer, "txt"); } public static void OpenBufferInEditorAsReadOnly(ITextBuffer buffer, String extension) { + ThreadHelper.ThrowIfNotOnUIThread(); String filepath = SaveBufferToTempPath(buffer, extension); var uiShell = (IVsUIShellOpenDocument) @@ -171,9 +178,13 @@ private static void MarkDocumentInFrameAsReadOnly(IVsWindowFrame frame) { } private static void MarkDocumentAsTemporary(string moniker) { + ThreadHelper.ThrowIfNotOnUIThread(); IVsRunningDocumentTable docTable = (IVsRunningDocumentTable) ServiceProvider.GlobalProvider.GetService(typeof(SVsRunningDocumentTable)); + if ( docTable == null ) { + return; + } uint lockType = (uint)_VSRDTFLAGS.RDT_DontAddToMRU | (uint)_VSRDTFLAGS.RDT_NonCreatable | (uint)_VSRDTFLAGS.RDT_VirtualDocument diff --git a/src/Viasfora.Core/Util/VsActivityLogger.cs b/src/Viasfora.Core/Util/VsActivityLogger.cs index 938787a5..3f9dff96 100644 --- a/src/Viasfora.Core/Util/VsActivityLogger.cs +++ b/src/Viasfora.Core/Util/VsActivityLogger.cs @@ -1,11 +1,7 @@ using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; using System; -using System.Collections.Generic; using System.ComponentModel.Composition; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Winterdom.Viasfora.Contracts; namespace Winterdom.Viasfora.Util { @@ -16,11 +12,13 @@ public class VsActivityLogger : ILogger { [ImportingConstructor] public VsActivityLogger(SVsServiceProvider serviceProvider, IVsfTelemetry telemetry) { + ThreadHelper.ThrowIfNotOnUIThread(); this.telemetry = telemetry; this.activityLog = serviceProvider.GetService(typeof(SVsActivityLog)) as IVsActivityLog; } public void LogError(string message, Exception ex) { + ThreadHelper.ThrowIfNotOnUIThread(); var log = this.activityLog; if ( log != null ) { log.LogEntry( @@ -33,6 +31,7 @@ public void LogError(string message, Exception ex) { } public void LogInfo(string format, params object[] args) { + ThreadHelper.ThrowIfNotOnUIThread(); var log = this.activityLog; if ( log != null ) { log.LogEntry( diff --git a/src/Viasfora.Core/Util/VsColors.cs b/src/Viasfora.Core/Util/VsColors.cs index e30693c4..956b5869 100644 --- a/src/Viasfora.Core/Util/VsColors.cs +++ b/src/Viasfora.Core/Util/VsColors.cs @@ -94,9 +94,9 @@ static VsColors() { // these don't really seem to have a match in VS2010... // so just watch it! - ToolTipBrushKey = Get("ToolTipBorderBrushKey", SystemColors.ControlLightBrushKey); - ToolTipTextBrushKey = Get("ToolTipTextBrushKey", SystemColors.InfoTextBrushKey); - PanelHyperlinkBrushKey = Get("PanelHyperlinkBrushKey", SystemColors.HotTrackBrushKey); + ToolTipBrushKey = Get("ToolTipBorderBrushKey", VsBrushes.ScreenTipBorderKey); + ToolTipTextBrushKey = Get("ToolTipTextBrushKey", VsBrushes.PanelTextKey); + PanelHyperlinkBrushKey = Get("PanelHyperlinkBrushKey", VsBrushes.PanelHyperlinkKey); } diff --git a/src/Viasfora.Core/Util/VsFeatures.cs b/src/Viasfora.Core/Util/VsFeatures.cs deleted file mode 100644 index 238c4520..00000000 --- a/src/Viasfora.Core/Util/VsFeatures.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.VisualStudio.Language.Intellisense; -using System; -using System.ComponentModel.Composition; -using Winterdom.Viasfora.Contracts; - -namespace Winterdom.Viasfora.Util { - [Export(typeof(IVsFeatures))] - public class VsFeatures : IVsFeatures { - public bool IsSupported(string featureName) { - switch ( featureName ) { - case KnownFeatures.TooltipApi: - return IsQuickInfoSourceDeprecated(); - } - throw new InvalidOperationException("Unknown feature: " + featureName); - } - - private bool IsQuickInfoSourceDeprecated() { - return typeof(IQuickInfoSource) - .GetCustomAttributes(typeof(ObsoleteAttribute), false) - .Length > 0; - } - } -} diff --git a/src/Viasfora.Core/Viasfora.Core.csproj b/src/Viasfora.Core/Viasfora.Core.csproj index 61f1bc70..331604df 100644 --- a/src/Viasfora.Core/Viasfora.Core.csproj +++ b/src/Viasfora.Core/Viasfora.Core.csproj @@ -1,5 +1,5 @@  - + @@ -10,28 +10,14 @@ Properties Winterdom.Viasfora Viasfora.Core - v4.5 + v4.7.2 512 true false - - - 11.0 - - - - 12.0 - - - 14.0 - - - 15.0 - - - 16.0 + + 17.0 false @@ -40,96 +26,6 @@ false - - False - ..\..\packages\VSSDK.DTE.7.0.4\lib\net20\envdte.dll - True - - - ..\..\packages\VSSDK.CoreUtility.10.0.4\lib\net40\Microsoft.VisualStudio.CoreUtility.dll - False - - - ..\..\packages\VSSDK.Editor.10.0.4\lib\net40\Microsoft.VisualStudio.Editor.dll - False - - - ..\..\packages\VSSDK.Language.10.0.4\lib\net40\Microsoft.VisualStudio.Language.Intellisense.dll - False - - - ..\..\packages\VSSDK.Language.10.0.4\lib\net40\Microsoft.VisualStudio.Language.StandardClassification.dll - False - - - ..\..\packages\VSSDK.OLE.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.OLE.Interop.dll - True - False - - - ..\..\packages\VSSDK.Shell.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.10.0.dll - False - - - ..\..\packages\VSSDK.Shell.Immutable.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll - True - False - - - ..\..\packages\VSSDK.Shell.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.dll - True - False - - - False - ..\..\packages\VSSDK.Shell.Interop.10.10.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.10.0.dll - True - - - ..\..\packages\VSSDK.Shell.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.8.0.dll - True - False - - - ..\..\packages\VSSDK.Shell.Interop.9.9.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.9.0.dll - True - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Data.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Logic.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.Wpf.dll - False - - - ..\..\packages\VSSDK.TextManager.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.dll - True - False - - - ..\..\packages\VSSDK.TextManager.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.8.0.dll - True - False - - - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - True - - - False - ..\..\packages\VSSDK.DTE.7.0.4\lib\net20\stdole.dll - True - @@ -169,7 +65,6 @@ - UserControl @@ -188,7 +83,6 @@ - @@ -245,7 +139,6 @@ - @@ -279,7 +172,6 @@ - @@ -303,6 +195,14 @@ Viasfora.Languages + + + 13.0.1 + + + 17.1.32210.191 + + - - 11.0 - - - - 12.0 - - - 14.0 - - - 15.0 - - - 16.0 + + 17.0 - - False - ..\..\packages\VSSDK.DTE.7.0.4\lib\net20\envdte.dll - True - - - ..\..\packages\VSSDK.CoreUtility.10.0.4\lib\net40\Microsoft.VisualStudio.CoreUtility.dll - False - - - ..\..\packages\VSSDK.Editor.10.0.4\lib\net40\Microsoft.VisualStudio.Editor.dll - False - - - ..\..\packages\VSSDK.Language.10.0.4\lib\net40\Microsoft.VisualStudio.Language.Intellisense.dll - False - - - ..\..\packages\VSSDK.Language.10.0.4\lib\net40\Microsoft.VisualStudio.Language.StandardClassification.dll - False - - - ..\..\packages\VSSDK.OLE.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.OLE.Interop.dll - True - False - - - ..\..\packages\VSSDK.Shell.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.10.0.dll - False - - - ..\..\packages\VSSDK.Shell.Immutable.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll - True - False - - - ..\..\packages\VSSDK.Shell.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.dll - True - False - - - False - ..\..\packages\VSSDK.Shell.Interop.10.10.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.10.0.dll - True - - - ..\..\packages\VSSDK.Shell.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.8.0.dll - True - False - - - ..\..\packages\VSSDK.Shell.Interop.9.9.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.9.0.dll - True - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Data.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Logic.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.Wpf.dll - False - - - ..\..\packages\VSSDK.TextManager.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.dll - True - False - - - ..\..\packages\VSSDK.TextManager.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.8.0.dll - True - False - - - False - ..\..\packages\VSSDK.DTE.7.0.4\lib\net20\stdole.dll - True - @@ -197,6 +98,14 @@ Designer + + + 13.0.1 + + + 17.1.32210.191 + + diff --git a/src/Viasfora.Rainbow/packages.config b/src/Viasfora.Rainbow/packages.config index 99ab4ec0..6b8deb9c 100644 --- a/src/Viasfora.Rainbow/packages.config +++ b/src/Viasfora.Rainbow/packages.config @@ -1,21 +1,3 @@  - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Viasfora.Settings/Viasfora.Settings.csproj b/src/Viasfora.Settings/Viasfora.Settings.csproj index a5dbd25f..9222ff12 100644 --- a/src/Viasfora.Settings/Viasfora.Settings.csproj +++ b/src/Viasfora.Settings/Viasfora.Settings.csproj @@ -10,8 +10,9 @@ Properties Viasfora.Settings Viasfora.Settings - v4.5 + v4.7.2 512 + false @@ -24,13 +25,14 @@ - - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - True - + + + 13.0.1 + + @@ -55,8 +57,5 @@ - - - \ No newline at end of file diff --git a/src/Viasfora.Settings/packages.config b/src/Viasfora.Settings/packages.config deleted file mode 100644 index 747efc53..00000000 --- a/src/Viasfora.Settings/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/Viasfora.Xml/Viasfora.Xml.csproj b/src/Viasfora.Xml/Viasfora.Xml.csproj index 6caa31c2..4eb849c3 100644 --- a/src/Viasfora.Xml/Viasfora.Xml.csproj +++ b/src/Viasfora.Xml/Viasfora.Xml.csproj @@ -1,5 +1,5 @@  - + @@ -10,28 +10,14 @@ Properties Winterdom.Viasfora.Xml Viasfora.Xml - v4.5 + v4.7.2 512 true false - - - 11.0 - - - - 12.0 - - - 14.0 - - - 15.0 - - - 16.0 + + 17.0 false @@ -40,94 +26,8 @@ false - - False - ..\..\packages\VSSDK.DTE.7.0.4\lib\net20\envdte.dll - True - - - ..\..\packages\VSSDK.CoreUtility.10.0.4\lib\net40\Microsoft.VisualStudio.CoreUtility.dll - False - - - ..\..\packages\VSSDK.Editor.10.0.4\lib\net40\Microsoft.VisualStudio.Editor.dll - False - - - ..\..\packages\VSSDK.Language.10.0.4\lib\net40\Microsoft.VisualStudio.Language.Intellisense.dll - False - - - ..\..\packages\VSSDK.Language.10.0.4\lib\net40\Microsoft.VisualStudio.Language.StandardClassification.dll - False - - - ..\..\packages\VSSDK.OLE.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.OLE.Interop.dll - True - False - - - ..\..\packages\VSSDK.Shell.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.10.0.dll - False - - - ..\..\packages\VSSDK.Shell.Immutable.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll - True - False - - - ..\..\packages\VSSDK.Shell.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.dll - True - False - - - False - ..\..\packages\VSSDK.Shell.Interop.10.10.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.10.0.dll - True - - - ..\..\packages\VSSDK.Shell.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.8.0.dll - True - False - - - ..\..\packages\VSSDK.Shell.Interop.9.9.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.9.0.dll - True - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Data.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Logic.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.Wpf.dll - False - - - ..\..\packages\VSSDK.TextManager.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.dll - True - False - - - ..\..\packages\VSSDK.TextManager.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.8.0.dll - True - False - - - False - ..\..\packages\VSSDK.DTE.7.0.4\lib\net20\stdole.dll - True - @@ -143,6 +43,11 @@ + + + 17.1.32210.191 + + Properties\AssemblyInfo.Common.cs @@ -181,9 +86,6 @@ Viasfora.Core - - - - - 11.0 - - - - 12.0 - - - 14.0 - - - 15.0 - - - 16.0 + + 17.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) false @@ -173,125 +160,14 @@ - Designer - - False - ..\..\packages\VSSDK.DTE.7.0.4\lib\net20\envdte.dll - True - - - False - ..\..\packages\VSSDK.DTE.10.10.0.4\lib\net20\envdte100.dll - True - - - False - ..\..\packages\VSSDK.DTE.8.8.0.4\lib\net20\envdte80.dll - True - - - False - ..\..\packages\VSSDK.DTE.9.9.0.4\lib\net20\envdte90.dll - True - - - False - ..\..\packages\VSSDK.DTE.9.9.0.4\lib\net20\envdte90a.dll - True - - - ..\..\packages\VSSDK.CoreUtility.10.0.4\lib\net40\Microsoft.VisualStudio.CoreUtility.dll - False - - - ..\..\packages\VSSDK.Editor.10.0.4\lib\net40\Microsoft.VisualStudio.Editor.dll - False - - - ..\..\packages\VSSDK.Language.10.0.4\lib\net40\Microsoft.VisualStudio.Language.Intellisense.dll - False - - - ..\..\packages\VSSDK.Language.10.0.4\lib\net40\Microsoft.VisualStudio.Language.StandardClassification.dll - False - - - ..\..\packages\VSSDK.OLE.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.OLE.Interop.dll - True - False - - - ..\..\packages\VSSDK.Shell.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.10.0.dll - False - - - ..\..\packages\VSSDK.Shell.Immutable.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll - True - False - - - ..\..\packages\VSSDK.Shell.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.dll - True - False - - - False - ..\..\packages\VSSDK.Shell.Interop.10.10.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.10.0.dll - True - - - ..\..\packages\VSSDK.Shell.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.8.0.dll - True - False - - - ..\..\packages\VSSDK.Shell.Interop.9.9.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.9.0.dll - True - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Data.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Logic.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.dll - False - - - ..\..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.Wpf.dll - False - - - ..\..\packages\VSSDK.TextManager.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.dll - True - False - - - ..\..\packages\VSSDK.TextManager.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.8.0.dll - True - False - - - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - True - - - False - ..\..\packages\VSSDK.DTE.7.0.4\lib\net20\stdole.dll - True - @@ -383,16 +259,19 @@ DebugSymbolsProjectOutputGroup%3b + + + 13.0.1 + + + 17.1.32210.191 + + + 17.0.5232 + + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - +