.NET: Fix expensive logging#7268
Merged
Merged
Conversation
Avoid unnecessary structured logging argument evaluation when warning logging is disabled, resolving CA1873 in release builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0bc01e26-22ba-42ce-ac1e-6fe166500f4f
Align the no-progress warning with the repository-standard LoggerMessage source generator pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0bc01e26-22ba-42ce-ac1e-6fe166500f4f
alliscode
temporarily deployed
to
github-app-auth
July 22, 2026 20:03 — with
GitHub Actions
Inactive
alliscode
temporarily deployed
to
github-app-auth
July 22, 2026 20:03 — with
GitHub Actions
Inactive
alliscode
temporarily deployed
to
github-app-auth
July 22, 2026 20:03 — with
GitHub Actions
Inactive
alliscode
temporarily deployed
to
github-app-auth
July 22, 2026 20:04 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates .NET hosting workflow-resume diagnostics by replacing an inline LogWarning call with a source-generated, strongly-typed logging extension method, reducing per-call allocations and centralizing the message definition.
Changes:
- Replaced the inline warning in
WarnOnNoProgresswith a call to a source-generated logging method. - Added a
HostedWorkflowStateLogMessagesstatic partial class with a[LoggerMessage]-based extension method for the “resume made no progress” warning.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs | Switches “no progress on resume” warning to a source-generated [LoggerMessage] extension for more efficient logging. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
alliscode
temporarily deployed
to
github-app-auth
July 22, 2026 20:15 — with
GitHub Actions
Inactive
alliscode
temporarily deployed
to
github-app-auth
July 22, 2026 21:09 — with
GitHub Actions
Inactive
peibekwe
approved these changes
Jul 22, 2026
moonbox3
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors how warning logs are generated when a workflow session resumes but makes no progress. The main change is moving the logging logic from an inline message to a strongly-typed logging method using source generators, which improves maintainability and consistency.
Logging improvements:
UpdateCursorwith a call to a new strongly-typed logging method,LogWorkflowResumeMadeNoProgress, inHostedWorkflowState.cs.HostedWorkflowStateLogMessagesstatic partial class, defining theLogWorkflowResumeMadeNoProgressmethod using the[LoggerMessage]attribute for efficient and consistent logging.Description & Review Guide
Related Issue
Fixes #
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.