Skip to content

.NET: Fix IDE0039 by using local functions in samples - #7666

Merged
Roger Barreto (rogerbarreto) merged 1 commit into
microsoft:mainfrom
rogerbarreto:format-fix
Aug 14, 2026
Merged

.NET: Fix IDE0039 by using local functions in samples#7666
Roger Barreto (rogerbarreto) merged 1 commit into
microsoft:mainfrom
rogerbarreto:format-fix

Conversation

@rogerbarreto

@rogerbarreto Roger Barreto (rogerbarreto) commented Aug 14, 2026

Copy link
Copy Markdown
Member

Motivation & Context

dotnet format --verify-no-changes fails on three .NET samples with IDE0039 (prefer local function over lambda assigned to a Func<> variable). That breaks format CI for these sample projects.

Description & Review Guide

  • What are the major changes?
    Convert three lambda-to-Func<> assignments into local functions and update the call sites to pass the method group:
    • Agent_Step17_AdditionalAIContext calendar loader
    • AgentWithRAG_Step01_BasicTextRAG search adapter
    • AgentWithRAG_Step02_CustomVectorStoreRAG search adapter
  • What is the impact of these changes?
    Sample behavior is unchanged. Format/analyzer IDE0039 is satisfied.
  • What do you want reviewers to focus on?
    Confirm the local function signatures still match the expected delegates (Func<Task<string[]>> and Func<string, CancellationToken, Task<IEnumerable<TextSearchResult>>>).

Related Issue

No open issue. Small analyzer/format fix for sample code.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Replace Func lambda assignments with local functions so
dotnet format --verify-no-changes passes on the agent and RAG samples.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rogerbarreto
Roger Barreto (rogerbarreto) added this pull request to the merge queue Aug 14, 2026
Merged via the queue into microsoft:main with commit 12621e0 Aug 14, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants