private static void ReportMemoryLeak(IChoDisposable target) { return; ChoGuard.ArgumentNotNull(target, "Target"); if (target.IsDisposed) { return; } ChoDisposableObjectAttribute disposableObjectAttribute = ChoType.GetAttribute <ChoDisposableObjectAttribute>(target.GetType()); if (disposableObjectAttribute == null || !disposableObjectAttribute.ContainsUnmanagedResources) { return; } AppDomain currentDomain = AppDomain.CurrentDomain; if (!currentDomain.IsFinalizingForUnload() && !Environment.HasShutdownStarted) { ChoStringMsgBuilder msg = new ChoStringMsgBuilder(target.GetType().FullName); //Console.WriteLine("Object allocated at:"); for (int index = 0; index < target.ObjectCreationStackTrace.FrameCount; ++index) { StackFrame frame = target.ObjectCreationStackTrace.GetFrame(index); msg.AppendLine(" {0}", frame.ToString()); } //ChoProfile.DefaultContext.AppendLine(msg.ToString()); } }
public static void NotDisposed(IChoDisposable obj) { ChoGuard.ArgumentNotNull(obj, "obj"); if (obj.IsDisposed) { throw new ObjectDisposedException(obj.GetType().Name); } }