public int GetMemoryContext(out IDebugMemoryContext2 memoryContext) { ulong?maybeAddress = _varInfo.GetMemoryContextAddress(); if (maybeAddress is ulong address) { memoryContext = _taskExecutor.Run( () => _codeContextFactory .Create(address, _varInfo.DisplayName, null, Guid.Empty)); return(VSConstants.S_OK); } memoryContext = null; return(AD7Constants.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT); }
public void GetMemoryContext() { const string VAR_NAME = "test"; const ulong EXPECTED_ADDRESS = 0xdeadbeef; mockVarInfo.DisplayName.Returns(VAR_NAME); mockVarInfo.GetMemoryContextAddress().Returns <ulong?>(EXPECTED_ADDRESS); IDebugCodeContext2 mockCodeContext = Substitute.For <IDebugCodeContext2>(); mockCodeContextFactory.Create(EXPECTED_ADDRESS, VAR_NAME, null, Guid.Empty) .Returns(mockCodeContext); var debugProperty = createPropertyDelegate.Invoke(mockVarInfo); IDebugMemoryContext2 memoryContext; Assert.AreEqual(VSConstants.S_OK, debugProperty.GetMemoryContext(out memoryContext)); Assert.AreEqual(mockCodeContext, memoryContext); }