public void BroadCastData(object target, Stream outgoingData) { //configure once the vs version string vsVersion = VisualStudioVersionHelper.FindCurrentVisualStudioVersion(); RavenWrapper.VisualStudioVersion = vsVersion; Log.VisualStudioVersion = vsVersion; try { Type targetType = GetInterfaceTypeIfIsIterator(target); string targetTypeFullName = TypeNameHelper.GetDisplayName(targetType, fullName: true); string targetTypeName = TypeNameHelper.GetDisplayName(targetType, fullName: false); //I'm lazy I know... Regex pattern1 = new Regex("[<]"); Regex pattern2 = new Regex("[>]"); Regex pattern3 = new Regex("[,]"); Regex pattern4 = new Regex("[`]"); Regex pattern5 = new Regex("[ ]"); string fileName = pattern1.Replace(targetTypeFullName, "("); fileName = pattern2.Replace(fileName, ")"); string typeName = pattern1.Replace(targetTypeName, string.Empty); typeName = pattern2.Replace(typeName, string.Empty); typeName = pattern3.Replace(typeName, string.Empty); typeName = pattern4.Replace(typeName, string.Empty); typeName = pattern5.Replace(typeName, string.Empty); fileName = TypeNameHelper.RemoveSystemNamespaces(fileName); Message message = new Message { FileName = string.Format(FileNameFormat, fileName), TypeName = typeName.Trim(), TypeFullName = targetTypeFullName, TypeNamespace = targetType.Namespace, AssemblyQualifiedName = targetType.AssemblyQualifiedName, AssemblyName = targetType.Assembly.GetName().Name }; BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(outgoingData, message); Log.Write("BroadCastData to LINQBridgeVsTruck"); SerializationOption serializationOption = CommonRegistryConfigurations.GetSerializationOption(vsVersion); Truck truck = new Truck("LINQBridgeVsTruck", serializationOption); truck.LoadCargo(target); bool res = truck.DeliverTo(typeName); Log.Write("Data Succesfully Shipped to Grapple"); } catch (Exception exception) { Log.Write(exception, "Error in BroadCastData"); RavenWrapper.Instance.Capture(exception, message: "Error broadcasting the data to linqpad"); throw; } }
public override void GetData(object target, Stream outgoingData) { //configure once the vs version for logging and raven string vsVersion = VisualStudioVersionHelper.FindCurrentVisualStudioVersion(); Log.VisualStudioVersion = vsVersion; try { string truckId = Guid.NewGuid().ToString(); SerializationOption?serializationOption = Truck.SendCargo(target, truckId, CRC.GetSerializationOption(vsVersion)); if (serializationOption.HasValue) { Message message = new Message(truckId, serializationOption.Value, target.GetType()); Type type = Type.GetType(message.AssemblyQualifiedName); List <string> assemblyNames = type.FindAssemblyNames(); List <string> projects = CRC.GetAssemblySolutionAndProject(assemblyNames, vsVersion); message.ReferencedAssemblies.AddRange(projects); Serialize(outgoingData, message); } else { Log.Write("Serialization option returned null"); } } catch (ThreadAbortException) { // Catch exception and do nothing Thread.ResetAbort(); } catch (Exception exception) { Log.Write(exception, "Error in BroadCastData"); exception.Capture(vsVersion, message: "Error broadcasting the data to LINQPad"); } }
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)); }