Skip to content

CA1822: Document MarshalByRefObject as an exception to the static-member rule#52763

Merged
gewarren merged 2 commits into
mainfrom
copilot/fix-static-methods-in-marshalbyrefobject
Mar 31, 2026
Merged

CA1822: Document MarshalByRefObject as an exception to the static-member rule#52763
gewarren merged 2 commits into
mainfrom
copilot/fix-static-methods-in-marshalbyrefobject

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

The CA1822 docs didn't mention that methods on classes inheriting from MarshalByRefObject should not be marked static — the remoting infrastructure relies on instance dispatch across AppDomain boundaries, so static methods break that contract.

Changes

  • ca1822.md — "When to suppress warnings": Converted the single-sentence paragraph into a bullet list and added a new entry for MarshalByRefObject subclasses, with a <xref:System.MarshalByRefObject> cross-reference link and a brief explanation of why static breaks remoting.
  • Updated ms.date to reflect the content change.
  • Added ai-usage: ai-assisted per documentation guidelines.

Internal previews

📄 File 🔗 Preview link
docs/fundamentals/code-analysis/quality-rules/ca1822.md docs/fundamentals/code-analysis/quality-rules/ca1822

Copilot AI changed the title [WIP] Fix static methods on MarshalByRefObject inheritance CA1822: Document MarshalByRefObject as an exception to the static-member rule Mar 30, 2026
Copilot AI requested a review from BillWagner March 30, 2026 13:00
Copy link
Copy Markdown
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready for final review.

@BillWagner BillWagner marked this pull request as ready for review March 31, 2026 15:10
@BillWagner BillWagner requested review from a team and gewarren as code owners March 31, 2026 15:10
Copilot AI review requested due to automatic review settings March 31, 2026 15:11
@gewarren gewarren merged commit 9e3c909 into main Mar 31, 2026
18 checks passed
@gewarren gewarren deleted the copilot/fix-static-methods-in-marshalbyrefobject branch March 31, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Methods on classes that inherit from MarshalByRefObject should not be marked as static

3 participants