Repository navigation
[dotnet-port-api] Add message.Source.String formatter - #1320
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
API consistency review
Changed Go contractNew exported method Upstream evidence reviewed
AssessmentGo output matches .NET formatting, including the
|
There was a problem hiding this comment.
🟢 Approval recommended
The small, self-contained implementation matches the documented behavior, with all formatting branches covered and no identified blocking issues.
No open issues 🎉
What changed in this PR
Adds message.Source.String() to provide a readable source attribution format aligned with the .NET formatter.
Changes:
- Returns
<type>or<type>:<id>, usingExternalfor the zero source type. - Adds tests covering empty and populated IDs for external and custom source types.
| File | Description |
|---|---|
message/message.go |
Implements and documents the source formatter. |
message/message_test.go |
Tests all formatting branches. |
Review effort: Balanced
Summary
Adds
message.Source.String()returning<type>or<type>:<id>, withExternalfor the zero source type, mirroring .NETAgentRequestMessageSourceAttribution.ToString()/AgentRequestMessageSourceType.ToString().Ported .NET PRs
None.
Breaking Changes
None.
Sourcegains afmt.Stringermethod, so%vformatting of aSourcenow prints the string form instead of the struct fields.Tests and Examples
Added
TestSource_Stringinmessage/message_test.go. Rangofmt,go test ./message/andgo build ./..., all clean. No example changes.Notes
0c9944cc9f577d51277ac7c55dbc388b60a577af. Source:dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRequestMessageSourceAttribution.csandAgentRequestMessageSourceType.cs.Microsoft.Agents.AI/AgentRequestMessageSourceAttribution.ToString() -> string(unmapped). Expected assessment after merge: mapped/adapted tomessage.Source.String.GetHashCodeis intentionally not ported because GoSourceis comparable.