Framework RecipesImplementation, failure path, check

ASP.NET Core: preserve requirements through advanced agent edits

Work through C# examples of real application boundaries: Authorize the loaded ASP.NET Core order before saving changes; Return a conflict when EF Core detects a stale order edit. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

Download the ASP.NET Core rule pack ZIP · Inspect the YAML rules

C#

Authorize the loaded ASP.NET Core order before saving changes

Authorize on the endpoint establishes broad access; an authorization handler over the loaded order establishes record-specific access. Ignoring the returned AuthorizationResult turns a policy invocation into a no-op.

Broken edit flagged · corrected edit passes

C#

Return a conflict when EF Core detects a stale order edit

A concurrency token lets EF put the expected row version into the UPDATE predicate. When another edit won, the application must return a conflict or explicitly resolve it, rather than tell the caller their old decision succeeded.

Broken edit flagged · corrected edit passes

Use a correction as a saved requirement

Choose the failure you need to prevent, add the scoped rule to your repository, and check both the broken and corrected implementation. Ask your agent to inspect the finding, repair the code and recheck the same rule. Keep framework tests beside the model check.

Perch keeps the requirement beside the code. Reuse the named check during the agent’s next edit and in CI, with cached answers free on unchanged requests.

Official ASP.NET Core documentation · All language and framework recipes