public static IEnumerable <VersionInfo> EnumerateClrVersions(IProcessInfo info) { using (var session = DebugSession.Create(info)) { return(session.DataTarget.ClrVersions.Select(v => v.Version)); } }
private static async Task <DebugSession> CreateDebugSession(DisposableTracker tracker) { var taskTarget = tracker.Track(new HeapAnalysisTargetProcess()); var process = taskTarget.Start(); await taskTarget.WaitForTask(); return(tracker.Track(DebugSession.Create(ProcessInfo.FromProcess(process), DebugMode.Snapshot))); }
public async Task CanEnumerateLiveObjects() { using (var taskTarget = new HeapAnalysisTargetProcess()) { var process = taskTarget.Start(); await taskTarget.WaitForTask(); using (var session = DebugSession.Create(ProcessInfo.FromProcess(process), DebugMode.Snapshot)) { var runtime = session.CreateRuntime(); var liveObjects = runtime.Heap.EnumerateLiveClrObjects().Where(o => !(o is ClrPrimitive)).ToArray(); Assert.That(liveObjects, Is.Not.Empty); Assert.That(liveObjects, Is.Unique); } } }
public async Task LiveObjectsIsSubsetOfAllObjects() { using (var taskTarget = new HeapAnalysisTargetProcess()) { var process = taskTarget.Start(); await taskTarget.WaitForTask(); using (var session = DebugSession.Create(ProcessInfo.FromProcess(process), DebugMode.Snapshot)) { var runtime = session.CreateRuntime(); var allObjects = runtime.Heap.EnumerateAllClrObjects().ToArray(); var liveObjects = runtime.Heap.EnumerateLiveClrObjects().ToArray(); // Need to specify default EqualityComparer in order to use the IEquatable interface. Possible NUnit bug. Assert.That(liveObjects, Is.SubsetOf(allObjects) .Using <IClrObject>(EqualityComparer <IClrObject> .Default)); } } }