/// <inheritdoc/> public async Task CloseAsync(IEnumerable <string> paths) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SarifViewerInterop sarifViewerInterop = await this.GetInteropObjectAsync().ConfigureAwait(continueOnCapturedContext: true); await sarifViewerInterop.CloseSarifLogAsync(paths).ConfigureAwait(false); }
/// <inheritdoc/> public async Task ReceiveAsync(Stream logStream, string logId) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SarifViewerInterop sarifViewerInterop = await this.GetInteropObjectAsync().ConfigureAwait(continueOnCapturedContext: true); await sarifViewerInterop.OpenSarifLogAsync(logStream, logId).ConfigureAwait(continueOnCapturedContext: false); }
public GenerateTestDataCommand(IVsShell vsShell, IMenuCommandService menuCommandService) { this.viewerInterop = new SarifViewerInterop(vsShell); var menuCommand = new MenuCommand( new EventHandler(this.MenuCommandCallback), new CommandID(Guids.SariferCommandSet, SariferPackageCommandIds.GenerateTestData)); menuCommandService.AddCommand(menuCommand); }
#pragma warning restore IDE0044, CS0649 /// <inheritdoc/> public void TextViewCreated(ITextView textView) { ThreadHelper.ThrowIfNotOnUIThread(); if (this.sarifViewerInterop == null) { if (Package.GetGlobalService(typeof(SVsShell)) is IVsShell vsShell) { this.sarifViewerInterop = new SarifViewerInterop(vsShell); } if (!this.sarifViewerInterop.IsSariferExtensionLoaded) { // need to load package to get extension option setting values this.sarifViewerInterop.LoadSariferExtension(); } } if (!SariferOption.Instance.IsBackgroundAnalysisEnabled) { return; } if (!this.subscribed) { // ITextViewCreationListener is not IDisposable, so the ITextBufferManager will // never be removed from memory. This isn't a problem because the listener will // never be removed from memory either; we want it to live as long as the extension // is loaded. this.textBufferViewTracker.FirstViewAdded += this.TextBufferViewTracker_FirstViewAdded; this.textBufferViewTracker.LastViewRemoved += this.TextBufferViewTracker_LastViewRemoved; this.textBufferViewTracker.ViewUpdated += this.TextBufferViewTracker_ViewUpdated; this.subscribed = true; } textView = textView ?? throw new ArgumentNullException(nameof(textView)); string text = textView.TextBuffer.CurrentSnapshot.GetText(); string path = this.GetPathFromTextView(textView); textView.Closed += (object sender, EventArgs e) => this.TextView_Closed(textView); // TextBuffer.Changed event is a performance critical event, whose handlers directly affect typing responsiveness. // Unless it's required to handle this event synchronously on the UI thread. // As suggested listen to Microsoft.VisualStudio.Text.ITextBuffer2.ChangedOnBackground event instead. if (textView.TextBuffer is VisualStudio.Text.ITextBuffer2 oldBuffer) { oldBuffer.ChangedOnBackground += (object sender, VisualStudio.Text.TextContentChangedEventArgs e) => this.TextBuffer_ChangedOnBackground(textView); } this.textBufferViewTracker.AddTextView(textView, path, text); this.inputAssistant = new TextEditIdleAssistant(); this.inputAssistant.Idled += this.InputAssistant_Idled; }
private async System.Threading.Tasks.Task <SarifViewerInterop> GetInteropObjectAsync() { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); using (this.interopLock.EnterWriteLock()) { if (this.sarifViewerInterop == null) { var shell = Package.GetGlobalService(typeof(SVsShell)) as IVsShell; this.sarifViewerInterop = new SarifViewerInterop(shell); } } return(this.sarifViewerInterop); }