-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add documentation for CA2026: Prefer JsonElement.Parse over JsonDocument.Parse().RootElement #49640
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 <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@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 pull request adds documentation for a new code analysis rule CA2026, which recommends using JsonElement.Parse() instead of JsonDocument.Parse().RootElement for better performance and resource management in .NET 10.
Key changes:
- Adds complete documentation for CA2026 rule with C# and VB examples.
- Updates the table of contents, rule index, and reliability warnings list to include CA2026.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/fundamentals/code-analysis/quality-rules/ca2026.md | New documentation file for CA2026 rule with examples and guidance |
| docs/navigate/tools-diagnostics/toc.yml | Adds CA2026 to the navigation table of contents |
| docs/fundamentals/code-analysis/quality-rules/reliability-warnings.md | Adds CA2026 to the reliability warnings table |
| docs/fundamentals/code-analysis/quality-rules/index.md | Adds CA2026 to the main quality rules index |
Comments suppressed due to low confidence (1)
docs/fundamentals/code-analysis/quality-rules/ca2026.md:1
- The
ms.topic: referencemetadata field is missing from the frontmatter. This field is present in similar rule documentation files (like ca2024.md and ca2025.md) and should be included for consistency.
---
BillWagner
left a comment
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.
Overall, this looks great. One comment.
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Adds missing documentation for CA2026, a .NET 10 performance analyzer that flags inefficient JSON parsing patterns.
Changes
ca2026.md): Explains whyJsonElement.Parse()is preferred overJsonDocument.Parse().RootElementin .NET 10+JsonDocumentimplementsIDisposableand rents fromArrayPool<byte>, requiring disposal to avoid memory leaksJsonElement.Parse()parses directly without allocation overhead or disposal requirementsperformance-warnings.mdandindex.mdsnippets/csharp/all-rules/ca2026.csandsnippets/vb/all-rules/ca2026.vbExample
Closes #49504
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews