[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D288M5K04PWREQJRHC6WX5":3,"skill-same:01M7D288M5K04PWREQJRHC6WX5":44},{"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":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7D288M5K04PWREQJRHC6WX5","testability-obstacle",null,"MUST USE for C#\u002F.NET deterministic tests that require the smallest production seam for DateTime\u002FTask.Delay\u002FFile\u002FEnvironment\u002FGuid\u002FRandom, static API preservation, nested\u002Fparallel overrides, or no real I\u002FO. USE ONLY when the target workspace contains C# source plus a .csproj or .sln. DO NOT USE for audits, bulk migration, code that already has an injectable seam, or an explicit migration to a user-named existing abstraction (migrate-static-to-wrapper). Use instead of general test generation when the requested test is impossible without a production edit and seam selection is still open.","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\u002F13-Testing-QA\u002Ftestability-obstacle\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: testability-obstacle\ndescription: >-\n  MUST USE for C#\u002F.NET deterministic tests that require the smallest production seam for\n  DateTime\u002FTask.Delay\u002FFile\u002FEnvironment\u002FGuid\u002FRandom, static API preservation,\n  nested\u002Fparallel overrides, or no real I\u002FO. USE ONLY when the target workspace\n  contains C# source plus a .csproj or .sln. DO NOT USE for audits, bulk\n  migration, code that already has an injectable seam, or an explicit migration\n  to a user-named existing abstraction (migrate-static-to-wrapper). Use instead\n  of general test generation when the requested test is impossible without a\n  production edit and seam selection is still open.\nlicense: MIT\n---\n\n# Resolve a Testability Obstacle\n\nIntroduce the smallest behavior-preserving seam needed to test a specific C#\nbehavior, then add deterministic tests that prove both the behavior and the seam.\nThe production edit is a means to the requested test, not an invitation to\nredesign adjacent code.\n\n## When to Use\n\n- A requested test would otherwise read\u002Fwrite the real filesystem.\n- Behavior depends on the current time, delay, random value, environment, console,\n  process, or another ambient dependency.\n- The user explicitly permits or requests a safe production seam.\n- Existing tests cannot control a dependency without process-global mutation.\n\n## When Not to Use\n\n- The dependency is already injected or passed as an argument. Write tests with\n  a fake through the existing seam using `code-testing-agent`.\n- The user wants a repository-wide testability audit. Use\n  `detect-static-dependencies`.\n- The user wants wrappers generated but not call sites\u002Ftests changed. Use\n  `generate-testability-wrappers`.\n- The user requests a broad mechanical migration. Use\n  `migrate-static-to-wrapper`, then generate tests separately.\n- The user already selected an existing replacement such as `TimeProvider` or\n  `IFileSystem` and asks to migrate call sites to it. Use\n  `migrate-static-to-wrapper`, which also updates affected tests.\n- The code is not C#\u002F.NET.\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Behavior to test | Yes | The method\u002Fworkflow and expected observable behavior |\n| Target scope | No | Discover the narrowest relevant file\u002Fproject when omitted |\n| Allowed production changes | No | Default to the minimum internal\u002Fconstructor seam |\n\n## Workflow\n\n### Step 1: Prove the obstacle\n\nRead the target production path and its existing tests. Identify the exact ambient\noperation preventing a deterministic test and the behavior that must remain\nunchanged. Do not run a repository-wide static scan for a single-class request.\n\nIf an adequate seam already exists, stop refactoring and use it. This skill adds\nno value when a fake can already be supplied.\n\n### Step 2: Select the smallest safe seam\n\nChoose by dependency and repository constraints:\n\n| Dependency | Preferred seam |\n|------------|----------------|\n| Current time \u002F timers | Inject `TimeProvider`; use `FakeTimeProvider` in tests |\n| Filesystem | Existing repository abstraction; for one write\u002Fread operation use an injected delegate when conventions allow, otherwise a one-member interface or an already accepted `System.IO.Abstractions` |\n| HTTP | Existing typed `HttpClient`\u002Fhandler or `IHttpClientFactory` seam |\n| Randomness | One generated value: injected delegate with `Random.Shared` as the production default; multiple operations\u002Fstate: inject `Random` or a minimal generator interface |\n| Environment\u002Fconsole\u002Fprocess | Minimal interface containing only members used by the target |\n\nThe scoped `AsyncLocal\u003CT>` rule applies to every static API that must retain its\npublic static shape — clocks, filesystem access, environment lookups, identity\ngeneration, and randomness. The scope captures and restores the previous value;\nnever implement `Dispose()` as an unconditional assignment to `null`.\nStore the provider\u002Fvalue itself in `AsyncLocal\u003CT>`. Do not put a mutable\n`Stack\u003CT>`, list, or other shared mutable collection in the slot: child\nexecution contexts can inherit the same object and corrupt each other's nesting.\nWhen the provider itself is mutable (for example an in-memory store or fake time\nprovider), establish a fresh provider inside each parallel flow rather than\nmutating one inherited instance from a parent context.\n\nConstructor injection is the default for instance classes. Reuse the repository's\nDI and naming conventions, but do not add a DI container to a class library just\nto satisfy this workflow.\n\nPreserve the existing public construction surface unless the user authorizes an\nAPI change. Keep a public parameterless constructor as the real-dependency default\nand place a test-only delegate\u002Fprovider constructor at the narrowest visibility\nthe test project can reach. Do not turn the seam into a new public optional\nparameter merely for test convenience.\n\nFor a static class or a public API that cannot change, use a scoped ambient seam\nonly when constructor\u002Fparameter injection is impossible. The override must:\n\n- flow across `await` (`AsyncLocal\u003CT>`, not `[ThreadStatic]`);\n- return `IDisposable` and restore the previous value, including nested scopes;\n- default to the real production dependency;\n- avoid a process-global mutable fake that makes tests non-parallel.\n\nUse built-in fake-time-aware overloads instead of inventing an `IDelay` wrapper:\n\n| Ambient operation | Replacement |\n|-------------------|-------------|\n| `Task.Delay(delay, token)` | `Task.Delay(delay, timeProvider, token)` |\n| `new CancellationTokenSource(delay)` | `new CancellationTokenSource(delay, timeProvider)` |\n| `PeriodicTimer(period)` | `new PeriodicTimer(period, timeProvider)` when the target framework provides it |\n\nTest delayed behavior by starting the operation, proving it is incomplete,\nadvancing `FakeTimeProvider`, then awaiting it. For a deadline or boundary,\nadvance to immediately before the deadline and assert the task is still\nincomplete before advancing across it; an immediate post-start assertion alone\ndoes not prove the boundary. Never wait for wall-clock time.\n\nFor a nested ambient override, each scope owns the value that was active when it\nstarted. Dispose scopes in LIFO order with `using` (which emits `try\u002Ffinally`) or\nan explicit `finally`; disposing the inner scope restores the outer value, never\nan unconditional `null`. For an environment-backed static API, use this shape:\n\n```csharp\npublic static class FeatureFlags\n{\n    private static readonly AsyncLocal\u003CFunc\u003Cstring, string?>?> s_environment = new();\n\n    public static bool IsEnabled(string name)\n    {\n        var reader = s_environment.Value;\n        var value = reader is null\n            ? Environment.GetEnvironmentVariable(name)\n            : reader(name);\n\n        return string.Equals(value, \"true\", StringComparison.OrdinalIgnoreCase);\n    }\n\n    public static IDisposable OverrideEnvironment(Func\u003Cstring, string?> reader)\n    {\n        ArgumentNullException.ThrowIfNull(reader);\n\n        var previous = s_environment.Value;\n        s_environment.Value = reader;\n        return new RestoreScope(() => s_environment.Value = previous);\n    }\n\n    private sealed class RestoreScope : IDisposable\n    {\n        private Action? _restore;\n\n        public RestoreScope(Action restore)\n        {\n            _restore = restore;\n        }\n\n        public void Dispose() =>\n            Interlocked.Exchange(ref _restore, null)?.Invoke();\n    }\n}\n```\n\nThe exception test must observe the outer value after the exception has escaped\nthe inner `using` scope but before the outer scope is disposed:\n\n```csharp\nusing var outer = FeatureFlags.OverrideEnvironment(_ => \"true\");\nAssert.True(FeatureFlags.IsEnabled(\"Preview\"));\n\nAssert.Throws\u003CInvalidOperationException>(() =>\n{\n    using var inner = FeatureFlags.OverrideEnvironment(_ => \"false\");\n    Assert.False(FeatureFlags.IsEnabled(\"Preview\"));\n    throw new InvalidOperationException(\"test\");\n});\n\nAssert.True(FeatureFlags.IsEnabled(\"Preview\"));\n```\n\nAlso overlap two async flows that each establish a fresh override and assert\nthat each flow sees only its own value. Parallel-only tests do not catch the\ncommon \"dispose sets null\" bug. Do not mutate process environment variables in\nthese tests; the scoped reader is the deterministic input. Choose an outer value\ndifferent from the production fallback so clearing the slot cannot accidentally\npass the restoration assertion.\n\n### Step 3: Preserve behavior and API shape\n\nKeep the production change mechanical:\n\n- Wrap only members used by the target behavior.\n- Default implementations delegate directly to the original API.\n- Preserve exceptions, path handling, time zone, and `DateTime.Kind`.\n- Keep existing public signatures unless the user explicitly permits an API change.\n- Do not move business logic into the wrapper or fix unrelated production bugs.\n\nDeterministic serialized text is a deliberate exception to preserving ambient\nplatform formatting. If the user asks for exact reproducible output across\nplatforms, use the format's explicit separator (use literal `\\n` when none is\nspecified) and assert that literal content. Keep `Environment.NewLine` only\nwhen platform-native output is part of the existing contract.\n\nFor time replacements:\n\n- `DateTime.UtcNow` -> `timeProvider.GetUtcNow().UtcDateTime`\n- `DateTime.Now` -> `timeProvider.GetLocalNow().LocalDateTime`\n- `DateTimeOffset.UtcNow` -> `timeProvider.GetUtcNow()`\n- `DateTimeOffset.Now` -> `timeProvider.GetLocalNow()`\n\n### Step 4: Keep production defaults wired\n\nUpdate every composition root or constructor call affected by the seam. Production\nmust still use real time\u002Ffilesystem\u002Fetc. by default. If the project uses DI,\nregister the default implementation with the lifetime matching repository\nconventions. If it does not use DI, compose explicitly; do not introduce a\ncontainer.\nAn existing manual factory must pass the real dependency explicitly (for example,\n`new ExpirationPolicy(TimeProvider.System)`). Do not move responsibility into an\noptional constructor or add an optional provider parameter to the factory.\n\nBuild the affected production project before writing tests. A compile failure here\nis a seam problem, not a test problem.\n\n### Step 5: Write deterministic tests\n\nUse the repository's existing test project. If none exists, invoke\n`scaffold-dotnet-test-project` first.\n\nTests must supply controlled dependencies:\n\n- fixed\u002Fadvanced time rather than wall-clock waiting;\n- an in-memory fake filesystem or hand-rolled fake rather than temp\u002Freal files;\n- no environment mutation, external process, console input, or network.\n\nBefore authoring a test, inspect its test project and follow the existing framework,\nglobal-using, and assertion conventions. Use the framework packages already referenced\nby that project; never add a hand-rolled `FactAttribute`, a substitute test-framework\ntype, or unrelated test-project plumbing to make a test compile.\n\nAssert the requested business result and at least one interaction\u002Fstate observable\nthat proves the fake dependency drove the path. Include a production-default test\nonly when it can remain deterministic; never touch the real filesystem merely to\nprove the adapter delegates.\n\nChoose the narrowest seam that supports the behavior. A single\n`File.WriteAllText` call can be an injected `Action\u003Cstring, string>` with a real\ndefault; do not create an interface, implementation, friend-assembly setting,\nand extra project wiring unless repository conventions or multiple operations\njustify them.\n\nPreserve the public API surface as well as existing signatures. Do not add a\npublic dependency-injecting constructor solely for tests. When a class currently\nhas only its implicit public parameterless constructor and the exact test\nassembly is known, keep that constructor behavior and make the test-only\nconstructor internal; an `InternalsVisibleTo` entry is justified in this narrow\ncase because it prevents the seam from becoming public API. Prefer an existing\nrepository friend-assembly convention when one is present.\n\nDo not add `InternalsVisibleTo` when an existing public seam already accepts the\nfake or the test project can otherwise supply it. Friend-assembly access is\njustified only when the chosen minimum constructor\u002Fdelegate seam must remain\ninternal to preserve the public API and the exact test assembly is known.\n\n### Step 6: Verify the complete path\n\nRun the affected production build, targeted test project, and repository-level\ntest command. Re-read the diff and confirm:\n\n1. every production change is required by the seam;\n2. no real ambient resource is used by the new tests;\n3. current-time semantics and public behavior are preserved;\n4. existing tests were not replaced or duplicated.\n\nInspect the test summary, not only the exit code. Zero discovered tests, a build\nwithout the requested test run, or any failing\u002Ferroring test means the task is\nincomplete. Fix discovery\u002Fexecution and rerun before reporting success.\nWhen a new test does not compile, correct its imports, assertion overload, or async\ntest shape against the existing test framework before changing the production seam;\ndo not emulate missing framework APIs in source.\nFor a static ambient seam, completion requires executed tests for substitution,\nnested restoration, and overlapping async-flow isolation; production compilation\nalone is never sufficient. Capture the passing test count or requested test\nnames in the handoff. If no test was discovered or the output does not prove\nexecution, correct the project\u002Ftest source and rerun rather than reporting the\nseam as validated.\n\n## Output Contract\n\nProvide a compact `Requirement | Evidence` table. Cite the production seam,\nproduction default wiring, exact test names, and passing commands. If a package\nrestore or build blocks validation, report that blocker rather than claiming the\ntests pass.\n\n## Validation\n\n- [ ] The original obstacle was concrete and in the requested path.\n- [ ] An existing seam was reused when available.\n- [ ] The new abstraction exposes only members required by the target behavior.\n- [ ] Production defaults still delegate to the original dependency.\n- [ ] The seam did not enlarge the public API when an internal test seam was sufficient.\n- [ ] Time conversions preserve local\u002FUTC and `DateTime.Kind` semantics.\n- [ ] Static ambient overrides are async-safe, scoped, nested, and reversible.\n- [ ] New tests use fixed\u002Fin-memory dependencies and no real I\u002FO or wall clock.\n- [ ] Production build and targeted\u002Frepository tests pass with at least one requested test discovered.\n\n## Common Pitfalls\n\n| Pitfall | Corrective action |\n|---------|-------------------|\n| Refactoring before proving a blocker | Reuse an existing seam and write the test directly |\n| Wrapping an entire static API | Expose only members exercised by the target |\n| Converting `UtcNow` with `.DateTime` | Use `.UtcDateTime` to preserve `DateTimeKind.Utc` |\n| Mutable static fake shared by tests | Use constructor injection or a scoped `AsyncLocal\u003CT>` override |\n| Adding DI to a library with no container | Compose the dependency explicitly |\n| Using temp files as a shortcut | Supply an in-memory fake; the scenario requires no real I\u002FO |\n| Stopping after the refactor builds | Write and run the behavior tests that justified the seam |\n| Reporting a zero-test run as success | Fix discovery and require the requested tests to execute and pass |\n","# Resolve a Testability Obstacle\n\nIntroduce the smallest behavior-preserving seam needed to test a specific C#\nbehavior, then add deterministic tests that prove both the behavior and the seam.\nThe production edit is a means to the requested test, not an invitation to\nredesign adjacent code.\n\n## When to Use\n\n- A requested test would otherwise read\u002Fwrite the real filesystem.\n- Behavior depends on the current time, delay, random value, environment, console,\n  process, or another ambient dependency.\n- The user explicitly permits or requests a safe production seam.\n- Existing tests cannot control a dependency without process-global mutation.\n\n## When Not to Use\n\n- The dependency is already injected or passed as an argument. Write tests with\n  a fake through the existing seam using `code-testing-agent`.\n- The user wants a repository-wide testability audit. Use\n  `detect-static-dependencies`.\n- The user wants wrappers generated but not call sites\u002Ftests changed. Use\n  `generate-testability-wrappers`.\n- The user requests a broad mechanical migration. Use\n  `migrate-static-to-wrapper`, then generate tests separately.\n- The user already selected an existing replacement such as `TimeProvider` or\n  `IFileSystem` and asks to migrate call sites to it. Use\n  `migrate-static-to-wrapper`, which also updates affected tests.\n- The code is not C#\u002F.NET.\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Behavior to test | Yes | The method\u002Fworkflow and expected observable behavior |\n| Target scope | No | Discover the narrowest relevant file\u002Fproject when omitted |\n| Allowed production changes | No | Default to the minimum internal\u002Fconstructor seam |\n\n## Workflow\n\n### Step 1: Prove the obstacle\n\nRead the target production path and its existing tests. Identify the exact ambient\noperation preventing a deterministic test and the behavior that must remain\nunchanged. Do not run a repository-wide static scan for a single-class request.\n\nIf an adequate seam already exists, stop refactoring and use it. This skill adds\nno value when a fake can already be supplied.\n\n### Step 2: Select the smallest safe seam\n\nChoose by dependency and repository constraints:\n\n| Dependency | Preferred seam |\n|------------|----------------|\n| Current time \u002F timers | Inject `TimeProvider`; use `FakeTimeProvider` in tests |\n| Filesystem | Existing repository abstraction; for one write\u002Fread operation use an injected delegate when conventions allow, otherwise a one-member interface or an already accepted `System.IO.Abstractions` |\n| HTTP | Existing typed `HttpClient`\u002Fhandler or `IHttpClientFactory` seam |\n| Randomness | One generated value: injected delegate with `Random.Shared` as the production default; multiple operations\u002Fstate: inject `Random` or a minimal generator interface |\n| Environment\u002Fconsole\u002Fprocess | Minimal interface containing only members used by the target |\n\nThe scoped `AsyncLocal\u003CT>` rule applies to every static API that must retain its\npublic static shape — clocks, filesystem access, environment lookups, identity\ngeneration, and randomness. The scope captures and restores the previous value;\nnever implement `Dispose()` as an unconditional assignment to `null`.\nStore the provider\u002Fvalue itself in `AsyncLocal\u003CT>`. Do not put a mutable\n`Stack\u003CT>`, list, or other shared mutable collection in the slot: child\nexecution contexts can inherit the same object and corrupt each other's nesting.\nWhen the provider itself is mutable (for example an in-memory store or fake time\nprovider), establish a fresh provider inside each parallel flow rather than\nmutating one inherited instance from a parent context.\n\nConstructor injection is the default for instance classes. Reuse the repository's\nDI and naming conventions, but do not add a DI container to a class library just\nto satisfy this workflow.\n\nPreserve the existing public construction surface unless the user authorizes an\nAPI change. Keep a public parameterless constructor as the real-dependency default\nand place a test-only delegate\u002Fprovider constructor at the narrowest visibility\nthe test project can reach. Do not turn the seam into a new public optional\nparameter merely for test convenience.\n\nFor a static class or a public API that cannot change, use a scoped ambient seam\nonly when constructor\u002Fparameter injection is impossible. The override must:\n\n- flow across `await` (`AsyncLocal\u003CT>`, not `[ThreadStatic]`);\n- return `IDisposable` and restore the previous value, including nested scopes;\n- default to the real production dependency;\n- avoid a process-global mutable fake that makes tests non-parallel.\n\nUse built-in fake-time-aware overloads instead of inventing an `IDelay` wrapper:\n\n| Ambient operation | Replacement |\n|-------------------|-------------|\n| `Task.Delay(delay, token)` | `Task.Delay(delay, timeProvider, token)` |\n| `new CancellationTokenSource(delay)` | `new CancellationTokenSource(delay, timeProvider)` |\n| `PeriodicTimer(period)` | `new PeriodicTimer(period, timeProvider)` when the target framework provides it |\n\nTest delayed behavior by starting the operation, proving it is incomplete,\nadvancing `FakeTimeProvider`, then awaiting it. For a deadline or boundary,\nadvance to immediately before the deadline and assert the task is still\nincomplete before advancing across it; an immediate post-start assertion alone\ndoes not prove the boundary. Never wait for wall-clock time.\n\nFor a nested ambient override, each scope owns the value that was active when it\nstarted. Dispose scopes in LIFO order with `using` (which emits `try\u002Ffinally`) or\nan explicit `finally`; disposing the inner scope restores the outer value, never\nan unconditional `null`. For an environment-backed static API, use this shape:\n\n```csharp\npublic static class FeatureFlags\n{\n    private static readonly AsyncLocal\u003CFunc\u003Cstring, string?>?> s_environment = new();\n\n    public static bool IsEnabled(string name)\n    {\n        var reader = s_environment.Value;\n        var value = reader is null\n            ? Environment.GetEnvironmentVariable(name)\n            : reader(name);\n\n        return string.Equals(value, \"true\", StringComparison.OrdinalIgnoreCase);\n    }\n\n    public static IDisposable OverrideEnvironment(Func\u003Cstring, string?> reader)\n    {\n        ArgumentNullException.ThrowIfNull(reader);\n\n        var previous = s_environment.Value;\n        s_environment.Value = reader;\n        return new RestoreScope(() => s_environment.Value = previous);\n    }\n\n    private sealed class RestoreScope : IDisposable\n    {\n        private Action? _restore;\n\n        public RestoreScope(Action restore)\n        {\n            _restore = restore;\n        }\n\n        public void Dispose() =>\n            Interlocked.Exchange(ref _restore, null)?.Invoke();\n    }\n}\n```\n\nThe exception test must observe the outer value after the exception has escaped\nthe inner `using` scope but before the outer scope is disposed:\n\n```csharp\nusing var outer = FeatureFlags.OverrideEnvironment(_ => \"true\");\nAssert.True(FeatureFlags.IsEnabled(\"Preview\"));\n\nAssert.Throws\u003CInvalidOperationException>(() =>\n{\n    using var inner = FeatureFlags.OverrideEnvironment(_ => \"false\");\n    Assert.False(FeatureFlags.IsEnabled(\"Preview\"));\n    throw new InvalidOperationException(\"test\");\n});\n\nAssert.True(FeatureFlags.IsEnabled(\"Preview\"));\n```\n\nAlso overlap two async flows that each establish a fresh override and assert\nthat each flow sees only its own value. Parallel-only tests do not catch the\ncommon \"dispose sets null\" bug. Do not mutate process environment variables in\nthese tests; the scoped reader is the deterministic input. Choose an outer value\ndifferent from the production fallback so clearing the slot cannot accidentally\npass the restoration assertion.\n\n### Step 3: Preserve behavior and API shape\n\nKeep the production change mechanical:\n\n- Wrap only members used by the target behavior.\n- Default implementations delegate directly to the original API.\n- Preserve exceptions, path handling, time zone, and `DateTime.Kind`.\n- Keep existing public signatures unless the user explicitly permits an API change.\n- Do not move business logic into the wrapper or fix unrelated production bugs.\n\nDeterministic serialized text is a deliberate exception to preserving ambient\nplatform formatting. If the user asks for exact reproducible output across\nplatforms, use the format's explicit separator (use literal `\\n` when none is\nspecified) and assert that literal content. Keep `Environment.NewLine` only\nwhen platform-native output is part of the existing contract.\n\nFor time replacements:\n\n- `DateTime.UtcNow` -> `timeProvider.GetUtcNow().UtcDateTime`\n- `DateTime.Now` -> `timeProvider.GetLocalNow().LocalDateTime`\n- `DateTimeOffset.UtcNow` -> `timeProvider.GetUtcNow()`\n- `DateTimeOffset.Now` -> `timeProvider.GetLocalNow()`\n\n### Step 4: Keep production defaults wired\n\nUpdate every composition root or constructor call affected by the seam. Production\nmust still use real time\u002Ffilesystem\u002Fetc. by default. If the project uses DI,\nregister the default implementation with the lifetime matching repository\nconventions. If it does not use DI, compose explicitly; do not introduce a\ncontainer.\nAn existing manual factory must pass the real dependency explicitly (for example,\n`new ExpirationPolicy(TimeProvider.System)`). Do not move responsibility into an\noptional constructor or add an optional provider parameter to the factory.\n\nBuild the affected production project before writing tests. A compile failure here\nis a seam problem, not a test problem.\n\n### Step 5: Write deterministic tests\n\nUse the repository's existing test project. If none exists, invoke\n`scaffold-dotnet-test-project` first.\n\nTests must supply controlled dependencies:\n\n- fixed\u002Fadvanced time rather than wall-clock waiting;\n- an in-memory fake filesystem or hand-rolled fake rather than temp\u002Freal files;\n- no environment mutation, external process, console input, or network.\n\nBefore authoring a test, inspect its test project and follow the existing framework,\nglobal-using, and assertion conventions. Use the framework packages already referenced\nby that project; never add a hand-rolled `FactAttribute`, a substitute test-framework\ntype, or unrelated test-project plumbing to make a test compile.\n\nAssert the requested business result and at least one interaction\u002Fstate observable\nthat proves the fake dependency drove the path. Include a production-default test\nonly when it can remain deterministic; never touch the real filesystem merely to\nprove the adapter delegates.\n\nChoose the narrowest seam that supports the behavior. A single\n`File.WriteAllText` call can be an injected `Action\u003Cstring, string>` with a real\ndefault; do not create an interface, implementation, friend-assembly setting,\nand extra project wiring unless repository conventions or multiple operations\njustify them.\n\nPreserve the public API surface as well as existing signatures. Do not add a\npublic dependency-injecting constructor solely for tests. When a class currently\nhas only its implicit public parameterless constructor and the exact test\nassembly is known, keep that constructor behavior and make the test-only\nconstructor internal; an `InternalsVisibleTo` entry is justified in this narrow\ncase because it prevents the seam from becoming public API. Prefer an existing\nrepository friend-assembly convention when one is present.\n\nDo not add `InternalsVisibleTo` when an existing public seam already accepts the\nfake or the test project can otherwise supply it. Friend-assembly access is\njustified only when the chosen minimum constructor\u002Fdelegate seam must remain\ninternal to preserve the public API and the exact test assembly is known.\n\n### Step 6: Verify the complete path\n\nRun the affected production build, targeted test project, and repository-level\ntest command. Re-read the diff and confirm:\n\n1. every production change is required by the seam;\n2. no real ambient resource is used by the new tests;\n3. current-time semantics and public behavior are preserved;\n4. existing tests were not replaced or duplicated.\n\nInspect the test summary, not only the exit code. Zero discovered tests, a build\nwithout the requested test run, or any failing\u002Ferroring test means the task is\nincomplete. Fix discovery\u002Fexecution and rerun before reporting success.\nWhen a new test does not compile, correct its imports, assertion overload, or async\ntest shape against the existing test framework before changing the production seam;\ndo not emulate missing framework APIs in source.\nFor a static ambient seam, completion requires executed tests for substitution,\nnested restoration, and overlapping async-flow isolation; production compilation\nalone is never sufficient. Capture the passing test count or requested test\nnames in the handoff. If no test was discovered or the output does not prove\nexecution, correct the project\u002Ftest source and rerun rather than reporting the\nseam as validated.\n\n## Output Contract\n\nProvide a compact `Requirement | Evidence` table. Cite the production seam,\nproduction default wiring, exact test names, and passing commands. If a package\nrestore or build blocks validation, report that blocker rather than claiming the\ntests pass.\n\n## Validation\n\n- [ ] The original obstacle was concrete and in the requested path.\n- [ ] An existing seam was reused when available.\n- [ ] The new abstraction exposes only members required by the target behavior.\n- [ ] Production defaults still delegate to the original dependency.\n- [ ] The seam did not enlarge the public API when an internal test seam was sufficient.\n- [ ] Time conversions preserve local\u002FUTC and `DateTime.Kind` semantics.\n- [ ] Static ambient overrides are async-safe, scoped, nested, and reversible.\n- [ ] New tests use fixed\u002Fin-memory dependencies and no real I\u002FO or wall clock.\n- [ ] Production build and targeted\u002Frepository tests pass with at least one requested test discovered.\n\n## Common Pitfalls\n\n| Pitfall | Corrective action |\n|---------|-------------------|\n| Refactoring before proving a blocker | Reuse an existing seam and write the test directly |\n| Wrapping an entire static API | Expose only members exercised by the target |\n| Converting `UtcNow` with `.DateTime` | Use `.UtcDateTime` to preserve `DateTimeKind.Utc` |\n| Mutable static fake shared by tests | Use constructor injection or a scoped `AsyncLocal\u003CT>` override |\n| Adding DI to a library with no container | Compose the dependency explicitly |\n| Using temp files as a shortcut | Supply an in-memory fake; the scenario requires no real I\u002FO |\n| Stopping after the refactor builds | Write and run the behavior tests that justified the seam |\n| Reporting a zero-test run as success | Fix discovery and require the requested tests to execute and pass |\n",{"name":5,"license":15,"description":7},"main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","13-Testing-QA\u002Ftestability-obstacle","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":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill testability-obstacle",{"tool":36,"command":37},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill testability-obstacle",{"tool":39,"command":40},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill testability-obstacle","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F13-Testing-QA\u002Ftestability-obstacle\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"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":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"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":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"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":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"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":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"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":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"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",[],[]]