detect-static-dependencies

Scan C# source files for hard-to-test static dependencies and produce a ranked report.

Updated Jul 12, 2026
One-click install
npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill detect-static-dependencies-patrick-rex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: detect-static-dependencies
Source: https://github.com/Patrick-Rex/DotNetTechSamples/tree/main/.agents/plugins/dotnet-test/skills/detect-static-dependencies
Command: npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill detect-static-dependencies-patrick-rex

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? C# codebases often call static APIs like DateTime.Now, File.ReadAllText, and new HttpClient() directly, making unit testing difficult. This Skill audits a project, file, or solution to find every untestable static call site and ranks them by frequency so you know where to start. ## Core Features & Use Cases - Static Dependency Detection: Searches .cs files for time, filesystem, environment, network, console, and process statics such as DateTime.UtcNow, File.Exists, and Process.Start. - Ranked Testability Report: Produces a category summary, top 10 patterns by count, most affected files, and a migration priority ordered by impact. - Replacement Guidance: Maps each category to a recommended .NET abstraction such as TimeProvider, System.IO.Abstractions, or IHttpClientFactory. - Use Case: Before adding unit tests to a legacy service, scan the solution to discover that DateTime.UtcNow appears 28 times across 14 files, then prioritize wrapping time access first. ## Quick Start Scan the DataAccess project directory for hard-to-test static dependencies and show me the ranked report.

Frequently Asked Questions about detect-static-dependencies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find untestable static dependencies in C# code?

Scan your .cs files for patterns like DateTime.Now, File.ReadAllText, Environment.GetEnvironmentVariable, new HttpClient(), Console.WriteLine, and Process.Start. The scan counts each call site and ranks patterns by frequency so you can prioritize which statics to wrap first.

What should I use to replace DateTime.Now in .NET for testability?

Use TimeProvider, which is built into .NET 8 and later, to abstract time access for unit testing. On earlier target frameworks, use NodaTime.IClock or a custom ISystemClock interface instead.

Can I scan only one project or file instead of the whole solution?

Yes, the scan scope can be a single .cs file, a directory, a .csproj, or a full .sln. When you provide a specific path, only that scope is scanned, and obj/, bin/, and test projects are excluded by default.

What replaces static file system calls like File.Exists in C#?

Use the System.IO.Abstractions NuGet package, which provides IFileSystem interfaces for File, Directory, and Path operations. This lets you mock file system behavior in unit tests without touching disk.

When should I not run a static dependency scan?

Skip the scan when statics are already behind interfaces or TimeProvider, when the code is not C#, or when you want wrappers generated or migration performed. Those tasks belong to wrapper generation and migration skills, not detection.