ReSharper 2023.1 Help

Code Inspection: Base type is required

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: 08 March 2021