-
Couldn't load subscription status.
- Fork 6.1k
Document CA2208 paramName requirement and provide guidance for non-parameter exceptions #49444
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
Co-authored-by: gewarren <[email protected]>
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.
@copilot please don't use the names "Foo" and "Bar" for the type and property.
Co-authored-by: gewarren <[email protected]>
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 updates the CA2208 documentation to clarify that ArgumentNullException requires the paramName argument to match an actual method parameter. The documentation previously explained common mistakes like mixing up message and parameter name arguments, but didn't explicitly state the requirement that paramName must match a method parameter. The PR also provides guidance on using InvalidOperationException when validating non-parameter variables.
Key changes:
- Clarified the
paramNamematching requirement in the "Cause" section. - Added code examples demonstrating incorrect usage with local variables and the correct fix using
InvalidOperationException. - Updated the ms.date to the current date.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ca2208.md | Added documentation explaining paramName requirement, added new code examples (snippet3 and snippet4), and updated date |
| ca2208.cs | Added C# code examples showing violation with local variable and fix using InvalidOperationException |
| ca2208-instantiate-argument-exceptions-correctly_1.vb | Added VB code examples showing violation with local variable and fix using InvalidOperationException |
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.
This LGTM @gewarren
Let's ![]()
Update CA2208 documentation to clarify paramName requirement
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Internal previews