/// <summary> /// Shows the node corresponding to the active text code in Dependinator /// </summary> private async void Execute(object sender, EventArgs e) { try { await package.JoinableTaskFactory.SwitchToMainThreadAsync(); DTE2 dte = await Studio.GetDteAsync(package); Solution solution = dte.Solution; if (solution == null || string.IsNullOrEmpty(solution.FullName)) { Studio.ShowInfoMessageBox(package, "No solution has been loaded yet."); return; } int lineNumber = 0; string filePath = TryGetSelectedFilePath(dte); if (filePath == null) { filePath = TryGetActiveDocumentFilePath(dte, out lineNumber); } if (filePath == null) { Studio.ShowInfoMessageBox(package, "Open a file and set the cursor within it first."); return; } DependinatorApiClient apiClient = new DependinatorApiClient( solution.FileName, Studio.IsDeveloperMode(dte)); if (!apiClient.IsDependinatorInstalled) { if (Studio.ShowInfoMessageBox(package, "The Dependinator application is needed to visualize the solution.\n\n" + "Please install the latest release.", true)) { OpenLatestReleasePage(); } return; } await apiClient.ShowFileAsync(filePath, lineNumber); } catch (Exception exception) { Studio.ShowWarnMessageBox(package, "Really sorry, the node could not be shown.\n" + $"Error: {exception.Message}\n" + "Please report the issue at:\n" + "https://github.com/michael-reichenauer/Dependinator/issues"); Log.Error($"Failed: {exception}"); } }