[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D0EBFVCZGN3EY719RCQ08A":3,"skill-same:01M7D0EBFVCZGN3EY719RCQ08A":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7D0EBFVCZGN3EY719RCQ08A","generate-testability-wrappers",null,"DO NOT USE when the target already consumes an injected interface or built-in abstraction such as IFileSystem or TimeProvider, even if the request says \"generate a wrapper\"; no new wrapper is needed. Use only when C# source calls an ambient\u002Fstatic dependency and no injectable seam exists: first-time TimeProvider, IHttpClientFactory, or System.IO.Abstractions adoption; minimal Environment\u002FConsole\u002FProcess wrappers; IProcessRunner; DI registration; or an ambient seam that preserves a static API. Exclude static detection (detect-static-dependencies), migration to an existing\u002Fregistered abstraction (migrate-static-to-wrapper), one blocked behavior plus deterministic tests (testability-obstacle), and general interface design.","itsmejay18\u002FAI-Skills-for-My-Development-Stack","itsmejay18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167779943?v=4","01M7CZRFC6DDZA5V2CX8WDSZED","Jay Jemino Ababon ","01M7CZRFCVRNW1SFHSQXEJ3CQN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F02-CSharp-WPF-Desktop-Development\u002Fgenerate-testability-wrappers\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: generate-testability-wrappers\ndescription: >\n  DO NOT USE when the target already consumes an injected interface or built-in\n  abstraction such as IFileSystem or TimeProvider, even if the request says\n  \"generate a wrapper\"; no new wrapper is needed. Use only when C# source calls\n  an ambient\u002Fstatic dependency and no injectable seam exists: first-time\n  TimeProvider, IHttpClientFactory, or System.IO.Abstractions adoption; minimal\n  Environment\u002FConsole\u002FProcess wrappers; IProcessRunner; DI registration; or an\n  ambient seam that preserves a static API. Exclude static detection\n  (detect-static-dependencies), migration to an existing\u002Fregistered abstraction\n  (migrate-static-to-wrapper), one blocked behavior plus deterministic tests\n  (testability-obstacle), and general interface design.\nlicense: MIT\n---\n\n# Generate Testability Wrappers\n\nGenerate wrapper interfaces, default implementations, and DI service registration code for untestable static dependencies. For statics that already have .NET built-in abstractions (`TimeProvider`, `IHttpClientFactory`), guide adoption of the built-in. For statics without built-in alternatives, generate custom minimal wrappers.\n\n## When to Use\n\n- After running `detect-static-dependencies` and identifying which statics to wrap\n- When the user asks to make a class testable by replacing statics with injected abstractions\n- When adopting `TimeProvider` (.NET 8+) or `System.IO.Abstractions`\n- When creating a custom wrapper for `Environment.*`, `Console.*`, or `Process.*`\n- When a released static API needs an ambient seam because signatures cannot change\n\n## When Not to Use\n\n- The user wants to find statics first (use `detect-static-dependencies`)\n- The user wants to bulk-replace call sites (use `migrate-static-to-wrapper`)\n- The static is already behind an interface\n\nIf the target already consumes an injected interface or built-in abstraction, stop:\ndo not add a second wrapper, project, registration, or test around that seam.\n\n> A missing DI package does not by itself force an ambient seam. For an\n> instantiable class, prefer constructor injection and compose it explicitly or\n> show the requested registration. Use Step 5 when the API is static and its\n> signatures must stay static, or when the user explicitly forbids caller\n> construction\u002FDI changes.\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Static category | Yes | Which category: `time`, `filesystem`, `environment`, `network`, `console`, `process` |\n| Target framework | Yes | The `TargetFramework` from `.csproj` (affects which built-in abstractions exist) |\n| Composition | No | Existing DI framework, explicit\u002Fmanual construction, or immutable static API |\n| Namespace | No | Target namespace for generated wrapper code |\n\n## Workflow\n\n### Step 1: Determine the abstraction strategy\n\nBased on the category and target framework:\n\n| Category | .NET 8+ | .NET 6-7 | .NET Framework |\n|----------|---------|----------|----------------|\n| Time | `TimeProvider` (built-in) | `TimeProvider` via `Microsoft.Bcl.TimeProvider` NuGet | Custom `ISystemClock` |\n| File system | `System.IO.Abstractions` (NuGet) | Same | Same |\n| HTTP | `IHttpClientFactory` (built-in) | Same | Same |\n| Environment | Custom `IEnvironmentProvider` | Same | Same |\n| Console | Custom `IConsole` | Same | Same |\n| Process | Custom `IProcessRunner` | Same | Same |\n\nThe table picks *which abstraction*. How it reaches the code under test is a\nseparate axis:\n\n- instantiable class: constructor injection, even if current callers compose the\n  object manually;\n- existing container: add compile-ready registration following its conventions;\n- public static API\u002Fsignatures that cannot change: Step 5's ambient seam.\n\nCheck for a host builder, `IServiceCollection`, existing registrations, and\nconstruction sites. Do not infer \"must remain static\" merely because the project\ncurrently has no container.\n\n### Step 2: Generate built-in abstraction adoption (Time, HTTP)\n\n#### TimeProvider (.NET 8+)\n\nNo wrapper code needed. Complete all four parts: production registration,\nconstructor injection, a `FakeTimeProvider` test, and the testing package.\n\n1. Register in DI:\n```csharp\nbuilder.Services.AddSingleton(TimeProvider.System);\n```\n\n2. Inject into classes:\n```csharp\npublic class OrderProcessor(TimeProvider timeProvider)\n{\n    public bool IsExpired(Order order)\n        => timeProvider.GetUtcNow() > order.ExpiresAt;\n}\n```\n\n3. Test with `FakeTimeProvider`:\n```csharp\n\u002F\u002F Requires Microsoft.Extensions.TimeProvider.Testing NuGet\nvar fakeTime = new FakeTimeProvider(new DateTimeOffset(2026, 1, 15, 0, 0, 0, TimeSpan.Zero));\nvar processor = new OrderProcessor(fakeTime);\nfakeTime.Advance(TimeSpan.FromDays(1));\nAssert.True(processor.IsExpired(order));\n```\n\nThe assertion must prove a time-dependent result after the fake is pinned or\nadvanced. Merely constructing `FakeTimeProvider` is not a test. When the project\nhas no container but the target is an instantiable class, inject\n`TimeProvider` anyway and show explicit production construction with\n`TimeProvider.System`; do not replace it with a custom static clock.\n\nBefore calling the adoption complete, verify the repository contains or the\nanswer supplies every required artifact: the testing package reference, the\nproduction composition\u002Fregistration, every affected constructor call, and a\nrunnable fake-time test. A code fragment that omits one of those integration\npoints is guidance, not a completed adoption.\n\n#### TimeProvider (pre-.NET 8)\n\nGuide: install `Microsoft.Bcl.TimeProvider` NuGet. Same API as above.\n\n#### IHttpClientFactory\n\nNo wrapper code needed. Register a typed client via\n`builder.Services.AddHttpClient\u003CMyService>()` and inject `HttpClient` directly\ninto the class constructor. Preserve cancellation by passing the caller's token\nto the HTTP operation.\n\nFor tests, provide a complete fake `HttpMessageHandler` whose `SendAsync`\nreturns a deterministic `HttpResponseMessage`, construct `HttpClient` with that\nhandler, and exercise the typed client without network access. Compile and run\nthe focused test when the task asks for implementation; do not stop at a\nschematic handler method.\n\nWhen production uses a typed-client registration, test that same registration\npipeline: configure its primary handler in `ServiceCollection`, resolve the typed\nclient, and call it. A test that manually constructs `HttpClient` proves the class\nbut not the DI registration the task asked to adopt.\n\n### Step 3: Generate custom wrappers (Environment, Console, Process)\n\nFor categories without built-in abstractions, follow this template:\n\n#### Interface — define the minimal surface\n\nOnly include methods that were actually detected in the codebase. Do NOT generate a wrapper for every possible member — wrap only what is used.\n\nPrefer a stateless operation-shaped interface. For example, if a caller only\nneeds to start a process, wait, and return its exit code, expose one `Run`\noperation rather than a stateful wrapper that leaks `Process` lifecycle.\n\n```csharp\nnamespace \u003CNamespace>;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Abstraction over \u003Cstatic class> for testability. \n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic interface I\u003CWrapperName>\n{\n    \u002F\u002F One method per detected static call\n    \u003Creturn type> \u003CMethodName>(\u003Cparameters>);\n}\n```\n\n#### Default implementation — delegate to the real static\n\n```csharp\nnamespace \u003CNamespace>;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Default implementation that delegates to \u003Cstatic class>.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class \u003CWrapperName> : I\u003CWrapperName>\n{\n    public \u003Creturn type> \u003CMethodName>(\u003Cparameters>)\n        => \u003CStaticClass>.\u003CMethod>(\u003Carguments>);\n}\n```\n\n#### DI registration\n\n```csharp\n\u002F\u002F In Program.cs or Startup.cs:\nbuilder.Services.AddSingleton\u003CI\u003CWrapperName>, \u003CWrapperName>>();\n```\n\nTreat registration as a deliverable, not a sentence in the summary. Add it to\nthe repository's existing registration surface when one exists. Otherwise show\nthe exact compile-ready statement and identify where the caller should place\nit. Stateless delegating wrappers are singleton; if state must be retained,\nexplain why a shorter lifetime is required.\n\n### Step 4: Generate file system wrapper adoption\n\nPrefer the established `System.IO.Abstractions` NuGet package over custom wrappers:\n\n1. Install the package:\n```\ndotnet add package System.IO.Abstractions\n```\n\n2. Register in DI:\n```csharp\nbuilder.Services.AddSingleton\u003CIFileSystem, FileSystem>();\n```\n\n3. Inject `IFileSystem` into classes:\n```csharp\npublic class ConfigLoader(IFileSystem fileSystem)\n{\n    public string LoadConfig(string path)\n        => fileSystem.File.ReadAllText(path);\n}\n```\n\n4. Test with `MockFileSystem`:\n```\ndotnet add \u003CTestProject> package System.IO.Abstractions.TestingHelpers\n```\n```csharp\nvar mockFs = new MockFileSystem(new Dictionary\u003Cstring, MockFileData>\n{\n    { \"\u002Fconfig.json\", new MockFileData(\"{\\\"key\\\": \\\"value\\\"}\") }\n});\nvar loader = new ConfigLoader(mockFs);\nAssert.Equal(\"{\\\"key\\\": \\\"value\\\"}\", loader.LoadConfig(\"\u002Fconfig.json\"));\n```\n\nPackage-first adoption is exclusive: add both package references, use\n`IFileSystem` in production, register or explicitly compose `FileSystem`, and\nseed `MockFileSystem` before exercising the consumer. Do not also generate a\nsecond custom filesystem interface, and do not present an unseeded mock whose\ntest could pass without proving the requested read\u002Fwrite behavior.\n\n### Step 5: Generate a signature-preserving ambient context\n\nUse this pattern when the API must remain static or its released signatures\ncannot accept a dependency:\n\n```csharp\npublic static class Clock\n{\n    private static readonly AsyncLocal\u003CFunc\u003CDateTime>?> s_override = new();\n    public static DateTime UtcNow\n        => s_override.Value?.Invoke() ?? TimeProvider.System.GetUtcNow().UtcDateTime;\n\n    internal static IDisposable Override(DateTime fixedUtcTime)\n    {\n        if (fixedUtcTime.Kind != DateTimeKind.Utc)\n            throw new ArgumentException(\"The override must be UTC.\", nameof(fixedUtcTime));\n\n        var previous = s_override.Value;\n        s_override.Value = () => fixedUtcTime;\n        return new Scope(previous);\n    }\n    private sealed class Scope : IDisposable\n    {\n        private readonly Func\u003CDateTime>? _previous;\n        private bool _disposed;\n\n        public Scope(Func\u003CDateTime>? previous)\n        {\n            _previous = previous;\n        }\n\n        public void Dispose()\n        {\n            if (_disposed)\n                return;\n\n            s_override.Value = _previous;\n            _disposed = true;\n        }\n    }\n}\n```\n\nKey trade-offs: `AsyncLocal\u003CT>` ensures parallel tests don't interfere; production cost is one null check per call; the `static readonly` field is essentially free.\n\nThree properties this pattern must keep, because each has broken a real migration:\n\n- **Scope the override and make it reversible.** Return an `IDisposable` that restores the previous value, so a test cannot leak a pinned time into the next one. A bare setter, or a manual `try`\u002F`finally` at each call site, puts that burden on every test author.\n- **Use `AsyncLocal\u003CT>`, never `[ThreadStatic]`.** `[ThreadStatic]` does not flow across `await`, so the override silently disappears mid-test.\n- **Preserve the semantics of the member you are replacing.** Substituting `DateTime.UtcNow` with a local-time source changes the `DateTimeKind` every existing caller and stored value depends on — pair `UtcNow` with `GetUtcNow()`, and `Now` with `GetLocalNow()`.\n- **Prove the test assembly can reach the override.** An `internal` override is\n  inaccessible from a separate test assembly unless the production project adds\n  the exact `InternalsVisibleTo` for that test assembly. Otherwise use an\n  already-public seam only when a public API change is authorized. Never show a\n  test calling an inaccessible member.\n\nThe same shape works for non-time statics: swap `TimeProvider.System.GetUtcNow()` for the real static call and keep the override slot, the disposable scope, and the original semantics.\n\n### Step 6: Place generated files\n\nGenerate files following the project's existing conventions:\n- If there is an `Abstractions\u002F` or `Interfaces\u002F` folder, place the interface there\n- If there is an `Infrastructure\u002F` or `Services\u002F` folder, place the implementation there\n- Otherwise, create files next to the code that uses the static\n\nAlways generate:\n1. The interface file (or adoption instructions for built-in abstractions)\n2. The default implementation file\n3. The compile-ready DI registration, applied to an existing registration\n   surface or shown at the exact composition point.\n4. A deterministic substitution example or focused test that exercises the\n   consumer without the ambient resource.\n\nSkip registration entirely on the ambient-seam path: there is no container to\nregister into, and offering one anyway is the failure mode that made a user ask\nfor the seam in the first place.\n\nBefore reporting completion, verify the delivered output contains every item\nthe prompt requested. In particular, do not summarize \"singleton registration\"\nwhen no registration code was added or shown, and do not claim testability\nwithout demonstrating how the consumer receives a fake.\nFor console wrappers, exercise the consumer with a fake that both captures the\nprompt and supplies the returned input; a build or banner-only run does not prove\nthe prompt flow.\n\n## Validation\n\n- [ ] Generated interface only wraps statics that were actually detected (not speculative)\n- [ ] Default implementation delegates to the real static with no behavior changes\n- [ ] DI registration uses `AddSingleton` for stateless wrappers, `AddTransient` for stateful ones\n- [ ] NuGet packages are recommended where established libraries exist (System.IO.Abstractions, etc.)\n- [ ] For .NET 8+, `TimeProvider` is recommended over custom `ISystemClock`\n- [ ] TimeProvider adoption includes injection, production composition,\n      `FakeTimeProvider`, its testing package, and an assertion on a\n      time-dependent result\n- [ ] HTTP adoption includes a complete fake-handler test and preserves\n      cancellation\n- [ ] On injection paths, registration or explicit composition is compile-ready,\n      and a fake demonstrates the consumer without the real ambient dependency\n- [ ] Ambient context pattern includes `AsyncLocal\u003CT>`, a scoped `IDisposable` that restores the previous value, and trade-off explanation\n- [ ] On the ambient-seam path, no `IServiceCollection` registration is proposed, the separate test assembly can reach the override, and the replaced member's return type and semantics (`UtcNow` vs `Now`, and its `DateTimeKind`) are preserved\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Treating \"no DI package\" as \"must be ambient\" | Inject into instantiable classes and compose explicitly; reserve Step 5 for static\u002Fsignature-preserving APIs |\n| Wrapping ALL members of a static class | Only wrap methods actually called in the codebase |\n| Custom time wrapper on .NET 8+ | Use built-in `TimeProvider` instead |\n| Custom file system wrapper | Prefer `System.IO.Abstractions` NuGet — battle-tested, complete |\n| Registering scoped when singleton suffices | Stateless wrappers should be `AddSingleton` |\n| Forgetting test helper packages | `Microsoft.Extensions.TimeProvider.Testing` for time, `System.IO.Abstractions.TestingHelpers` for filesystem |\n| Ambient context without `AsyncLocal` | Non-async `[ThreadStatic]` breaks with `async`\u002F`await` — always use `AsyncLocal\u003CT>` |\n| Showing an internal ambient override to external tests | Add the exact friend assembly or use an authorized public seam; compile the test project |\n","# Generate Testability Wrappers\n\nGenerate wrapper interfaces, default implementations, and DI service registration code for untestable static dependencies. For statics that already have .NET built-in abstractions (`TimeProvider`, `IHttpClientFactory`), guide adoption of the built-in. For statics without built-in alternatives, generate custom minimal wrappers.\n\n## When to Use\n\n- After running `detect-static-dependencies` and identifying which statics to wrap\n- When the user asks to make a class testable by replacing statics with injected abstractions\n- When adopting `TimeProvider` (.NET 8+) or `System.IO.Abstractions`\n- When creating a custom wrapper for `Environment.*`, `Console.*`, or `Process.*`\n- When a released static API needs an ambient seam because signatures cannot change\n\n## When Not to Use\n\n- The user wants to find statics first (use `detect-static-dependencies`)\n- The user wants to bulk-replace call sites (use `migrate-static-to-wrapper`)\n- The static is already behind an interface\n\nIf the target already consumes an injected interface or built-in abstraction, stop:\ndo not add a second wrapper, project, registration, or test around that seam.\n\n> A missing DI package does not by itself force an ambient seam. For an\n> instantiable class, prefer constructor injection and compose it explicitly or\n> show the requested registration. Use Step 5 when the API is static and its\n> signatures must stay static, or when the user explicitly forbids caller\n> construction\u002FDI changes.\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Static category | Yes | Which category: `time`, `filesystem`, `environment`, `network`, `console`, `process` |\n| Target framework | Yes | The `TargetFramework` from `.csproj` (affects which built-in abstractions exist) |\n| Composition | No | Existing DI framework, explicit\u002Fmanual construction, or immutable static API |\n| Namespace | No | Target namespace for generated wrapper code |\n\n## Workflow\n\n### Step 1: Determine the abstraction strategy\n\nBased on the category and target framework:\n\n| Category | .NET 8+ | .NET 6-7 | .NET Framework |\n|----------|---------|----------|----------------|\n| Time | `TimeProvider` (built-in) | `TimeProvider` via `Microsoft.Bcl.TimeProvider` NuGet | Custom `ISystemClock` |\n| File system | `System.IO.Abstractions` (NuGet) | Same | Same |\n| HTTP | `IHttpClientFactory` (built-in) | Same | Same |\n| Environment | Custom `IEnvironmentProvider` | Same | Same |\n| Console | Custom `IConsole` | Same | Same |\n| Process | Custom `IProcessRunner` | Same | Same |\n\nThe table picks *which abstraction*. How it reaches the code under test is a\nseparate axis:\n\n- instantiable class: constructor injection, even if current callers compose the\n  object manually;\n- existing container: add compile-ready registration following its conventions;\n- public static API\u002Fsignatures that cannot change: Step 5's ambient seam.\n\nCheck for a host builder, `IServiceCollection`, existing registrations, and\nconstruction sites. Do not infer \"must remain static\" merely because the project\ncurrently has no container.\n\n### Step 2: Generate built-in abstraction adoption (Time, HTTP)\n\n#### TimeProvider (.NET 8+)\n\nNo wrapper code needed. Complete all four parts: production registration,\nconstructor injection, a `FakeTimeProvider` test, and the testing package.\n\n1. Register in DI:\n```csharp\nbuilder.Services.AddSingleton(TimeProvider.System);\n```\n\n2. Inject into classes:\n```csharp\npublic class OrderProcessor(TimeProvider timeProvider)\n{\n    public bool IsExpired(Order order)\n        => timeProvider.GetUtcNow() > order.ExpiresAt;\n}\n```\n\n3. Test with `FakeTimeProvider`:\n```csharp\n\u002F\u002F Requires Microsoft.Extensions.TimeProvider.Testing NuGet\nvar fakeTime = new FakeTimeProvider(new DateTimeOffset(2026, 1, 15, 0, 0, 0, TimeSpan.Zero));\nvar processor = new OrderProcessor(fakeTime);\nfakeTime.Advance(TimeSpan.FromDays(1));\nAssert.True(processor.IsExpired(order));\n```\n\nThe assertion must prove a time-dependent result after the fake is pinned or\nadvanced. Merely constructing `FakeTimeProvider` is not a test. When the project\nhas no container but the target is an instantiable class, inject\n`TimeProvider` anyway and show explicit production construction with\n`TimeProvider.System`; do not replace it with a custom static clock.\n\nBefore calling the adoption complete, verify the repository contains or the\nanswer supplies every required artifact: the testing package reference, the\nproduction composition\u002Fregistration, every affected constructor call, and a\nrunnable fake-time test. A code fragment that omits one of those integration\npoints is guidance, not a completed adoption.\n\n#### TimeProvider (pre-.NET 8)\n\nGuide: install `Microsoft.Bcl.TimeProvider` NuGet. Same API as above.\n\n#### IHttpClientFactory\n\nNo wrapper code needed. Register a typed client via\n`builder.Services.AddHttpClient\u003CMyService>()` and inject `HttpClient` directly\ninto the class constructor. Preserve cancellation by passing the caller's token\nto the HTTP operation.\n\nFor tests, provide a complete fake `HttpMessageHandler` whose `SendAsync`\nreturns a deterministic `HttpResponseMessage`, construct `HttpClient` with that\nhandler, and exercise the typed client without network access. Compile and run\nthe focused test when the task asks for implementation; do not stop at a\nschematic handler method.\n\nWhen production uses a typed-client registration, test that same registration\npipeline: configure its primary handler in `ServiceCollection`, resolve the typed\nclient, and call it. A test that manually constructs `HttpClient` proves the class\nbut not the DI registration the task asked to adopt.\n\n### Step 3: Generate custom wrappers (Environment, Console, Process)\n\nFor categories without built-in abstractions, follow this template:\n\n#### Interface — define the minimal surface\n\nOnly include methods that were actually detected in the codebase. Do NOT generate a wrapper for every possible member — wrap only what is used.\n\nPrefer a stateless operation-shaped interface. For example, if a caller only\nneeds to start a process, wait, and return its exit code, expose one `Run`\noperation rather than a stateful wrapper that leaks `Process` lifecycle.\n\n```csharp\nnamespace \u003CNamespace>;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Abstraction over \u003Cstatic class> for testability. \n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic interface I\u003CWrapperName>\n{\n    \u002F\u002F One method per detected static call\n    \u003Creturn type> \u003CMethodName>(\u003Cparameters>);\n}\n```\n\n#### Default implementation — delegate to the real static\n\n```csharp\nnamespace \u003CNamespace>;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Default implementation that delegates to \u003Cstatic class>.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class \u003CWrapperName> : I\u003CWrapperName>\n{\n    public \u003Creturn type> \u003CMethodName>(\u003Cparameters>)\n        => \u003CStaticClass>.\u003CMethod>(\u003Carguments>);\n}\n```\n\n#### DI registration\n\n```csharp\n\u002F\u002F In Program.cs or Startup.cs:\nbuilder.Services.AddSingleton\u003CI\u003CWrapperName>, \u003CWrapperName>>();\n```\n\nTreat registration as a deliverable, not a sentence in the summary. Add it to\nthe repository's existing registration surface when one exists. Otherwise show\nthe exact compile-ready statement and identify where the caller should place\nit. Stateless delegating wrappers are singleton; if state must be retained,\nexplain why a shorter lifetime is required.\n\n### Step 4: Generate file system wrapper adoption\n\nPrefer the established `System.IO.Abstractions` NuGet package over custom wrappers:\n\n1. Install the package:\n```\ndotnet add package System.IO.Abstractions\n```\n\n2. Register in DI:\n```csharp\nbuilder.Services.AddSingleton\u003CIFileSystem, FileSystem>();\n```\n\n3. Inject `IFileSystem` into classes:\n```csharp\npublic class ConfigLoader(IFileSystem fileSystem)\n{\n    public string LoadConfig(string path)\n        => fileSystem.File.ReadAllText(path);\n}\n```\n\n4. Test with `MockFileSystem`:\n```\ndotnet add \u003CTestProject> package System.IO.Abstractions.TestingHelpers\n```\n```csharp\nvar mockFs = new MockFileSystem(new Dictionary\u003Cstring, MockFileData>\n{\n    { \"\u002Fconfig.json\", new MockFileData(\"{\\\"key\\\": \\\"value\\\"}\") }\n});\nvar loader = new ConfigLoader(mockFs);\nAssert.Equal(\"{\\\"key\\\": \\\"value\\\"}\", loader.LoadConfig(\"\u002Fconfig.json\"));\n```\n\nPackage-first adoption is exclusive: add both package references, use\n`IFileSystem` in production, register or explicitly compose `FileSystem`, and\nseed `MockFileSystem` before exercising the consumer. Do not also generate a\nsecond custom filesystem interface, and do not present an unseeded mock whose\ntest could pass without proving the requested read\u002Fwrite behavior.\n\n### Step 5: Generate a signature-preserving ambient context\n\nUse this pattern when the API must remain static or its released signatures\ncannot accept a dependency:\n\n```csharp\npublic static class Clock\n{\n    private static readonly AsyncLocal\u003CFunc\u003CDateTime>?> s_override = new();\n    public static DateTime UtcNow\n        => s_override.Value?.Invoke() ?? TimeProvider.System.GetUtcNow().UtcDateTime;\n\n    internal static IDisposable Override(DateTime fixedUtcTime)\n    {\n        if (fixedUtcTime.Kind != DateTimeKind.Utc)\n            throw new ArgumentException(\"The override must be UTC.\", nameof(fixedUtcTime));\n\n        var previous = s_override.Value;\n        s_override.Value = () => fixedUtcTime;\n        return new Scope(previous);\n    }\n    private sealed class Scope : IDisposable\n    {\n        private readonly Func\u003CDateTime>? _previous;\n        private bool _disposed;\n\n        public Scope(Func\u003CDateTime>? previous)\n        {\n            _previous = previous;\n        }\n\n        public void Dispose()\n        {\n            if (_disposed)\n                return;\n\n            s_override.Value = _previous;\n            _disposed = true;\n        }\n    }\n}\n```\n\nKey trade-offs: `AsyncLocal\u003CT>` ensures parallel tests don't interfere; production cost is one null check per call; the `static readonly` field is essentially free.\n\nThree properties this pattern must keep, because each has broken a real migration:\n\n- **Scope the override and make it reversible.** Return an `IDisposable` that restores the previous value, so a test cannot leak a pinned time into the next one. A bare setter, or a manual `try`\u002F`finally` at each call site, puts that burden on every test author.\n- **Use `AsyncLocal\u003CT>`, never `[ThreadStatic]`.** `[ThreadStatic]` does not flow across `await`, so the override silently disappears mid-test.\n- **Preserve the semantics of the member you are replacing.** Substituting `DateTime.UtcNow` with a local-time source changes the `DateTimeKind` every existing caller and stored value depends on — pair `UtcNow` with `GetUtcNow()`, and `Now` with `GetLocalNow()`.\n- **Prove the test assembly can reach the override.** An `internal` override is\n  inaccessible from a separate test assembly unless the production project adds\n  the exact `InternalsVisibleTo` for that test assembly. Otherwise use an\n  already-public seam only when a public API change is authorized. Never show a\n  test calling an inaccessible member.\n\nThe same shape works for non-time statics: swap `TimeProvider.System.GetUtcNow()` for the real static call and keep the override slot, the disposable scope, and the original semantics.\n\n### Step 6: Place generated files\n\nGenerate files following the project's existing conventions:\n- If there is an `Abstractions\u002F` or `Interfaces\u002F` folder, place the interface there\n- If there is an `Infrastructure\u002F` or `Services\u002F` folder, place the implementation there\n- Otherwise, create files next to the code that uses the static\n\nAlways generate:\n1. The interface file (or adoption instructions for built-in abstractions)\n2. The default implementation file\n3. The compile-ready DI registration, applied to an existing registration\n   surface or shown at the exact composition point.\n4. A deterministic substitution example or focused test that exercises the\n   consumer without the ambient resource.\n\nSkip registration entirely on the ambient-seam path: there is no container to\nregister into, and offering one anyway is the failure mode that made a user ask\nfor the seam in the first place.\n\nBefore reporting completion, verify the delivered output contains every item\nthe prompt requested. In particular, do not summarize \"singleton registration\"\nwhen no registration code was added or shown, and do not claim testability\nwithout demonstrating how the consumer receives a fake.\nFor console wrappers, exercise the consumer with a fake that both captures the\nprompt and supplies the returned input; a build or banner-only run does not prove\nthe prompt flow.\n\n## Validation\n\n- [ ] Generated interface only wraps statics that were actually detected (not speculative)\n- [ ] Default implementation delegates to the real static with no behavior changes\n- [ ] DI registration uses `AddSingleton` for stateless wrappers, `AddTransient` for stateful ones\n- [ ] NuGet packages are recommended where established libraries exist (System.IO.Abstractions, etc.)\n- [ ] For .NET 8+, `TimeProvider` is recommended over custom `ISystemClock`\n- [ ] TimeProvider adoption includes injection, production composition,\n      `FakeTimeProvider`, its testing package, and an assertion on a\n      time-dependent result\n- [ ] HTTP adoption includes a complete fake-handler test and preserves\n      cancellation\n- [ ] On injection paths, registration or explicit composition is compile-ready,\n      and a fake demonstrates the consumer without the real ambient dependency\n- [ ] Ambient context pattern includes `AsyncLocal\u003CT>`, a scoped `IDisposable` that restores the previous value, and trade-off explanation\n- [ ] On the ambient-seam path, no `IServiceCollection` registration is proposed, the separate test assembly can reach the override, and the replaced member's return type and semantics (`UtcNow` vs `Now`, and its `DateTimeKind`) are preserved\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Treating \"no DI package\" as \"must be ambient\" | Inject into instantiable classes and compose explicitly; reserve Step 5 for static\u002Fsignature-preserving APIs |\n| Wrapping ALL members of a static class | Only wrap methods actually called in the codebase |\n| Custom time wrapper on .NET 8+ | Use built-in `TimeProvider` instead |\n| Custom file system wrapper | Prefer `System.IO.Abstractions` NuGet — battle-tested, complete |\n| Registering scoped when singleton suffices | Stateless wrappers should be `AddSingleton` |\n| Forgetting test helper packages | `Microsoft.Extensions.TimeProvider.Testing` for time, `System.IO.Abstractions.TestingHelpers` for filesystem |\n| Ambient context without `AsyncLocal` | Non-async `[ThreadStatic]` breaks with `async`\u002F`await` — always use `AsyncLocal\u003CT>` |\n| Showing an internal ambient override to external tests | Add the exact friend assembly or use an authorized public seam; compile the test project |\n",{"name":5,"license":15,"description":24},"DO NOT USE when the target already consumes an injected interface or built-in abstraction such as IFileSystem or TimeProvider, even if the request says \"generate a wrapper\"; no new wrapper is needed. Use only when C# source calls an ambient\u002Fstatic dependency and no injectable seam exists: first-time TimeProvider, IHttpClientFactory, or System.IO.Abstractions adoption; minimal Environment\u002FConsole\u002FProcess wrappers; IProcessRunner; DI registration; or an ambient seam that preserves a static API. Exclude static detection (detect-static-dependencies), migration to an existing\u002Fregistered abstraction (migrate-static-to-wrapper), one blocked behavior plus deterministic tests (testability-obstacle), and general interface design.\n","main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","02-CSharp-WPF-Desktop-Development\u002Fgenerate-testability-wrappers","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack","https:\u002F\u002Fgithub.com\u002Fitsmejay18","2026-09-18 16:06:36",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill generate-testability-wrappers",{"tool":37,"command":38},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill generate-testability-wrappers",{"tool":40,"command":41},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill generate-testability-wrappers","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F02-CSharp-WPF-Desktop-Development\u002Fgenerate-testability-wrappers\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7D2RKBHPZ3E1RNN5DWHT550","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including Vector\u003CT>, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fvectorization\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7D2RDJ7RN3QK8GJR0QTER1D","resolve-project-references","Guide for interpreting ResolveProjectReferences time in MSBuild performance summaries. Activate when ResolveProjectReferences appears as the most expensive target and developers are trying to optimize it directly. Explains that the reported time includes wait time for dependent project builds and is misleading. Guides users to focus on task self-time instead. Do not activate for general build performance -- use build-perf-diagnostics instead.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fresolve-project-references\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7D2R1H2GTNZYHG9YRX3JDQW","optimizing-ef-core-queries","Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7D2QREG04W1YT0NEBHEW5C9","microbenchmarking","Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling\u002Ftracing .NET code (dotnet-trace, PerfView), production telemetry, or load\u002Fstress testing (Crank, k6).","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fmicrobenchmarking\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7D2QGE175XWPZVACVH2868Z","incremental-build","Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fincremental-build\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7D2Q1DQTC6K49R73WQTTPSB","eval-performance","Guide for diagnosing and improving MSBuild project evaluation performance. USE FOR: builds slow before any compilation starts, high evaluation time in binlog analysis, expensive glob patterns walking large directories (node_modules, .git, bin\u002Fobj), deep import chains (>20 levels), preprocessed output >10K lines indicating heavy evaluation, property functions with file I\u002FO ($([System.IO.File]::ReadAllText(...))), multiple evaluations per project. Covers the 5 MSBuild evaluation phases, glob optimization via DefaultItemExcludes, import chain analysis with \u002Fpp preprocessing. DO NOT USE FOR: compilation-time slowness (use build-perf-diagnostics), incremental build issues (use incremental-build), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Feval-performance\u002FSKILL.md",[],[]]