C#


ROSLYN.RELIABILITY.CA2020 : Prevent behavioral change (C#)

See Roslyn-Detected C# Warning Classes for more information.

Summary

Some built-in operators added in .NET 7 behave differently when overflowing than did the corresponding user-defined operators in .NET 6 and earlier versions. Some operators that previously threw in an unchecked context now don't throw unless wrapped within a checked context. Also, some operators that did not previously throw in a checked context now throw unless wrapped in an unchecked context.

This check corresponds to Roslyn rule CA2020. For full rule details, see the Microsoft website: CA2020.

Properties

Class Name Prevent behavioral change (C#)
Significance reliability
Mnemonic ROSLYN.RELIABILITY.CA2020
Categories None
Availability Available for C# only.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Prevent behavioral change (C#)"

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.