From ca47896204482bf4a6979e3838bf7f09f61cebeb Mon Sep 17 00:00:00 2001 From: giy <giy@omp-system.ru> Date: Fri, 02 Sep 2022 14:16:56 +0300 Subject: [PATCH] Обновление до версии 2.9.0 --- QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs | 46 +++++++++++++--------------------------------- 1 files changed, 13 insertions(+), 33 deletions(-) diff --git a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs index 8da6eb9..5dc4bdb 100644 --- a/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs +++ b/QtVsTools.Package/QML/Debugging/AD7/QmlDebugAD7Engine.cs @@ -78,13 +78,13 @@ FileSystem = FileSystem.Create(); } - Dictionary<Guid, Program> programs = new Dictionary<Guid, Program>(); + readonly Dictionary<Guid, Program> programs = new Dictionary<Guid, Program>(); public IEnumerable<Program> Programs { get { return ThreadSafe(() => programs.Values.ToList()); } } - HashSet<PendingBreakpoint> pendingBreakpoints = new HashSet<PendingBreakpoint>(); + readonly HashSet<PendingBreakpoint> pendingBreakpoints = new HashSet<PendingBreakpoint>(); public IEnumerable<PendingBreakpoint> PendingBreakpoints { get { return ThreadSafe(() => pendingBreakpoints.ToList()); } @@ -106,8 +106,7 @@ if (string.IsNullOrEmpty(pszOptions)) return VSConstants.E_FAIL; - uint procId; - if (!uint.TryParse(pszOptions, out procId)) + if (!uint.TryParse(pszOptions, out uint procId)) return VSConstants.E_FAIL; var env = bstrEnv.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) @@ -120,13 +119,12 @@ FileSystem.RegisterRccFile(rccFile); } - IDebugProcess2 nativeProc; var nativeProcId = new AD_PROCESS_ID { ProcessIdType = (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM, dwProcessId = procId }; - if (pPort.GetProcess(nativeProcId, out nativeProc) != VSConstants.S_OK) + if (pPort.GetProcess(nativeProcId, out IDebugProcess2 nativeProc) != VSConstants.S_OK) return VSConstants.E_FAIL; var program = Program.Create(this, nativeProc, pszExe, pszArgs); @@ -144,20 +142,11 @@ if (program == null) return VSConstants.E_FAIL; - IDebugPort2 port; - if (process.GetPort(out port) != VSConstants.S_OK) + if (process.GetPort(out IDebugPort2 port) != VSConstants.S_OK) return VSConstants.E_FAIL; - string portName; - port.GetPortName(out portName); - - Guid guidPort; - port.GetPortId(out guidPort); - IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port; - - IDebugPortNotify2 portNotify; - if (defaultPort.GetPortNotify(out portNotify) != VSConstants.S_OK) + if (defaultPort.GetPortNotify(out IDebugPortNotify2 portNotify) != VSConstants.S_OK) return VSConstants.E_FAIL; if (portNotify.AddProgramNode(program) != VSConstants.S_OK) @@ -181,8 +170,7 @@ DebugEvent.Send(new EngineCreateEvent(this)); - Guid pguidProgramId; - if (rgpPrograms[0].GetProgramId(out pguidProgramId) != VSConstants.S_OK) + if (rgpPrograms[0].GetProgramId(out Guid pguidProgramId) != VSConstants.S_OK) return VSConstants.E_FAIL; program.ProgramId = pguidProgramId; @@ -199,15 +187,10 @@ int IDebugEngineLaunch2.CanTerminateProcess(IDebugProcess2 pProcess) { - Guid procId; - if (pProcess.GetProcessId(out procId) != VSConstants.S_OK) + if (pProcess.GetProcessId(out Guid procId) != VSConstants.S_OK) return VSConstants.E_FAIL; - Program program; - if (!programs.TryGetValue(procId, out program)) - return VSConstants.S_FALSE; - - return VSConstants.S_OK; + return programs.TryGetValue(procId, out _) ? VSConstants.S_OK : VSConstants.S_FALSE; } public bool ProgramIsRunning(Program program) @@ -217,12 +200,10 @@ int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 pProcess) { - Guid procId; - if (pProcess.GetProcessId(out procId) != VSConstants.S_OK) + if (pProcess.GetProcessId(out Guid procId) != VSConstants.S_OK) return VSConstants.E_FAIL; - Program program; - if (!programs.TryGetValue(procId, out program)) + if (!programs.TryGetValue(procId, out Program program)) return VSConstants.S_FALSE; programs.Remove(procId); @@ -235,8 +216,7 @@ int IDebugEngine2.ContinueFromSynchronousEvent(IDebugEvent2 pEvent) { - var evtProgramDestroy = pEvent as ProgramDestroyEvent; - if (evtProgramDestroy != null) + if (pEvent is ProgramDestroyEvent evtProgramDestroy) evtProgramDestroy.Program.Dispose(); return VSConstants.S_OK; @@ -271,7 +251,7 @@ #region //////////////////// Concurrent /////////////////////////////////////////////////// - LocalConcurrent concurrent = new LocalConcurrent(); + readonly LocalConcurrent concurrent = new LocalConcurrent(); class LocalConcurrent : Concurrent { public void LocalThreadSafe(Action action) -- Gitblit v1.9.1