Skip to content

Commit b8e08ff

Browse files
committed
add obsolete note
1 parent dc4fa5e commit b8e08ff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/code-quality/ca2104-do-not-declare-read-only-mutable-reference-types.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,20 @@ ms.workload:
3030
|Category|Microsoft.Security|
3131
|Breaking Change|Non-breaking|
3232

33+
> [!NOTE]
34+
> Rule CA2104 is obsolete and will be removed in a future version of Visual Studio.
35+
3336
## Cause
3437

35-
An externally visible type contains an externally visible read-only field that is possibly a mutable reference type.
38+
An externally visible type contains an externally visible read-only field that is a mutable reference type.
3639

3740
## Rule description
3841

3942
A mutable type is a type whose instance data can be modified. The <xref:System.Text.StringBuilder?displayProperty=fullName> class is an example of a mutable reference type. It contains members that can change the value of an instance of the class. An example of an immutable reference type is the <xref:System.String?displayProperty=fullName> class. After it has been instantiated, its value can never change.
4043

4144
The read-only modifier ([readonly](/dotnet/csharp/language-reference/keywords/readonly) in C#, [ReadOnly](/dotnet/visual-basic/language-reference/modifiers/readonly) in Visual Basic, and [const](/cpp/cpp/const-cpp) in C++) on a reference type field (or pointer in C++) prevents the field from being replaced by a different instance of the reference type. However, the modifier does not prevent the instance data of the field from being modified through the reference type.
4245

43-
This rule may inadvertently show a violation for a type that is, in fact, immutable. In that case, it is safe to suppress this rule. The rule checks the type against a finite list of types that are known to have immutable semantics, and it considers anything else mutable.
46+
This rule may inadvertently show a violation for a type that is, in fact, immutable. In that case, it is safe to suppress this rule.
4447

4548
Read-only array fields are exempt from this rule but instead cause a violation of the [CA2105: Array fields should not be read only](../code-quality/ca2105-array-fields-should-not-be-read-only.md) rule.
4649

0 commit comments

Comments
 (0)