ReSharper 2024.1 Help

Code Inspection: Base type is required

Category

Constraints Violations

ID

RequiredBaseTypesIsNotInherited

EditorConfig

resharper_required_base_types_is_not_inherited_highlighting

Default severity

Warning

Language

C#

Requires SWA

No

One of the ReSharper annotation attributes is the BaseTypeRequired attribute, which ensures that classes marked with this attribute derive from a specific class. Consider the snippet below:

[BaseTypeRequired(typeof(Soldier))] class FriendlyAttribute : Attribute { } class Soldier { } [Friendly] class Marine { }

In this snippet, the Marine class will generate a warning because the Friendly attribute it’s tagged with expects the class to be derived from Soldier. The following change fixes the problem:

[Friendly] class Marine : Soldier { }
Last modified: 15 April 2024