Issue
I have an abstract base class that has a Property on it that I would like to prevent both hiding, aka new, and override on.
public abstract class DomainObject
{
public bool IsDeleted { get; set; }
}
public class BankAccount : DomainObject
{
public bool IsDeleted { get; set; }
}
The issue is: I need BankAccount to inherit from the base DomainObject class, so I can't mark it as sealed, but I want to prevent the situation, an override or new, of IsDeleted at compile time.
Solution
I've had this same need for the same reason that you mentioned in comments: preventing issues caused by generated code. My solution was to make this specific warning an error, which can be done by adding "0108" to the "Project Properties" => "Build" => "Treat warnings as errors" => "Specific warnings" list.
I'd be curious to know why this was considered to be only a warning and not an error in the first place. Surely, it is some "brittle base class" situation that I haven't considered...
Answered By - MarkPflug Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.