.NET: Fix IDE0039 by using local functions in samples - #7666
Conversation
Replace Func lambda assignments with local functions so dotnet format --verify-no-changes passes on the agent and RAG samples.
There was a problem hiding this comment.
Pull request overview
Converts three sample delegates to local functions, resolving IDE0039 without changing behavior.
Changes:
- Replaced calendar and RAG adapter lambdas with async local functions.
- Updated provider call sites to pass the corresponding method groups.
- Confirmed signatures match expected delegate types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
AgentWithRAG_Step02_CustomVectorStoreRAG/Program.cs |
Converts the custom vector search adapter. |
AgentWithRAG_Step01_BasicTextRAG/Program.cs |
Converts the basic text search adapter. |
Agent_Step17_AdditionalAIContext/Program.cs |
Converts the calendar event loader. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): 1936346f6b88
Model: gpt-5.6-sol
Overview
This PR replaces three delegate-valued lambdas with signature-equivalent local functions while preserving the same method-group call sites, captured state, cancellation propagation, and async behavior. Compiler-enforced delegate conversion, existing provider tests using the same pattern, and unchanged resource ownership and state boundaries prevent a publishable concern.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
dotnet format --verify-no-changesfails on three .NET samples with IDE0039 (prefer local function over lambda assigned to aFunc<>variable). That breaks format CI for these sample projects.Description & Review Guide
Convert three lambda-to-
Func<>assignments into local functions and update the call sites to pass the method group:Agent_Step17_AdditionalAIContextcalendar loaderAgentWithRAG_Step01_BasicTextRAGsearch adapterAgentWithRAG_Step02_CustomVectorStoreRAGsearch adapterSample behavior is unchanged. Format/analyzer IDE0039 is satisfied.
Confirm the local function signatures still match the expected delegates (
Func<Task<string[]>>andFunc<string, CancellationToken, Task<IEnumerable<TextSearchResult>>>).Related Issue
No open issue. Small analyzer/format fix for sample code.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.