Files
Amaury Levé 4c40b873f2 Add detect-static-dependencies evals for report structure, obj exclusion, and lambda statics (#640)
Cover previously uncovered skill aspects:
- [Validation] All .cs files in scope were scanned (check count)
- [Validation] Report includes category totals, top patterns, and affected files
- [Validation] obj/ and bin/ directories were excluded
- [Pitfall] Scanning obj/ or generated code
- [Pitfall] Missing statics inside lambdas/LINQ
- [WorkflowStep] Step 4: Present the report

Three new scenarios with supporting fixtures:
- Structured report with file count, categories, and top patterns
- Exclude obj/bin directories (with Generated.cs decoy in obj/)
- Detect statics inside lambdas and LINQ expressions
2026-05-13 11:49:18 +00:00

197 lines
9.9 KiB
YAML

scenarios:
- name: "Identify static dependencies in a multi-class project"
prompt: |
I have a .NET project at StaticHeavy/ that I suspect has a lot of hard-to-test
static calls. Can you scan it and tell me what's making it hard to unit test?
setup:
files:
- path: "StaticHeavy/StaticHeavy.csproj"
source: "fixtures/static-heavy-project/StaticHeavy.csproj"
- path: "StaticHeavy/Program.cs"
source: "fixtures/static-heavy-project/Program.cs"
- path: "StaticHeavy/Services/OrderProcessor.cs"
source: "fixtures/static-heavy-project/Services/OrderProcessor.cs"
- path: "StaticHeavy/Services/NotificationService.cs"
source: "fixtures/static-heavy-project/Services/NotificationService.cs"
- path: "StaticHeavy/Services/ConfigLoader.cs"
source: "fixtures/static-heavy-project/Services/ConfigLoader.cs"
assertions:
- type: "output_matches"
pattern: "(DateTime\\.UtcNow|DateTime\\.Now)"
- type: "output_matches"
pattern: "(File\\.|file system|filesystem|IFileSystem)"
- type: "output_matches"
pattern: "(Environment\\.|environment variable)"
- type: "output_matches"
pattern: "(Console\\.|console)"
- type: "output_matches"
pattern: "(HttpClient|http client)"
- type: "exit_success"
rubric:
- "Identified DateTime.UtcNow and DateTime.Now as frequently used static dependencies"
- "Identified File.WriteAllText, File.ReadAllText, File.Exists, and File.AppendAllText as file system statics"
- "Identified Environment.GetEnvironmentVariable as environment static usage"
- "Identified Console.WriteLine as untestable console output"
- "Identified new HttpClient() as a hard-to-test network dependency"
- "Ranked or prioritized the static categories by frequency or migration ease"
- "Recommended a concrete next step such as wrapping the statics or adopting TimeProvider"
timeout: 120
- name: "Detect time-related statics and recommend TimeProvider"
prompt: |
My OrderProcessor.cs uses DateTime.UtcNow in several places and it's impossible
to write deterministic tests. Can you scan my entire project for all time-related
static dependencies, show me where each one is with file locations and counts,
and recommend how to make them testable?
setup:
files:
- path: "StaticHeavy/StaticHeavy.csproj"
source: "fixtures/static-heavy-project/StaticHeavy.csproj"
- path: "StaticHeavy/Program.cs"
source: "fixtures/static-heavy-project/Program.cs"
- path: "StaticHeavy/Services/OrderProcessor.cs"
source: "fixtures/static-heavy-project/Services/OrderProcessor.cs"
- path: "StaticHeavy/Services/NotificationService.cs"
source: "fixtures/static-heavy-project/Services/NotificationService.cs"
- path: "StaticHeavy/Services/ConfigLoader.cs"
source: "fixtures/static-heavy-project/Services/ConfigLoader.cs"
assertions:
- type: "output_matches"
pattern: "(DateTime\\.UtcNow|DateTime\\.Now)"
- type: "output_matches"
pattern: "(TimeProvider|time provider|ISystemClock|abstraction)"
- type: "output_matches"
pattern: "\\.cs"
- type: "output_matches"
pattern: "\\d+.*(call|site|occurrence|instance|usage|found|time)|([Cc]ount|[Tt]otal).*\\d+"
- type: "exit_success"
rubric:
- "Found all DateTime.UtcNow and DateTime.Now call sites across the project"
- "Identified specific files and locations containing time-related static dependencies"
- "Provided a count or summary of time-related static call sites"
- "Recommended TimeProvider or a similar abstraction as the replacement for .NET 8+"
- "Provided a migration plan or prioritized steps for replacing the time statics"
timeout: 120
- name: "Decline scan for non-C# project"
prompt: |
I have a Python Django project at my_app/ that has lots of datetime.now() calls.
Can you scan it for untestable statics?
expect_activation: false
setup:
files:
- path: "my_app/views.py"
content: |
from datetime import datetime
def index(request):
now = datetime.now()
return render(request, 'index.html', {'time': now})
assertions:
- type: "output_matches"
pattern: "(Python|not.*(C#|\\.NET)|different|unsupported)"
rubric:
- "Recognized that the project is Python, not C#/.NET"
- "Did not attempt to scan for .NET static patterns"
- "Suggested an alternative approach or clarified it only supports .NET"
timeout: 60
- name: "Verify structured report includes file count, categories, and top patterns"
prompt: |
I need to present a testability audit to my team lead. Can you scan the
StaticHeavy/ project and give me a full report? I need to know exactly how
many files were scanned, which categories of statics exist with their totals,
which patterns appear most often, and which files are the worst offenders.
setup:
files:
- path: "StaticHeavy/StaticHeavy.csproj"
source: "fixtures/static-heavy-project/StaticHeavy.csproj"
- path: "StaticHeavy/Program.cs"
source: "fixtures/static-heavy-project/Program.cs"
- path: "StaticHeavy/Services/OrderProcessor.cs"
source: "fixtures/static-heavy-project/Services/OrderProcessor.cs"
- path: "StaticHeavy/Services/NotificationService.cs"
source: "fixtures/static-heavy-project/Services/NotificationService.cs"
- path: "StaticHeavy/Services/ConfigLoader.cs"
source: "fixtures/static-heavy-project/Services/ConfigLoader.cs"
assertions:
- type: "output_matches"
pattern: "\\d+.*([Ff]iles?|scanned)|([Ff]iles?|[Ss]canned).*\\d+"
- type: "output_matches"
pattern: "([Cc]ategor(y|ies)|[Bb]reakdown|[Pp]er.category).*\\d+|\\d+.*(categor|breakdown)"
- type: "output_matches"
pattern: "(DateTime\\.UtcNow|DateTime\\.Now)"
- type: "output_matches"
pattern: "\\.cs"
- type: "exit_success"
rubric:
- "Report includes the number of .cs files that were scanned"
- "Report includes a per-category breakdown showing total call sites for each static category"
- "Report ranks or lists the most frequently occurring static dependency patterns"
- "Report identifies which source files have the most static dependencies"
- "Report is organized with clear sections that would be presentable to a team"
timeout: 300
- name: "Exclude obj and bin directories from the scan"
prompt: |
My ObjExclusion/ project seems to have a lot of statics but I want to know
what's in my actual source code, not build artifacts. Can you scan the source
files, skip obj/ and bin/ directories, and give me a report of all static
dependencies that need to be wrapped for testability?
setup:
files:
- path: "ObjExclusion/ObjExclusion.csproj"
source: "fixtures/obj-exclusion-project/ObjExclusion.csproj"
- path: "ObjExclusion/Program.cs"
source: "fixtures/obj-exclusion-project/Program.cs"
- path: "ObjExclusion/Services/DataService.cs"
source: "fixtures/obj-exclusion-project/Services/DataService.cs"
- path: "ObjExclusion/obj/Debug/net10.0/Generated.cs"
source: "fixtures/obj-exclusion-project/obj/Debug/net10.0/Generated.cs"
- path: "ObjExclusion/bin/Release/net10.0/AssemblyMetadata.cs"
source: "fixtures/obj-exclusion-project/bin/Release/net10.0/AssemblyMetadata.cs"
assertions:
- type: "output_matches"
pattern: "(DateTime|File\\.|Environment)"
- type: "output_not_matches"
pattern: "(GeneratedResourceAccessor|AssemblyMetadata|Process\\.(GetCurrentProcess|GetProcessesByName))"
- type: "output_matches"
pattern: "\\.cs"
- type: "exit_success"
rubric:
- "Only reported static dependencies found in production source code files"
- "Did not include statics from auto-generated code in obj/ or bin/ directories"
- "Correctly identified the static dependencies in DataService such as DateTime.UtcNow and File.WriteAllText"
- "Provided a structured summary or report of findings with categories or counts"
- "Recommended wrapping or abstracting the detected static dependencies"
timeout: 120
- name: "Detect statics inside lambda expressions and LINQ queries"
prompt: |
My ReportGenerator class in LambdaStatics/ uses a lot of LINQ and lambdas.
I'm worried there might be hidden static dependencies that would make it
impossible to unit test. Can you find all the statics in that project?
setup:
files:
- path: "LambdaStatics/LambdaStatics.csproj"
source: "fixtures/lambda-statics-project/LambdaStatics.csproj"
- path: "LambdaStatics/Program.cs"
source: "fixtures/lambda-statics-project/Program.cs"
- path: "LambdaStatics/Services/ReportGenerator.cs"
source: "fixtures/lambda-statics-project/Services/ReportGenerator.cs"
assertions:
- type: "output_matches"
pattern: "(DateTime\\.UtcNow|DateTime\\.Now)"
- type: "output_matches"
pattern: "(File\\.(Exists|ReadAllText|WriteAllText))"
- type: "output_matches"
pattern: "(Environment\\.|Directory\\.)"
- type: "output_matches"
pattern: "\\.cs"
- type: "exit_success"
rubric:
- "Found all DateTime.UtcNow and DateTime.Now call sites including those embedded in expression chains"
- "Found File.Exists and File.ReadAllText call sites even when used within method chains"
- "Found static calls inside callback or delegate assignments, not just direct method body calls"
- "Total count of detected static call sites covers all occurrences across the project"
timeout: 120