Loading...
Loading...
Scan C# source files for hard-to-test static dependencies — DateTime.Now/UtcNow, File.*, Directory.*, Environment.*, HttpClient, Console.*, Process.*, and other untestable statics. Produces a ranked report of static call sites by frequency. USE FOR: find untestable statics, scan for static dependencies, testability audit, identify hard-to-mock code, find DateTime.Now usage, detect static coupling, testability report, static analysis for testability. DO NOT USE FOR: generating wrappers (use generate-testability-wrappers), migrating code (use migrate-static-to-wrapper), general code review, or finding statics that are already behind abstractions.
npx skill4agent add dotnet/skills detect-static-dependenciesgenerate-testability-wrappersmigrate-static-to-wrapperTimeProvider| Input | Required | Description |
|---|---|---|
| Target path | Yes | A file, directory, project (.csproj), or solution (.sln) to scan |
| Exclusion patterns | No | Glob patterns to skip (e.g., |
| Category filter | No | Limit to specific categories: |
.cs.cs.csobj/bin/.csproj.cs.sln.csobj/bin/| Category | Patterns to search for | Recommended replacement |
|---|---|---|
| Time | | |
| File System | | |
| Environment | | Custom |
| Network | | |
| Console | | |
| Process | | Custom |
TimeProviderSystem.IO.AbstractionsIHttpClientFactoryIEnvironmentProviderIConsoleILoggerIProcessRunner## Static Dependency Report
**Scope**: <project/solution name>
**Files scanned**: <count>
**Total static call sites**: <count>
### Category Summary
| Category | Call Sites | Recommended Abstraction |
|-------------|-----------|------------------------|
| Time | 42 | TimeProvider (.NET 8+) |
| File System | 31 | System.IO.Abstractions |
| Environment | 12 | IEnvironmentProvider |
| ... | ... | ... |
### Top 10 Patterns
| # | Pattern | Count | Files |
|---|---------------------|-------|-------|
| 1 | DateTime.UtcNow | 28 | 14 |
| 2 | File.ReadAllText | 18 | 9 |
| ... |
### Most Affected Files
| File | Static Calls | Categories |
|-------------------------------|-------------|---------------------|
| Services/OrderProcessor.cs | 12 | Time, FileSystem |
| ... |
### Migration Priority
1. **Time** (42 sites) — Use `TimeProvider`, zero NuGet dependencies on .NET 8+
2. **File System** (31 sites) — Use `System.IO.Abstractions` NuGet package
3. ...generate-testability-wrappersmigrate-static-to-wrapper.csobj/bin/| Pitfall | Solution |
|---|---|
Scanning | Always exclude |
| Counting wrapped calls as statics | Check if the call is behind an interface or injected service before counting |
| Missing statics inside lambdas/LINQ | Search covers all code within |
Recommending | Check |
| Ignoring test projects | Only scan production code — exclude |