CollectionSpy 0.0.7
See the version list below for details.
dotnet add package CollectionSpy --version 0.0.7
NuGet\Install-Package CollectionSpy -Version 0.0.7
<PackageReference Include="CollectionSpy" Version="0.0.7" />
<PackageVersion Include="CollectionSpy" Version="0.0.7" />
<PackageReference Include="CollectionSpy" />
paket add CollectionSpy --version 0.0.7
#r "nuget: CollectionSpy, 0.0.7"
#:package CollectionSpy@0.0.7
#addin nuget:?package=CollectionSpy&version=0.0.7
#tool nuget:?package=CollectionSpy&version=0.0.7
CollectionSpy 🕵️♂️
CollectionSpy allows you to "trap" and debug hidden modifications in your C# lists and dictionaries.
It provides a specialized TrapList<T> and TrapDictionary<TKey, TValue> that act as drop-in replacements for standard collections, enabling you to inject Breakpoints, Stack Traces, or Logs when specific data conditions are met (e.g., "Who added a null ID to this list?").
🚀 Why CollectionSpy?
Debugging legacy code or complex state management can be a nightmare when you don't know who modified a collection.
- Standard
ObservableCollectionis too verbose for debugging (requires event handlers). - Conditional Breakpoints in IDEs are slow and can't be shared with the team.
- AOP Frameworks are overkill for simple debugging tasks.
CollectionSpy solves this with a fluent, declarative API.
📦 Installation
dotnet add package CollectionSpy
⚡ Quick Start
1. Spy on a List
You can create a TrapList directly, or convert an existing IEnumerable using fluent extensions:
using Debugging.Traps;
using Debugging.Traps.Extensions; // Import for .ToTrapList()
var users = GetUsers().ToTrapList(); // Convert directly!
// 1. Break execution when a user with null name is added
users.OnAdd()
.When(u => u.Name == null)
.Do(TrapActions.Break());
// 2. Log a warning when a specific ID is removed
users.OnRemove()
.When(u => u.Id == 999)
.Do(TrapActions.Log("WARNING: Admin user 999 was removed!"));
2. Spy on a Dictionary
var config = GetConfigs().ToTrapDictionary();
// Alert if a secure setting is downgraded to HTTP
config.OnUpdate()
.When((key, value) => key == "ApiUrl" && value.StartsWith("http:"))
.Do(TrapActions.Log("SECURITY ALERT: API URL set to insecure HTTP!"));
3. Spy on a HashSet
var uniqueTags = new TrapHashSet<string>();
// Detect inefficient code: adding a tag that already exists
uniqueTags.OnAdd()
.When(tag => uniqueTags.Contains(tag))
.Do(TrapActions.Log("Inefficient Code: Tag already exists!"));
4. Spy on Queue and Stack
// Spy on a Queue (FIFO)
var jobQueue = new List<string> { "init_job" }.ToTrapQueue();
jobQueue.OnEnqueue()
.When(job => job == "POISON_PILL")
.Do(TrapActions.Log("Critical: Poison pill enqueued!"));
// Spy on a Stack (LIFO)
var navStack = new TrapStack<string>();
navStack.OnPop()
.When(page => page == "Root")
.Do(TrapActions.DumpStackTrace("Root Page Popped By"));
🛡️ Performance & Production Safety
CollectionSpy is designed to be usable in production for critical debugging, but with clear warnings.
Release Mode:
- By default,
TrapManager.Enabledis TRUE in both Debug and Release builds. - In Release builds, the library will emit a Console Warning on startup to alert you that traps are active.
- By default,
Disabling: To disable all overhead in production, set:
TrapManager.Enabled = false;When disabled, the interception logic returns immediately (fast-fail), imposing negligible overhead.
Thread Safety: Trap configuration is thread-safe. Execution logic snapshots rules to prevent concurrency issues during enumeration.
📝 License
MIT License. See LICENSE for details.
Maintained by angleyanalbedo
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.