예제 #1
0
        /// <summary>
        /// Copy information over from the contract struct to the native one.
        /// </summary>
        /// <returns>The native struct.</returns>
        internal static VsDebugTargetInfo4 GetDebuggerStruct4(IDebugLaunchSettings info)
        {
            var debugInfo = new VsDebugTargetInfo4
            {
                // **Begin common section -- keep this in sync with GetDebuggerStruct**
                dlo               = (uint)info.LaunchOperation,
                LaunchFlags       = (uint)info.LaunchOptions,
                bstrRemoteMachine = info.RemoteMachine,
                bstrArg           = info.Arguments,
                bstrCurDir        = info.CurrentDirectory,
                bstrExe           = info.Executable,

                bstrEnv = GetSerializedEnvironmentString(info.Environment),
                guidLaunchDebugEngine = info.LaunchDebugEngineGuid
            };

            var guids = new List <Guid>(1)
            {
                info.LaunchDebugEngineGuid
            };

            if (info.AdditionalDebugEngines != null)
            {
                guids.AddRange(info.AdditionalDebugEngines);
            }

            debugInfo.dwDebugEngineCount = (uint)guids.Count;

            byte[] guidBytes = GetGuidBytes(guids);
            debugInfo.pDebugEngines = Marshal.AllocCoTaskMem(guidBytes.Length);
            Marshal.Copy(guidBytes, 0, debugInfo.pDebugEngines, guidBytes.Length);

            debugInfo.guidPortSupplier    = info.PortSupplierGuid;
            debugInfo.bstrPortName        = info.PortName;
            debugInfo.bstrOptions         = info.Options;
            debugInfo.fSendToOutputWindow = info.SendToOutputWindow ? 1 : 0;
            debugInfo.dwProcessId         = unchecked ((uint)info.ProcessId);
            debugInfo.pUnknown            = info.Unknown;
            debugInfo.guidProcessLanguage = info.ProcessLanguageGuid;

            // **End common section**

            if (info.StandardErrorHandle != IntPtr.Zero || info.StandardInputHandle != IntPtr.Zero || info.StandardOutputHandle != IntPtr.Zero)
            {
                var processStartupInfo = new VsDebugStartupInfo
                {
                    hStdInput  = unchecked ((uint)info.StandardInputHandle.ToInt32()),
                    hStdOutput = unchecked ((uint)info.StandardOutputHandle.ToInt32()),
                    hStdError  = unchecked ((uint)info.StandardErrorHandle.ToInt32()),
                    flags      = (uint)__DSI_FLAGS.DSI_USESTDHANDLES,
                };
                debugInfo.pStartupInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(processStartupInfo));
                Marshal.StructureToPtr(processStartupInfo, debugInfo.pStartupInfo, false);
            }

            debugInfo.AppPackageLaunchInfo = info.AppPackageLaunchInfo;
            debugInfo.project = info.Project;

            return(debugInfo);
        }
예제 #2
0
        /// <summary>
        /// Clones an <see cref="IDebugLaunchSettings"/> instance so that it can be changed.
        /// </summary>
        /// <param name="value">The instance to clone.</param>
        /// <returns>The new instance.</returns>
        internal static DebugLaunchSettings Clone(this IDebugLaunchSettings value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var result = new DebugLaunchSettings(value.LaunchOptions)
            {
                Arguments             = value.Arguments,
                CurrentDirectory      = value.CurrentDirectory,
                Executable            = value.Executable,
                LaunchDebugEngineGuid = value.LaunchDebugEngineGuid,
                LaunchOperation       = value.LaunchOperation,
                Options              = value.Options,
                PortName             = value.PortName,
                RemoteMachine        = value.RemoteMachine,
                PortSupplierGuid     = value.PortSupplierGuid,
                StandardErrorHandle  = value.StandardErrorHandle,
                StandardOutputHandle = value.StandardOutputHandle,
                StandardInputHandle  = value.StandardInputHandle,
                SendToOutputWindow   = value.SendToOutputWindow,
                Unknown              = value.Unknown,
                ProcessId            = value.ProcessId,
                ProcessLanguageGuid  = value.ProcessLanguageGuid,
            };

            foreach (var engine in value.AdditionalDebugEngines)
            {
                result.AdditionalDebugEngines.Add(engine);
            }
            foreach (var env in value.Environment)
            {
                result.Environment[env.Key] = env.Value;
            }

            return(result);
        }