/// <summary> /// Retrieves the message data from the object provider /// </summary> /// <param name="objectProvider"></param> /// <returns></returns> private static Message GetMessage(IVisualizerObjectProvider objectProvider) { Stream dataStream = objectProvider.GetData(); if (dataStream.Length == 0) { return(null); } BinaryFormatter f = new BinaryFormatter(); Message message = (Message)f.Deserialize(dataStream); Log.Write($"Message content - \t {message}"); return(message); }
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { string vsVersion = VisualStudioVersionHelper.FindCurrentVisualStudioVersion(); Log.VisualStudioVersion = vsVersion; Exception exception = null; try { Message message = GetMessage(objectProvider); string linqQueryFileName = DeployLinqScript(message, vsVersion); string linqPadInstallationPath = CommonRegistryConfigurations.GetLINQPadInstallationPath(vsVersion); OpenLinqPad(linqQueryFileName, linqPadInstallationPath); string linqPadExePath = Path.Combine(linqPadInstallationPath, "LINQPad.exe"); string linqPadVersion = FileVersionInfo.GetVersionInfo(linqPadExePath).FileDescription; SendInputToLinqPad(linqPadVersion); } catch (ThreadAbortException) { // Catch exception and do nothing Thread.ResetAbort(); } catch (Exception ex) { const string context = "Error during LINQPad execution"; Log.Write(ex, context); ex.Capture(vsVersion, message: context); exception = ex; } windowService.ShowDialog(new TemporaryForm(exception)); }
/// <summary> /// Deploys the dynamically generated linq script. /// </summary> /// <param name="message">The message.</param> /// <param name="vsVersion">The visual studio version</param> internal string DeployLinqScript(Message message, string vsVersion) { try { Log.Write("Entered in DeployLinqScript"); string dstScriptPath = CommonFolderPaths.DefaultLinqPadQueryFolder; Log.Write("dstScriptPath: {0}", dstScriptPath); string targetFolder = Path.Combine(dstScriptPath, message.AssemblyName); if (!FS.FileSystem.Directory.Exists(targetFolder)) { FS.FileSystem.Directory.CreateDirectory(targetFolder); } string fileName = FindAvailableFileName(targetFolder, message.FileName); Log.Write("linqPadScriptPath: {0}", fileName); Inspection linqQuery = new Inspection(message); string linqQueryText = linqQuery.TransformText(); FS.FileSystem.File.WriteAllText(fileName, linqQueryText); Log.Write("LinqQuery Successfully deployed"); return(fileName); } catch (Exception e) { e.Capture(vsVersion, message: "Error deploying the LINQPad script"); Log.Write(e, "DynamicDebuggerVisualizer.DeployLinqScript"); throw; } }
internal static void TestShowVisualizer(Message msg) { VisualizerDevelopmentHost visualizerHost = new VisualizerDevelopmentHost(msg, typeof(DynamicDebuggerVisualizer)); visualizerHost.ShowVisualizer(); }