Exemplo n.º 1
0
        public override IEnumerable <AttachProgramOptions> Create(AttachProgramOptionsProviderContext context)
        {
            var processes = Process.GetProcessesByName("Unity");

            try {
                foreach (var p in processes)
                {
                    if (!ProcessUtils.IsValidProcess(context, p.Id, p))
                    {
                        continue;
                    }
                    context.CancellationToken.ThrowIfCancellationRequested();
                    ushort       port      = (ushort)(56000 + p.Id % 1000);
                    const string ipAddress = "127.0.0.1";
                    yield return(new UnityAttachProgramOptionsImpl(p.Id, ipAddress, port, $"Unity ({dnSpy_Debugger_DotNet_Mono_Resources.UnityEditor})"));
                }
            }
            finally {
                foreach (var p in processes)
                {
                    p.Dispose();
                }
            }
        }