C#


ROSLYN.DESIGN.CA1070 : Do not declare event fields as virtual (C#)

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

Summary

Do not declare virtual events in a base class. Overridden events in a derived class have undefined behavior. The C# compiler does not handle this correctly and it is unpredictable whether a subscriber to the derived event will actually be subscribing to the base class event.

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

Properties

Class Name Do not declare event fields as virtual (C#)
Significance reliability
Mnemonic ROSLYN.DESIGN.CA1070
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="Do not declare event fields as virtual (C#)"

Relevant Configuration File Parameters

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