Skip to content

Commit fdc7107

Browse files
alliscodeCopilot
andauthored
fix: resolve CA1873 in GitHubCopilotAgent by using LoggerMessage source generator (microsoft#6815)
Replace the direct logger.LogWarning() call (which eagerly evaluates string.Join()) with a [LoggerMessage]-generated extension method in GitHubCopilotAgentLogMessages.cs. Fixes build error: GitHubCopilotAgent.cs(580,13): error CA1873: Evaluation of this argument may be expensive and unnecessary if logging is disabled Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e59a31c commit fdc7107

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,13 @@ private AgentResponseUpdate ConvertToAgentResponseUpdate(SessionEvent sessionEve
577577
// Warn so the developer knows the ApprovalRequiredAIFunction marker(s) will not be automatically gated.
578578
if (sessionConfig.Hooks?.OnPreToolUse is not null)
579579
{
580-
logger.LogApprovalGatingSkippedDueToCustomHook(
581-
approvalRequiredToolNames.Count,
582-
string.Join(", ", approvalRequiredToolNames));
580+
if (logger.IsEnabled(LogLevel.Warning))
581+
{
582+
logger.LogApprovalGatingSkippedDueToCustomHook(
583+
approvalRequiredToolNames.Count,
584+
string.Join(", ", approvalRequiredToolNames));
585+
}
586+
583587
return sessionConfig;
584588
}
585589

0 commit comments

Comments
 (0)