migrate-static-to-wrapper

Refactor static dependencies in .NET projects to injected wrapper interfaces.

Updated May 28, 2026
One-click install
npx skills add https://github.com/ojrojas/AgentsInstructions --skill migrate-static-to-wrapper-ojrojas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-static-to-wrapper
Source: https://github.com/ojrojas/AgentsInstructions/tree/main/.claude/skills/dotnet-test/skills/migrate-static-to-wrapper
Command: npx skills add https://github.com/ojrojas/AgentsInstructions --skill migrate-static-to-wrapper-ojrojas

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Microsoft.Bcl.TimeProvider, System.IO.Abstractions, Microsoft.Extensions.TimeProvider.Testing, System.IO.Abstractions.TestingHelpers, and includes scripts (resource) components.

What problem does it solve?

This Skill migrates static method calls to wrapper abstractions, improving testability and dependency injection in .NET applications.

Core Features & Use Cases

  • Static to Wrapper Replacement: Transforms static calls like DateTime.UtcNow or File.ReadAllText to wrapper or built-in abstraction calls.
  • Constructor Injection: Adds constructor injection for new abstractions and updates DI registration.
  • Scalable Migration: Operates on bounded scopes such as a single file, project, or namespace, allowing incremental migration.

Quick Start

Run the migrate-static-to-wrapper skill on your project to refactor static calls to wrappers for better testability and dependency injection.

Frequently Asked Questions about migrate-static-to-wrapper

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

FAQPage Schema
How do I refactor static method calls in .NET for dependency injection?

Refactoring static method calls in .NET for dependency injection involves replacing static dependencies like DateTime.UtcNow with injected wrapper interfaces. This Skill automates transforming static calls to wrapper abstractions and updates constructor injection to improve testability.

What is the best way to replace static file system calls in C#?

The best way to replace static file system calls in C# is migrating them to wrapper abstractions using System.IO.Abstractions. This Skill refactors static calls like File.ReadAllText to injected interfaces, enabling mockable file system operations for unit testing.

Does migrate-static-to-wrapper support incremental migration across a namespace?

Yes, migrate-static-to-wrapper supports incremental migration across a namespace. It operates on bounded scopes including single files, projects, or namespaces, allowing you to gradually refactor static dependencies to wrapper abstractions without overhauling the entire solution.

Can I use Microsoft.Bcl.TimeProvider to test static DateTime calls in .NET 8?

You can use Microsoft.Bcl.TimeProvider to test static DateTime calls in .NET 8 by abstracting time dependencies. This Skill replaces DateTime.UtcNow with TimeProvider abstractions and leverages Microsoft.Extensions.TimeProvider.Testing for deterministic unit testing.

What dependencies are required to set up static refactoring for testability?

Setting up static refactoring for testability requires Microsoft.Bcl.TimeProvider, System.IO.Abstractions, and their testing helper libraries. The Skill requires dependency injection setup in your .NET 8+ project to properly resolve the injected wrapper interfaces.

When should I avoid replacing static calls with wrapper abstractions?

You should avoid replacing static calls with wrapper abstractions if your .NET project lacks dependency injection setup or targets a version below .NET 8. The Skill relies on Microsoft.Bcl.TimeProvider support and bounded scopes to function correctly during static refactoring.