--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+internal partial class Interop
+{
+ internal partial class Advapi32
+ {
+ [DllImport(Libraries.Advapi32, ExactSpelling = true, SetLastError = true)]
+ internal static extern int RegNotifyChangeKeyValue(SafeRegistryHandle hKey, bool bWatchSubtree, uint dwNotifyFilter, SafeWaitHandle hEvent, bool fAsynchronous);
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+internal partial class Interop
+{
+ internal partial class Advapi32
+ {
+ [DllImport(Libraries.Advapi32, CharSet = CharSet.Auto, BestFitMapping = false, SetLastError = true)]
+ internal static extern int RegOpenKeyEx(IntPtr hKey, string lpSubKey, int ulOptions, int samDesired, out SafeRegistryHandle phkResult);
+ }
+}
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>System.Runtime.Caching</AssemblyName>
<ProjectGuid>{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}</ProjectGuid>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<Compile Include="System\Runtime\Caching\MemoryMonitor.Windows.cs" />
<Compile Include="System\Runtime\Caching\PhysicalMemoryMonitor.Windows.cs" />
+ <Compile Include="$(CommonPath)\Interop\Windows\Advapi32\Interop.RegNotifyChangeKeyValue.cs">
+ <Link>Common\Interop\Windows\Advapi32\Interop.RegNotifyChangeKeyValue.cs</Link>
+ </Compile>
+ <Compile Include="$(CommonPath)\Interop\Windows\Advapi32\Interop.RegOpenKeyEx.cs">
+ <Link>Common\Interop\Windows\Advapi32\Interop.RegOpenKeyEx.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Kernel32\Interop.GlobalMemoryStatusEx.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.GlobalMemoryStatusEx.cs</Link>
</Compile>
using System;
using System.Collections;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
internal ExpiresEntryRef(int pageIndex, int entryIndex)
{
- Dbg.Assert((pageIndex & 0x00ffffff) == pageIndex, "(pageIndex & 0x00ffffff) == pageIndex");
- Dbg.Assert((entryIndex & ENTRY_MASK) == entryIndex, "(entryIndex & ENTRY_MASK) == entryIndex");
- Dbg.Assert(entryIndex != 0 || pageIndex == 0, "entryIndex != 0 || pageIndex == 0");
+ Debug.Assert((pageIndex & 0x00ffffff) == pageIndex, "(pageIndex & 0x00ffffff) == pageIndex");
+ Debug.Assert((entryIndex & ENTRY_MASK) == entryIndex, "(entryIndex & ENTRY_MASK) == entryIndex");
+ Debug.Assert(entryIndex != 0 || pageIndex == 0, "entryIndex != 0 || pageIndex == 0");
_ref = ((((uint)pageIndex) << PAGE_SHIFT) | (((uint)(entryIndex)) & ENTRY_MASK));
}
private void InitZeroPages()
{
- Dbg.Assert(_cPagesInUse == 0, "_cPagesInUse == 0");
- Dbg.Assert(_cEntriesInUse == 0, "_cEntriesInUse == 0");
- Dbg.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
+ Debug.Assert(_cPagesInUse == 0, "_cPagesInUse == 0");
+ Debug.Assert(_cEntriesInUse == 0, "_cEntriesInUse == 0");
+ Debug.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
_pages = null;
_minEntriesInUse = -1;
private void AddToListHead(int pageIndex, ref ExpiresPageList list)
{
- Dbg.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
+ Debug.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
(_pages[(pageIndex)]._pagePrev) = -1;
(_pages[(pageIndex)]._pageNext) = list._head;
if (list._head != -1)
{
- Dbg.Assert((_pages[(list._head)]._pagePrev) == -1, "PagePrev(list._head) == -1");
+ Debug.Assert((_pages[(list._head)]._pagePrev) == -1, "PagePrev(list._head) == -1");
(_pages[(list._head)]._pagePrev) = pageIndex;
}
else
private void AddToListTail(int pageIndex, ref ExpiresPageList list)
{
- Dbg.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
+ Debug.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
(_pages[(pageIndex)]._pageNext) = -1;
(_pages[(pageIndex)]._pagePrev) = list._tail;
if (list._tail != -1)
{
- Dbg.Assert((_pages[(list._tail)]._pageNext) == -1, "PageNext(list._tail) == -1");
+ Debug.Assert((_pages[(list._tail)]._pageNext) == -1, "PageNext(list._tail) == -1");
(_pages[(list._tail)]._pageNext) = pageIndex;
}
else
private int RemoveFromListHead(ref ExpiresPageList list)
{
- Dbg.Assert(list._head != -1, "list._head != -1");
+ Debug.Assert(list._head != -1, "list._head != -1");
int oldHead = list._head;
RemoveFromList(oldHead, ref list);
private void RemoveFromList(int pageIndex, ref ExpiresPageList list)
{
- Dbg.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
+ Debug.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
if ((_pages[(pageIndex)]._pagePrev) != -1)
{
- Dbg.Assert((_pages[((_pages[(pageIndex)]._pagePrev))]._pageNext) == pageIndex, "PageNext(PagePrev(pageIndex)) == pageIndex");
+ Debug.Assert((_pages[((_pages[(pageIndex)]._pagePrev))]._pageNext) == pageIndex, "PageNext(PagePrev(pageIndex)) == pageIndex");
(_pages[((_pages[(pageIndex)]._pagePrev))]._pageNext) = (_pages[(pageIndex)]._pageNext);
}
else
{
- Dbg.Assert(list._head == pageIndex, "list._head == pageIndex");
+ Debug.Assert(list._head == pageIndex, "list._head == pageIndex");
list._head = (_pages[(pageIndex)]._pageNext);
}
if ((_pages[(pageIndex)]._pageNext) != -1)
{
- Dbg.Assert((_pages[((_pages[(pageIndex)]._pageNext))]._pagePrev) == pageIndex, "PagePrev(PageNext(pageIndex)) == pageIndex");
+ Debug.Assert((_pages[((_pages[(pageIndex)]._pageNext))]._pagePrev) == pageIndex, "PagePrev(PageNext(pageIndex)) == pageIndex");
(_pages[((_pages[(pageIndex)]._pageNext))]._pagePrev) = (_pages[(pageIndex)]._pagePrev);
}
else
{
- Dbg.Assert(list._tail == pageIndex, "list._tail == pageIndex");
+ Debug.Assert(list._tail == pageIndex, "list._tail == pageIndex");
list._tail = (_pages[(pageIndex)]._pagePrev);
}
private void MoveToListHead(int pageIndex, ref ExpiresPageList list)
{
- Dbg.Assert(list._head != -1, "list._head != -1");
- Dbg.Assert(list._tail != -1, "list._tail != -1");
+ Debug.Assert(list._head != -1, "list._head != -1");
+ Debug.Assert(list._tail != -1, "list._tail != -1");
if (list._head == pageIndex)
return;
private void MoveToListTail(int pageIndex, ref ExpiresPageList list)
{
- Dbg.Assert(list._head != -1, "list._head != -1");
- Dbg.Assert(list._tail != -1, "list._tail != -1");
+ Debug.Assert(list._head != -1, "list._head != -1");
+ Debug.Assert(list._tail != -1, "list._tail != -1");
if (list._tail == pageIndex)
{
else
{
int capacity = _cPagesInUse * NUM_ENTRIES;
- Dbg.Assert(capacity > 0, "capacity > 0");
- Dbg.Assert(MIN_LOAD_FACTOR < 1.0, "MIN_LOAD_FACTOR < 1.0");
+ Debug.Assert(capacity > 0, "capacity > 0");
+ Debug.Assert(MIN_LOAD_FACTOR < 1.0, "MIN_LOAD_FACTOR < 1.0");
_minEntriesInUse = (int)(capacity * MIN_LOAD_FACTOR);
private void RemovePage(int pageIndex)
{
- Dbg.Assert((((_pages[(pageIndex)]._entries))[0]._cFree) == NUM_ENTRIES, "FreeEntryCount(EntriesI(pageIndex)) == NUM_ENTRIES");
+ Debug.Assert((((_pages[(pageIndex)]._entries))[0]._cFree) == NUM_ENTRIES, "FreeEntryCount(EntriesI(pageIndex)) == NUM_ENTRIES");
RemoveFromList(pageIndex, ref _freeEntryList);
AddToListHead(pageIndex, ref _freePageList);
- Dbg.Assert((_pages[(pageIndex)]._entries) != null, "EntriesI(pageIndex) != null");
+ Debug.Assert((_pages[(pageIndex)]._entries) != null, "EntriesI(pageIndex) != null");
(_pages[(pageIndex)]._entries) = null;
_cPagesInUse--;
private ExpiresEntryRef GetFreeExpiresEntry()
{
- Dbg.Assert(_freeEntryList._head >= 0, "_freeEntryList._head >= 0");
+ Debug.Assert(_freeEntryList._head >= 0, "_freeEntryList._head >= 0");
int pageIndex = _freeEntryList._head;
ExpiresEntry[] entries = (_pages[(pageIndex)]._entries);
((entries)[0]._cFree)--;
if (((entries)[0]._cFree) == 0)
{
- Dbg.Assert(((entries)[0]._next).IsInvalid, "FreeEntryHead(entries).IsInvalid");
+ Debug.Assert(((entries)[0]._next).IsInvalid, "FreeEntryHead(entries).IsInvalid");
RemoveFromList(pageIndex, ref _freeEntryList);
}
return new ExpiresEntryRef(pageIndex, entryIndex);
ExpiresEntry[] entries = (_pages[(entryRef.PageIndex)]._entries);
int entryIndex = entryRef.Index;
- Dbg.Assert(entries[entryIndex]._cacheEntry == null, "entries[entryIndex]._cacheEntry == null");
+ Debug.Assert(entries[entryIndex]._cacheEntry == null, "entries[entryIndex]._cacheEntry == null");
entries[entryIndex]._cFree = 0;
entries[entryIndex]._next = ((entries)[0]._next);
private void Expand()
{
- Dbg.Assert(_cPagesInUse * NUM_ENTRIES == _cEntriesInUse, "_cPagesInUse * NUM_ENTRIES == _cEntriesInUse");
- Dbg.Assert(_freeEntryList._head == -1, "_freeEntryList._head == -1");
- Dbg.Assert(_freeEntryList._tail == -1, "_freeEntryList._tail == -1");
+ Debug.Assert(_cPagesInUse * NUM_ENTRIES == _cEntriesInUse, "_cPagesInUse * NUM_ENTRIES == _cEntriesInUse");
+ Debug.Assert(_freeEntryList._head == -1, "_freeEntryList._head == -1");
+ Debug.Assert(_freeEntryList._tail == -1, "_freeEntryList._tail == -1");
if (_freePageList._head == -1)
{
oldLength = _pages.Length;
}
- Dbg.Assert(_cPagesInUse == oldLength, "_cPagesInUse == oldLength");
- Dbg.Assert(_cEntriesInUse == oldLength * NUM_ENTRIES, "_cEntriesInUse == oldLength * ExpiresEntryRef.NUM_ENTRIES");
+ Debug.Assert(_cPagesInUse == oldLength, "_cPagesInUse == oldLength");
+ Debug.Assert(_cEntriesInUse == oldLength * NUM_ENTRIES, "_cEntriesInUse == oldLength * ExpiresEntryRef.NUM_ENTRIES");
int newLength = oldLength * 2;
newLength = Math.Max(oldLength + MIN_PAGES_INCREMENT, newLength);
newLength = Math.Min(newLength, oldLength + MAX_PAGES_INCREMENT);
- Dbg.Assert(newLength > oldLength, "newLength > oldLength");
+ Debug.Assert(newLength > oldLength, "newLength > oldLength");
ExpiresPage[] newPages = new ExpiresPage[newLength];
if (_cEntriesInUse >= _minEntriesInUse || _blockReduce)
return;
- Dbg.Assert(_freeEntryList._head != -1, "_freeEntryList._head != -1");
- Dbg.Assert(_freeEntryList._tail != -1, "_freeEntryList._tail != -1");
- Dbg.Assert(_freeEntryList._head != _freeEntryList._tail, "_freeEntryList._head != _freeEntryList._tail");
+ Debug.Assert(_freeEntryList._head != -1, "_freeEntryList._head != -1");
+ Debug.Assert(_freeEntryList._tail != -1, "_freeEntryList._tail != -1");
+ Debug.Assert(_freeEntryList._head != _freeEntryList._tail, "_freeEntryList._head != _freeEntryList._tail");
int meanFree = (int)(NUM_ENTRIES - (NUM_ENTRIES * MIN_LOAD_FACTOR));
int pageIndexLast = _freeEntryList._tail;
break;
entries = (_pages[(_freeEntryList._tail)]._entries);
- Dbg.Assert(((entries)[0]._cFree) > 0, "FreeEntryCount(entries) > 0");
+ Debug.Assert(((entries)[0]._cFree) > 0, "FreeEntryCount(entries) > 0");
int availableFreeEntries = (_cPagesInUse * NUM_ENTRIES) - ((entries)[0]._cFree) - _cEntriesInUse;
if (availableFreeEntries < (NUM_ENTRIES - ((entries)[0]._cFree)))
break;
if (entries[i]._cacheEntry == null)
continue;
- Dbg.Assert(_freeEntryList._head != _freeEntryList._tail, "_freeEntryList._head != _freeEntryList._tail");
+ Debug.Assert(_freeEntryList._head != _freeEntryList._tail, "_freeEntryList._head != _freeEntryList._tail");
ExpiresEntryRef newRef = GetFreeExpiresEntry();
- Dbg.Assert(newRef.PageIndex != _freeEntryList._tail, "newRef.PageIndex != _freeEntryList._tail");
+ Debug.Assert(newRef.PageIndex != _freeEntryList._tail, "newRef.PageIndex != _freeEntryList._tail");
MemoryCacheEntry cacheEntry = entries[i]._cacheEntry;
return;
ExpiresEntryRef entryRef = cacheEntry.ExpiresEntryRef;
- Dbg.Assert((cacheEntry.ExpiresBucket == 0xff) == entryRef.IsInvalid, "(cacheEntry.ExpiresBucket == 0xff) == entryRef.IsInvalid");
+ Debug.Assert((cacheEntry.ExpiresBucket == 0xff) == entryRef.IsInvalid, "(cacheEntry.ExpiresBucket == 0xff) == entryRef.IsInvalid");
if (cacheEntry.ExpiresBucket != 0xff || !entryRef.IsInvalid)
return;
}
ExpiresEntryRef freeRef = GetFreeExpiresEntry();
- Dbg.Assert(cacheEntry.ExpiresBucket == 0xff, "cacheEntry.ExpiresBucket == 0xff");
- Dbg.Assert(cacheEntry.ExpiresEntryRef.IsInvalid, "cacheEntry.ExpiresEntryRef.IsInvalid");
+ Debug.Assert(cacheEntry.ExpiresBucket == 0xff, "cacheEntry.ExpiresBucket == 0xff");
+ Debug.Assert(cacheEntry.ExpiresEntryRef.IsInvalid, "cacheEntry.ExpiresEntryRef.IsInvalid");
cacheEntry.ExpiresBucket = _bucket;
cacheEntry.ExpiresEntryRef = freeRef;
ExpiresEntry[] entries = (_pages[(entryRef.PageIndex)]._entries);
int entryIndex = entryRef.Index;
- Dbg.Assert(cacheEntry == entries[entryIndex]._cacheEntry);
+ Debug.Assert(cacheEntry == entries[entryIndex]._cacheEntry);
RemoveCount(entries[entryIndex]._utcExpires);
AddCount(utcExpires);
if (_cEntriesInUse == 0 || GetExpiresCount(utcNow) == 0)
return 0;
- Dbg.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
+ Debug.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
ExpiresEntryRef inFlushHead = ExpiresEntryRef.INVALID;
lock (this)
{
- Dbg.Assert(_blockReduce == false, "_blockReduce == false");
+ Debug.Assert(_blockReduce == false, "_blockReduce == false");
if (_cEntriesInUse == 0 || GetExpiresCount(utcNow) == 0)
return 0;
}
}
- Dbg.Assert(!inFlushHead.IsInvalid, "!inFlushHead.IsInvalid");
+ Debug.Assert(!inFlushHead.IsInvalid, "!inFlushHead.IsInvalid");
MemoryCacheStore cacheStore = _cacheExpires.MemoryCacheStore;
ExpiresEntryRef current = inFlushHead;
cacheEntry = entries[entryIndex]._cacheEntry;
entries[entryIndex]._cacheEntry = null;
- Dbg.Assert(cacheEntry.ExpiresEntryRef.IsInvalid, "cacheEntry.ExpiresEntryRef.IsInvalid");
+ Debug.Assert(cacheEntry.ExpiresEntryRef.IsInvalid, "cacheEntry.ExpiresEntryRef.IsInvalid");
cacheStore.Remove(cacheEntry, cacheEntry, CacheEntryRemovedReason.Expired);
current = next;
current = next;
}
- Dbg.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
+ Debug.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
_blockReduce = false;
Reduce();
internal CacheExpires(MemoryCacheStore cacheStore)
{
- Dbg.Assert(NUMBUCKETS < byte.MaxValue);
+ Debug.Assert(NUMBUCKETS < byte.MaxValue);
DateTime utcNow = DateTime.UtcNow;
// the SizedRef is only updated after a Gen2 Collection
// increment the index (it's either 1 or 0)
- Dbg.Assert(SAMPLE_COUNT == 2);
+ Debug.Assert(SAMPLE_COUNT == 2);
_idx = _idx ^ 1;
// remember the sample time
_cacheSizeSampleTimes[_idx] = DateTime.UtcNow;
using System;
using System.Collections;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
internal UsageEntryRef(int pageIndex, int entryIndex)
{
- Dbg.Assert((pageIndex & 0x00ffffff) == pageIndex, "(pageIndex & 0x00ffffff) == pageIndex");
- Dbg.Assert((Math.Abs(entryIndex) & ENTRY_MASK) == (Math.Abs(entryIndex)), "(Math.Abs(entryIndex) & ENTRY_MASK) == Math.Abs(entryIndex)");
- Dbg.Assert(entryIndex != 0 || pageIndex == 0, "entryIndex != 0 || pageIndex == 0");
+ Debug.Assert((pageIndex & 0x00ffffff) == pageIndex, "(pageIndex & 0x00ffffff) == pageIndex");
+ Debug.Assert((Math.Abs(entryIndex) & ENTRY_MASK) == (Math.Abs(entryIndex)), "(Math.Abs(entryIndex) & ENTRY_MASK) == Math.Abs(entryIndex)");
+ Debug.Assert(entryIndex != 0 || pageIndex == 0, "entryIndex != 0 || pageIndex == 0");
_ref = ((((uint)pageIndex) << PAGE_SHIFT) | (((uint)(entryIndex)) & ENTRY_MASK));
}
get
{
int result = (int)(sbyte)(_ref & ENTRY_MASK);
- Dbg.Assert(result > 0, "result > 0");
+ Debug.Assert(result > 0, "result > 0");
return result;
}
}
get
{
int result = (int)(sbyte)(_ref & ENTRY_MASK);
- Dbg.Assert(result < 0, "result < 0");
+ Debug.Assert(result < 0, "result < 0");
return -result;
}
}
private void InitZeroPages()
{
- Dbg.Assert(_cPagesInUse == 0, "_cPagesInUse == 0");
- Dbg.Assert(_cEntriesInUse == 0, "_cEntriesInUse == 0");
- Dbg.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
- Dbg.Assert(_lastRefHead.IsInvalid, "_lastRefHead.IsInvalid");
- Dbg.Assert(_lastRefTail.IsInvalid, "_lastRefTail.IsInvalid");
- Dbg.Assert(_addRef2Head.IsInvalid, "_addRef2Head.IsInvalid");
+ Debug.Assert(_cPagesInUse == 0, "_cPagesInUse == 0");
+ Debug.Assert(_cEntriesInUse == 0, "_cEntriesInUse == 0");
+ Debug.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
+ Debug.Assert(_lastRefHead.IsInvalid, "_lastRefHead.IsInvalid");
+ Debug.Assert(_lastRefTail.IsInvalid, "_lastRefTail.IsInvalid");
+ Debug.Assert(_addRef2Head.IsInvalid, "_addRef2Head.IsInvalid");
_pages = null;
_minEntriesInUse = -1;
private void AddToListHead(int pageIndex, ref UsagePageList list)
{
- Dbg.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
+ Debug.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
(_pages[(pageIndex)]._pagePrev) = -1;
(_pages[(pageIndex)]._pageNext) = list._head;
if (list._head != -1)
{
- Dbg.Assert((_pages[(list._head)]._pagePrev) == -1, "PagePrev(list._head) == -1");
+ Debug.Assert((_pages[(list._head)]._pagePrev) == -1, "PagePrev(list._head) == -1");
(_pages[(list._head)]._pagePrev) = pageIndex;
}
else
private void AddToListTail(int pageIndex, ref UsagePageList list)
{
- Dbg.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
+ Debug.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
(_pages[(pageIndex)]._pageNext) = -1;
(_pages[(pageIndex)]._pagePrev) = list._tail;
if (list._tail != -1)
{
- Dbg.Assert((_pages[(list._tail)]._pageNext) == -1, "PageNext(list._tail) == -1");
+ Debug.Assert((_pages[(list._tail)]._pageNext) == -1, "PageNext(list._tail) == -1");
(_pages[(list._tail)]._pageNext) = pageIndex;
}
else
private int RemoveFromListHead(ref UsagePageList list)
{
- Dbg.Assert(list._head != -1, "list._head != -1");
+ Debug.Assert(list._head != -1, "list._head != -1");
int oldHead = list._head;
RemoveFromList(oldHead, ref list);
private void RemoveFromList(int pageIndex, ref UsagePageList list)
{
- Dbg.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
+ Debug.Assert((list._head == -1) == (list._tail == -1), "(list._head == -1) == (list._tail == -1)");
if ((_pages[(pageIndex)]._pagePrev) != -1)
{
- Dbg.Assert((_pages[((_pages[(pageIndex)]._pagePrev))]._pageNext) == pageIndex, "PageNext(PagePrev(pageIndex)) == pageIndex");
+ Debug.Assert((_pages[((_pages[(pageIndex)]._pagePrev))]._pageNext) == pageIndex, "PageNext(PagePrev(pageIndex)) == pageIndex");
(_pages[((_pages[(pageIndex)]._pagePrev))]._pageNext) = (_pages[(pageIndex)]._pageNext);
}
else
{
- Dbg.Assert(list._head == pageIndex, "list._head == pageIndex");
+ Debug.Assert(list._head == pageIndex, "list._head == pageIndex");
list._head = (_pages[(pageIndex)]._pageNext);
}
if ((_pages[(pageIndex)]._pageNext) != -1)
{
- Dbg.Assert((_pages[((_pages[(pageIndex)]._pageNext))]._pagePrev) == pageIndex, "PagePrev(PageNext(pageIndex)) == pageIndex");
+ Debug.Assert((_pages[((_pages[(pageIndex)]._pageNext))]._pagePrev) == pageIndex, "PagePrev(PageNext(pageIndex)) == pageIndex");
(_pages[((_pages[(pageIndex)]._pageNext))]._pagePrev) = (_pages[(pageIndex)]._pagePrev);
}
else
{
- Dbg.Assert(list._tail == pageIndex, "list._tail == pageIndex");
+ Debug.Assert(list._tail == pageIndex, "list._tail == pageIndex");
list._tail = (_pages[(pageIndex)]._pagePrev);
}
private void MoveToListHead(int pageIndex, ref UsagePageList list)
{
- Dbg.Assert(list._head != -1, "list._head != -1");
- Dbg.Assert(list._tail != -1, "list._tail != -1");
+ Debug.Assert(list._head != -1, "list._head != -1");
+ Debug.Assert(list._tail != -1, "list._tail != -1");
if (list._head == pageIndex)
return;
private void MoveToListTail(int pageIndex, ref UsagePageList list)
{
- Dbg.Assert(list._head != -1, "list._head != -1");
- Dbg.Assert(list._tail != -1, "list._tail != -1");
+ Debug.Assert(list._head != -1, "list._head != -1");
+ Debug.Assert(list._tail != -1, "list._tail != -1");
if (list._tail == pageIndex)
return;
else
{
int capacity = _cPagesInUse * NUM_ENTRIES;
- Dbg.Assert(capacity > 0, "capacity > 0");
- Dbg.Assert(MIN_LOAD_FACTOR < 1.0, "MIN_LOAD_FACTOR < 1.0");
+ Debug.Assert(capacity > 0, "capacity > 0");
+ Debug.Assert(MIN_LOAD_FACTOR < 1.0, "MIN_LOAD_FACTOR < 1.0");
_minEntriesInUse = (int)(capacity * MIN_LOAD_FACTOR);
private void RemovePage(int pageIndex)
{
- Dbg.Assert((((_pages[(pageIndex)]._entries))[0]._cFree) == NUM_ENTRIES, "FreeEntryCount(EntriesI(pageIndex)) == NUM_ENTRIES");
+ Debug.Assert((((_pages[(pageIndex)]._entries))[0]._cFree) == NUM_ENTRIES, "FreeEntryCount(EntriesI(pageIndex)) == NUM_ENTRIES");
RemoveFromList(pageIndex, ref _freeEntryList);
AddToListHead(pageIndex, ref _freePageList);
- Dbg.Assert((_pages[(pageIndex)]._entries) != null, "EntriesI(pageIndex) != null");
+ Debug.Assert((_pages[(pageIndex)]._entries) != null, "EntriesI(pageIndex) != null");
(_pages[(pageIndex)]._entries) = null;
_cPagesInUse--;
private UsageEntryRef GetFreeUsageEntry()
{
- Dbg.Assert(_freeEntryList._head >= 0, "_freeEntryList._head >= 0");
+ Debug.Assert(_freeEntryList._head >= 0, "_freeEntryList._head >= 0");
int pageIndex = _freeEntryList._head;
UsageEntry[] entries = (_pages[(pageIndex)]._entries);
((entries)[0]._cFree)--;
if (((entries)[0]._cFree) == 0)
{
- Dbg.Assert(((entries)[0]._ref1._next).IsInvalid, "FreeEntryHead(entries).IsInvalid");
+ Debug.Assert(((entries)[0]._ref1._next).IsInvalid, "FreeEntryHead(entries).IsInvalid");
RemoveFromList(pageIndex, ref _freeEntryList);
}
return new UsageEntryRef(pageIndex, entryIndex);
private void AddUsageEntryToFreeList(UsageEntryRef entryRef)
{
- Dbg.Assert(entryRef.IsRef1, "entryRef.IsRef1");
+ Debug.Assert(entryRef.IsRef1, "entryRef.IsRef1");
UsageEntry[] entries = (_pages[(entryRef.PageIndex)]._entries);
int entryIndex = entryRef.Ref1Index;
- Dbg.Assert(entries[entryIndex]._cacheEntry == null, "entries[entryIndex]._cacheEntry == null");
+ Debug.Assert(entries[entryIndex]._cacheEntry == null, "entries[entryIndex]._cacheEntry == null");
entries[entryIndex]._utcDate = DateTime.MinValue;
entries[entryIndex]._ref1._prev = UsageEntryRef.INVALID;
entries[entryIndex]._ref2._next = UsageEntryRef.INVALID;
private void Expand()
{
- Dbg.Assert(_cPagesInUse * NUM_ENTRIES == _cEntriesInUse, "_cPagesInUse * NUM_ENTRIES == _cEntriesInUse");
- Dbg.Assert(_freeEntryList._head == -1, "_freeEntryList._head == -1");
- Dbg.Assert(_freeEntryList._tail == -1, "_freeEntryList._tail == -1");
+ Debug.Assert(_cPagesInUse * NUM_ENTRIES == _cEntriesInUse, "_cPagesInUse * NUM_ENTRIES == _cEntriesInUse");
+ Debug.Assert(_freeEntryList._head == -1, "_freeEntryList._head == -1");
+ Debug.Assert(_freeEntryList._tail == -1, "_freeEntryList._tail == -1");
if (_freePageList._head == -1)
{
oldLength = _pages.Length;
}
- Dbg.Assert(_cPagesInUse == oldLength, "_cPagesInUse == oldLength");
- Dbg.Assert(_cEntriesInUse == oldLength * NUM_ENTRIES, "_cEntriesInUse == oldLength * ExpiresEntryRef.NUM_ENTRIES");
+ Debug.Assert(_cPagesInUse == oldLength, "_cPagesInUse == oldLength");
+ Debug.Assert(_cEntriesInUse == oldLength * NUM_ENTRIES, "_cEntriesInUse == oldLength * ExpiresEntryRef.NUM_ENTRIES");
int newLength = oldLength * 2;
newLength = Math.Max(oldLength + MIN_PAGES_INCREMENT, newLength);
newLength = Math.Min(newLength, oldLength + MAX_PAGES_INCREMENT);
- Dbg.Assert(newLength > oldLength, "newLength > oldLength");
+ Debug.Assert(newLength > oldLength, "newLength > oldLength");
UsagePage[] newPages = new UsagePage[newLength];
if (_cEntriesInUse >= _minEntriesInUse || _blockReduce)
return;
- Dbg.Assert(_freeEntryList._head != -1, "_freeEntryList._head != -1");
- Dbg.Assert(_freeEntryList._tail != -1, "_freeEntryList._tail != -1");
- Dbg.Assert(_freeEntryList._head != _freeEntryList._tail, "_freeEntryList._head != _freeEntryList._tail");
+ Debug.Assert(_freeEntryList._head != -1, "_freeEntryList._head != -1");
+ Debug.Assert(_freeEntryList._tail != -1, "_freeEntryList._tail != -1");
+ Debug.Assert(_freeEntryList._head != _freeEntryList._tail, "_freeEntryList._head != _freeEntryList._tail");
int meanFree = (int)(NUM_ENTRIES - (NUM_ENTRIES * MIN_LOAD_FACTOR));
int pageIndexLast = _freeEntryList._tail;
break;
entries = (_pages[(_freeEntryList._tail)]._entries);
- Dbg.Assert(((entries)[0]._cFree) > 0, "FreeEntryCount(entries) > 0");
+ Debug.Assert(((entries)[0]._cFree) > 0, "FreeEntryCount(entries) > 0");
int availableFreeEntries = (_cPagesInUse * NUM_ENTRIES) - ((entries)[0]._cFree) - _cEntriesInUse;
if (availableFreeEntries < (NUM_ENTRIES - ((entries)[0]._cFree)))
break;
if (entries[i]._cacheEntry == null)
continue;
- Dbg.Assert(_freeEntryList._head != _freeEntryList._tail, "_freeEntryList._head != _freeEntryList._tail");
+ Debug.Assert(_freeEntryList._head != _freeEntryList._tail, "_freeEntryList._head != _freeEntryList._tail");
UsageEntryRef newRef1 = GetFreeUsageEntry();
UsageEntryRef newRef2 = (new UsageEntryRef((newRef1).PageIndex, -(newRef1).Ref1Index));
- Dbg.Assert(newRef1.PageIndex != _freeEntryList._tail, "newRef1.PageIndex != _freeEntryList._tail");
+ Debug.Assert(newRef1.PageIndex != _freeEntryList._tail, "newRef1.PageIndex != _freeEntryList._tail");
UsageEntryRef oldRef1 = new UsageEntryRef(_freeEntryList._tail, i);
UsageEntryRef oldRef2 = (new UsageEntryRef((oldRef1).PageIndex, -(oldRef1).Ref1Index));
MemoryCacheEntry cacheEntry = entries[i]._cacheEntry;
- Dbg.Assert(cacheEntry.UsageEntryRef == oldRef1, "cacheEntry.UsageEntryRef == oldRef1");
+ Debug.Assert(cacheEntry.UsageEntryRef == oldRef1, "cacheEntry.UsageEntryRef == oldRef1");
cacheEntry.UsageEntryRef = newRef1;
UsageEntry[] newEntries = (_pages[(newRef1.PageIndex)]._entries);
((entries)[0]._cFree)++;
UsageEntryRef prev = newEntries[newRef1.Ref1Index]._ref1._prev;
- Dbg.Assert(prev != oldRef2, "prev != oldRef2");
+ Debug.Assert(prev != oldRef2, "prev != oldRef2");
UsageEntryRef next = newEntries[newRef1.Ref1Index]._ref1._next;
if (next == oldRef2)
}
next = newEntries[newRef1.Ref1Index]._ref2._next;
- Dbg.Assert(next != oldRef1, "next != oldRef1");
+ Debug.Assert(next != oldRef1, "next != oldRef1");
{ if ((prev).IsRef1) { (_pages[((prev).PageIndex)]._entries)[(prev).Ref1Index]._ref1._next = (newRef2); } else if ((prev).IsRef2) { (_pages[((prev).PageIndex)]._entries)[(prev).Ref2Index]._ref2._next = (newRef2); } else { _lastRefHead = (newRef2); } };
{ if ((next).IsRef1) { (_pages[((next).PageIndex)]._entries)[(next).Ref1Index]._ref1._prev = (newRef2); } else if ((next).IsRef2) { (_pages[((next).PageIndex)]._entries)[(next).Ref2Index]._ref2._prev = (newRef2); } else { _lastRefTail = (newRef2); } };
}
RemovePage(_freeEntryList._tail);
-
Dbg.Validate("CacheValidateUsage", this);
}
}
UsageEntryRef freeRef1 = GetFreeUsageEntry();
UsageEntryRef freeRef2 = (new UsageEntryRef((freeRef1).PageIndex, -(freeRef1).Ref1Index));
- Dbg.Assert(cacheEntry.UsageEntryRef.IsInvalid, "cacheEntry.UsageEntryRef.IsInvalid");
+ Debug.Assert(cacheEntry.UsageEntryRef.IsInvalid, "cacheEntry.UsageEntryRef.IsInvalid");
cacheEntry.UsageEntryRef = freeRef1;
UsageEntry[] entries = (_pages[(freeRef1.PageIndex)]._entries);
private void RemoveEntryFromLastRefList(UsageEntryRef entryRef)
{
- Dbg.Assert(entryRef.IsRef1, "entryRef.IsRef1");
+ Debug.Assert(entryRef.IsRef1, "entryRef.IsRef1");
UsageEntry[] entries = (_pages[(entryRef.PageIndex)]._entries);
int entryIndex = entryRef.Ref1Index;
if (_cEntriesInUse == 0)
return 0;
- Dbg.Assert(maxFlush > 0, "maxFlush is not greater than 0, instead is " + maxFlush);
- Dbg.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
+ Debug.Assert(maxFlush > 0, "maxFlush is not greater than 0, instead is " + maxFlush);
+ Debug.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
UsageEntryRef inFlushHead = UsageEntryRef.INVALID;
lock (this)
{
- Dbg.Assert(_blockReduce == false, "_blockReduce == false");
+ Debug.Assert(_blockReduce == false, "_blockReduce == false");
if (_cEntriesInUse == 0)
return 0;
for (prev = _lastRefTail; _cEntriesInFlush < maxFlush && !prev.IsInvalid; prev = prevNext)
{
- Dbg.Assert(_cEntriesInUse > 0, "_cEntriesInUse > 0");
+ Debug.Assert(_cEntriesInUse > 0, "_cEntriesInUse > 0");
prevNext = (_pages[(prev.PageIndex)]._entries)[prev.Ref2Index]._ref2._prev;
while (prevNext.IsRef1)
if (!force)
{
utcDate = entries[entryIndex]._utcDate;
- Dbg.Assert(utcDate != DateTime.MinValue, "utcDate != DateTime.MinValue");
+ Debug.Assert(utcDate != DateTime.MinValue, "utcDate != DateTime.MinValue");
if (utcNow - utcDate <= CacheUsage.NEWADD_INTERVAL && utcNow >= utcDate)
continue;
UsageEntryRef prev1 = (new UsageEntryRef((prev).PageIndex, (prev).Ref2Index));
cacheEntry = entries[entryIndex]._cacheEntry;
- Dbg.Assert(cacheEntry.UsageEntryRef == prev1, "cacheEntry.UsageEntryRef == prev1");
+ Debug.Assert(cacheEntry.UsageEntryRef == prev1, "cacheEntry.UsageEntryRef == prev1");
Dbg.Trace("CacheUsageFlushUnderUsedItem", "Flushing underused items, item=" + cacheEntry.Key + ", bucket=" + _bucket);
cacheEntry.UsageEntryRef = UsageEntryRef.INVALID;
_cacheUsage.MemoryCacheStore.UnblockInsert();
}
- Dbg.Assert(!inFlushHead.IsInvalid, "!inFlushHead.IsInvalid");
+ Debug.Assert(!inFlushHead.IsInvalid, "!inFlushHead.IsInvalid");
MemoryCacheStore cacheStore = _cacheUsage.MemoryCacheStore;
UsageEntryRef current = inFlushHead;
cacheEntry = entries[entryIndex]._cacheEntry;
entries[entryIndex]._cacheEntry = null;
- Dbg.Assert(cacheEntry.UsageEntryRef.IsInvalid, "cacheEntry.UsageEntryRef.IsInvalid");
+ Debug.Assert(cacheEntry.UsageEntryRef.IsInvalid, "cacheEntry.UsageEntryRef.IsInvalid");
cacheStore.Remove(cacheEntry, cacheEntry, CacheEntryRemovedReason.Evicted);
current = next;
current = next;
}
- Dbg.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
+ Debug.Assert(_cEntriesInFlush == 0, "_cEntriesInFlush == 0");
_blockReduce = false;
Reduce();
internal void Add(MemoryCacheEntry cacheEntry)
{
byte bucket = cacheEntry.UsageBucket;
- Dbg.Assert(bucket != 0xff, "bucket != 0xff");
+ Debug.Assert(bucket != 0xff, "bucket != 0xff");
_buckets[bucket].AddCacheEntry(cacheEntry);
}
using System.Runtime.Caching.Resources;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
+using System.Diagnostics;
// Every member of this class is thread-safe.
//
_flags[INITIALIZED] = true;
// If the dependency has already changed, or someone tried to dispose us, then call Dispose now.
- Dbg.Assert(_flags[INITIALIZED], "It is critical that INITIALIZED is set before CHANGED is checked below");
+ Debug.Assert(_flags[INITIALIZED], "It is critical that INITIALIZED is set before CHANGED is checked below");
if (_flags[CHANGED])
{
Dispose();
OnChangedHelper(state);
// OnChanged will also invoke Dispose, but only after initialization is complete
- Dbg.Assert(_flags[CHANGED], "It is critical that CHANGED is set before INITIALIZED is checked below.");
+ Debug.Assert(_flags[CHANGED], "It is critical that CHANGED is set before INITIALIZED is checked below.");
if (_flags[INITIALIZED])
{
DisposeHelper();
OnChangedHelper(null);
// If not initialized, throw, so the derived class understands that it must call InitializeComplete before Dispose.
- Dbg.Assert(_flags[CHANGED], "It is critical that CHANGED is set before INITIALIZED is checked below.");
+ Debug.Assert(_flags[CHANGED], "It is critical that CHANGED is set before INITIALIZED is checked below.");
if (!_flags[INITIALIZED])
{
throw new InvalidOperationException(SR.Init_not_complete);
[DllImport("kernel32.dll")]
internal extern static void DebugBreak();
- [DllImport("kernel32.dll")]
- internal extern static int GetCurrentProcessId();
-
- [DllImport("kernel32.dll")]
- internal extern static int GetCurrentThreadId();
-
- [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
- internal extern static IntPtr GetCurrentProcess();
-
[DllImport("kernel32.dll")]
internal extern static bool IsDebuggerPresent();
- [DllImport("kernel32.dll", SetLastError=true)]
- internal extern static bool TerminateProcess(HandleRef processHandle, int exitCode);
-
- internal const int PM_NOREMOVE = 0x0000;
- internal const int PM_REMOVE = 0x0001;
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct MSG {
- internal IntPtr hwnd;
- internal int message;
- internal IntPtr wParam;
- internal IntPtr lParam;
- internal int time;
- internal int pt_x;
- internal int pt_y;
- }
-
//[DllImport("user32.dll", CharSet=CharSet.Auto)]
//internal extern static bool PeekMessage([In, Out] ref MSG msg, HandleRef hwnd, int msgMin, int msgMax, int remove);
- internal const int
- MB_OK = 0x00000000,
- MB_OKCANCEL = 0x00000001,
- MB_ABORTRETRYIGNORE = 0x00000002,
- MB_YESNOCANCEL = 0x00000003,
- MB_YESNO = 0x00000004,
- MB_RETRYCANCEL = 0x00000005,
- MB_ICONHAND = 0x00000010,
- MB_ICONQUESTION = 0x00000020,
- MB_ICONEXCLAMATION = 0x00000030,
- MB_ICONASTERISK = 0x00000040,
- MB_USERICON = 0x00000080,
- MB_ICONWARNING = 0x00000030,
- MB_ICONERROR = 0x00000010,
- MB_ICONINFORMATION = 0x00000040,
- MB_DEFBUTTON1 = 0x00000000,
- MB_DEFBUTTON2 = 0x00000100,
- MB_DEFBUTTON3 = 0x00000200,
- MB_DEFBUTTON4 = 0x00000300,
- MB_APPLMODAL = 0x00000000,
- MB_SYSTEMMODAL = 0x00001000,
- MB_TASKMODAL = 0x00002000,
- MB_HELP = 0x00004000,
- MB_NOFOCUS = 0x00008000,
- MB_SETFOREGROUND = 0x00010000,
- MB_DEFAULT_DESKTOP_ONLY = 0x00020000,
- MB_TOPMOST = 0x00040000,
- MB_RIGHT = 0x00080000,
- MB_RTLREADING = 0x00100000,
- MB_SERVICE_NOTIFICATION = 0x00200000,
- MB_SERVICE_NOTIFICATION_NT3X = 0x00040000,
- MB_TYPEMASK = 0x0000000F,
- MB_ICONMASK = 0x000000F0,
- MB_DEFMASK = 0x00000F00,
- MB_MODEMASK = 0x00003000,
- MB_MISCMASK = 0x0000C000;
-
- internal const int
- IDOK = 1,
- IDCANCEL = 2,
- IDABORT = 3,
- IDRETRY = 4,
- IDIGNORE = 5,
- IDYES = 6,
- IDNO = 7,
- IDCLOSE = 8,
- IDHELP = 9;
-
//[DllImport("user32.dll", CharSet=CharSet.Auto, BestFitMapping=false)]
//internal extern static int MessageBox(HandleRef hWnd, string text, string caption, int type);
internal const int REG_NOTIFY_CHANGE_NAME = 1;
internal const int REG_NOTIFY_CHANGE_LAST_SET = 4;
-
- [DllImport("advapi32.dll", CharSet=CharSet.Auto, BestFitMapping=false, SetLastError=true)]
- internal extern static int RegOpenKeyEx(IntPtr hKey, string lpSubKey, int ulOptions, int samDesired, out SafeRegistryHandle hkResult);
-
- [DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true)]
- internal extern static int RegNotifyChangeKeyValue(SafeRegistryHandle hKey, bool watchSubTree, uint notifyFilter, SafeWaitHandle regEvent, bool async);
}
private enum TagValue {
private const string TAG_DEBUG_PREFIX = "DebugPrefix";
private const string TAG_DEBUG_THREAD_PREFIX = "DebugThreadPrefix";
- private const string PRODUCT = "Microsoft .NET Framework";
private const string COMPONENT = "System.Web";
private static string s_regKeyName = @"Software\Microsoft\ASP.NET\Debug";
}
// Open the reg key
- int result = NativeMethods.RegOpenKeyEx(NativeMethods.HKEY_LOCAL_MACHINE, s_listenKeyName, 0, NativeMethods.KEY_READ, out s_regHandle);
+ int result = Interop.Advapi32.RegOpenKeyEx(NativeMethods.HKEY_LOCAL_MACHINE, s_listenKeyName, 0, NativeMethods.KEY_READ, out s_regHandle);
if (result != 0)
{
StopRegistryMonitor();
}
// Listen for changes.
- result = NativeMethods.RegNotifyChangeKeyValue(
+ result = Interop.Advapi32.RegNotifyChangeKeyValue(
s_regHandle,
true,
NativeMethods.REG_NOTIFY_CHANGE_NAME | NativeMethods.REG_NOTIFY_CHANGE_LAST_SET,
}
else
{
- Debugger.Break();
+ Debugger.Break();
}
#endif
}
}
}
}
-
using System.Diagnostics.CodeAnalysis;
using System.Security;
using System.Threading;
+using System.Diagnostics;
namespace System.Runtime.Caching
{
}
break;
case CacheEntryRemovedReason.Evicted:
- Dbg.Fail("Reason should never be CacheEntryRemovedReason.Evicted since the entry was inserted as NotRemovable.");
+ Debug.Fail("Reason should never be CacheEntryRemovedReason.Evicted since the entry was inserted as NotRemovable.");
return;
default:
// do nothing if reason is Removed or CacheSpecificEviction
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
// set to null so RemoveDependent does not attempt to access it, since we're not
// using a copy of the KeyCollection.
_fields._dependents = null;
- Dbg.Assert(_fields._dependents == null, "_fields._dependents == null");
+ Debug.Assert(_fields._dependents == null, "_fields._dependents == null");
}
}
if (deps != null)
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
+using System.Diagnostics;
namespace System.Runtime.Caching
{
internal MemoryCacheEntryChangeMonitor(ReadOnlyCollection<string> keys, string regionName, MemoryCache cache)
{
- Dbg.Assert(keys != null && keys.Count > 0, "keys != null && keys.Count > 0");
+ Debug.Assert(keys != null && keys.Count > 0, "keys != null && keys.Count > 0");
_keys = keys;
_regionName = regionName;
InitDisposableMembers(cache);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
using System.Collections;
+using System.Diagnostics;
namespace System.Runtime.Caching
{
{
bool IEqualityComparer.Equals(object x, object y)
{
- Dbg.Assert(x != null && x is MemoryCacheKey);
- Dbg.Assert(y != null && y is MemoryCacheKey);
+ Debug.Assert(x != null && x is MemoryCacheKey);
+ Debug.Assert(y != null && y is MemoryCacheKey);
MemoryCacheKey a, b;
a = (MemoryCacheKey)x;
_usage.Remove(entry);
}
- Dbg.Assert(entry.State == EntryState.RemovingFromCache, "entry.State = EntryState.RemovingFromCache");
+ Debug.Assert(entry.State == EntryState.RemovingFromCache, "entry.State = EntryState.RemovingFromCache");
entry.State = EntryState.RemovedFromCache;
if (!delayRelease)
// MemoryCacheStatistics has been disposed, and therefore nobody should be using
// _insertBlock except for potential threads in WaitInsertBlock (which won't care if we call Close).
- Dbg.Assert(_useInsertBlock == false, "_useInsertBlock == false");
+ Debug.Assert(_useInsertBlock == false, "_useInsertBlock == false");
_insertBlock.Close();
// Don't need to call GC.SuppressFinalize(this) for sealed types without finalizers.
internal long TrimInternal(int percent)
{
- Dbg.Assert(percent <= 100, "percent <= 100");
+ Debug.Assert(percent <= 100, "percent <= 100");
int count = Count;
int toTrim = 0;
using System.Collections.Specialized;
using System.Security;
using System.Runtime.InteropServices;
-
+using System.Diagnostics;
namespace System.Runtime.Caching
{
protected void InitHistory()
{
- Dbg.Assert(_pressureHigh > 0, "_pressureHigh > 0");
- Dbg.Assert(_pressureLow > 0, "_pressureLow > 0");
- Dbg.Assert(_pressureLow <= _pressureHigh, "_pressureLow <= _pressureHigh");
+ Debug.Assert(_pressureHigh > 0, "_pressureHigh > 0");
+ Debug.Assert(_pressureLow > 0, "_pressureLow > 0");
+ Debug.Assert(_pressureLow <= _pressureHigh, "_pressureLow <= _pressureHigh");
int pressure = GetCurrentPressure();
// See the LICENSE file in the project root for more information.
using System;
+using System.Diagnostics;
using System.Runtime.Caching.Configuration;
using System.Runtime.InteropServices;
using System.Security;