docs: fix non-compiling attachment examples in the .NET README - #2197
docs: fix non-compiling attachment examples in the .NET README#2197examon wants to merge 1 commit into
Conversation
The three attachment examples in dotnet/README.md referenced a type family that no longer exists in the SDK: UserMessageDataAttachmentsItem, UserMessageDataAttachmentsItemFile, UserMessageDataAttachmentsItemBlob and the enum UserMessageDataAttachmentsItemType. Copying any of them produced CS0246/CS0103, and because this README is packed as the package README it is also what renders on the GitHub.Copilot.SDK NuGet page. Update the examples to the shipped public API - List<Attachment> holding AttachmentFile and AttachmentBlob - matching the C# blocks in docs/features/image-input.md that documentation validation compiles. The explicit discriminator assignment in the file attachment example is dropped because the concrete subclass supplies it.
There was a problem hiding this comment.
Pull request overview
Updates the packaged .NET README to use the current attachment API, fixing examples reported in #2196.
Changes:
- Replaces removed attachment types with
Attachment,AttachmentFile, andAttachmentBlob. - Removes the obsolete explicit type discriminator.
Show a summary per file
| File | Description |
|---|---|
dotnet/README.md |
Corrects three attachment examples to compile against the public SDK API. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
Cross-SDK Consistency Review ✅This PR makes a documentation-only fix to No cross-SDK consistency concerns:
No action required in other SDK implementations.
|
|
Thank you for identifying this. The reported documentation defect and the proposed corrections are valid. PR #2208 supersedes this PR by fixing the same README examples along with the adjacent invalid |
Fixes #2196
Problem
The three attachment examples in
dotnet/README.mdreference a type family that is no longer in the SDK -UserMessageDataAttachmentsItem,UserMessageDataAttachmentsItemFile,UserMessageDataAttachmentsItemBlob, and the enumUserMessageDataAttachmentsItemType. Copying any of them yieldsCS0246/CS0103.This file is packed as the package README, so it is also the
GitHub.Copilot.SDKNuGet page. The published1.0.8package ships these broken snippets today.Attachments moved to a polymorphic model and the types were later renamed to
Attachment*. The feature guide underdocs/was updated; this README was not, and documentation validation never compiles it because extraction is scoped to thedocs/directory (scripts/docs-validation/extract.tsresolvesDOCS_DIRtodocsand globs**/*.mdrelative to it).Fix
Update the three examples to the shipped public API, aligning them with the C# blocks in
docs/features/image-input.mdthat documentation validation already compiles:new List<UserMessageDataAttachmentsItem>becomesnew List<Attachment>new UserMessageDataAttachmentsItemFilebecomesnew AttachmentFilenew UserMessageDataAttachmentsItemBlobbecomesnew AttachmentBlob### File Attachments, the base type plusType = UserMessageDataAttachmentsItemType.Filebecomesnew AttachmentFile, and the discriminator assignment is droppedProperty sets are unchanged:
AttachmentFilerequiresPathandDisplayName, both already present, andAttachmentBlobrequiresMimeType, also already present.The discriminator line is removed rather than translated because the concrete subclass already carries it.
AttachmentFile.Typeis a get-only override that always returns"file"and is[JsonIgnore]d; the wire discriminator is emitted from[JsonPolymorphic]/[JsonDerivedType]. An explicit assignment would compile but be silently ignored, which is worse than not showing it.Markdown only - no source, public API, schema, generated file, or codegen template is touched.
Verification
The examples were extracted from the README programmatically (not retyped) and compiled before and after:
Before, against published
1.0.8:After:
Green against both a local build of this branch and the published
1.0.8package, onnetstandard2.0,net8.0andnet10.0. The complete## Image Supportfence also compiles as a single paste. RemovingDisplayNamefrom the corrected file example fails withCS9035, confirming the required-member check is live rather than vacuous.Also verified: zero remaining occurrences of the old names in
dotnet/README.md; the markdown token stream is unchanged apart from the one deleted line;dotnet format --verify-no-changespasses; and documentation validation still passes (55 C# files).Round-tripping the corrected initializers through the real serializer gives
{"type":"file",...}and{"type":"blob",...}and deserializes back toAttachmentFile/AttachmentBlob, confirming the dropped discriminator is supplied by the concrete type.Scope
Deliberately limited to
dotnet/README.mdto keep this markdown-only.dotnet/src/Session.cshas a related but distinct defect in theSendAsyncXML<example>:new()inside aList<Attachment>initializer target-types to the baseAttachment, which has noPath(CS0117), and it omits the requiredDisplayName. It uses current type names, so it is a different bug from the stale names fixed here. Happy to follow up on it, or on widening documentation validation to cover the per-binding READMEs, in separate PRs.