Esempio n. 1
0
 public static IEnumerable <VersionInfo> EnumerateClrVersions(IProcessInfo info)
 {
     using (var session = DebugSession.Create(info))
     {
         return(session.DataTarget.ClrVersions.Select(v => v.Version));
     }
 }
Esempio n. 2
0
        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)));
        }
Esempio n. 3
0
        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);
                }
            }
        }
Esempio n. 4
0
        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));
                }
            }
        }