-
Notifications
You must be signed in to change notification settings - Fork 183
Fix clipboard GetData documentation to reflect NotSupportedException instead of null #2150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ad of null Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes documentation comments in code examples that incorrectly stated Clipboard.GetData() returns null when BinaryFormatter is unavailable. The actual behavior is that it returns a NotSupportedException instance.
- Updated 4 comment lines across C# and VB code example files
- Changes align with the main article documentation which correctly describes the exception return behavior
- All modifications are limited to comments only; no code logic was changed
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dotnet-desktop-guide/winforms/migration/snippets/clipboard-dataobject-net10/net/csharp/ObsoletePatterns.cs | Updated 2 comments to reflect that GetData() returns a NotSupportedException instance instead of null |
| dotnet-desktop-guide/winforms/migration/snippets/clipboard-dataobject-net10/net/vb/ObsoletePatterns.vb | Updated 2 comments to reflect that GetData() returns a NotSupportedException instance instead of null |
...-guide/winforms/migration/snippets/clipboard-dataobject-net10/net/csharp/ObsoletePatterns.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
...ktop-guide/winforms/migration/snippets/clipboard-dataobject-net10/net/vb/ObsoletePatterns.vb
Outdated
Show resolved
Hide resolved
Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
|
@BillWagner This is ready |
Summary
Code examples incorrectly documented that
Clipboard.GetData()returnsnullwhenBinaryFormatteris unavailable. The actual behavior returns aNotSupportedExceptioninstance. Additionally, the code examples were checking for null instead of validating the returned type.Changes
ObsoletePatterns.cs/vbto accurately reflect exception behaviorif (data != null)toif (data is Person person)using pattern matchingIf data IsNot Nothing ThentoIf TypeOf data Is Person ThenCTypetoDirectCastfor better performance after type validationExample
VB Example
This aligns the code examples with the main article documentation, which correctly states that
GetData()returns aNotSupportedExceptionwhenBinaryFormatteris required but not enabled, and ensures the code properly validates the type before using the data.Fixes #2146
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.