Skip to content

Commit 9e3c909

Browse files
authored
CA1822: Document MarshalByRefObject as an exception to the static-member rule (#52763)
1 parent 9e3b27e commit 9e3c909

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • docs/fundamentals/code-analysis/quality-rules

docs/fundamentals/code-analysis/quality-rules/ca1822.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
title: "CA1822: Mark members as static (code analysis)"
33
description: "Learn about code analysis rule CA1822: Mark members as static"
4-
ms.date: 11/04/2016
4+
ms.date: 03/30/2026
5+
ai-usage: ai-assisted
56
f1_keywords:
67
- MarkMembersAsStatic
78
- CA1822
@@ -41,7 +42,10 @@ Mark the member as static (or Shared in Visual Basic) or use 'this'/'Me' in the
4142

4243
## When to suppress warnings
4344

44-
It is safe to suppress a warning from this rule for previously shipped code for which the fix would be a breaking change.
45+
It's safe to suppress a warning from this rule in the following cases:
46+
47+
- For previously shipped code for which the fix would be a breaking change.
48+
- For methods in classes that inherit from <xref:System.MarshalByRefObject>. The methods in these classes shouldn't be marked as static, because the .NET remoting infrastructure uses instance dispatch to forward calls across AppDomain boundaries. Making such methods static can break remoting across AppDomain boundaries.
4549

4650
## Suppress a warning
4751

0 commit comments

Comments
 (0)