I am making a software in c#. I am using an abstract class, Instruction
, that has these bits of code:
protected Instruction(InstructionSet instr
You could pass in the real instruction into the base class constructor:
protected Instruction(..., Instruction realInstruction)
{
//Some stuff
if (DoesUseRealInstruction) {
RealInstruction = realInstruction;
}
}
public DerivedInstruction(...)
: base(..., GetRealInstruction(...))
{
}
Or, if you really want to call a virtual function from your constructor (which I highly discorage you from) you could suppress the ReSharper warning:
// ReSharper disable DoNotCallOverridableMethodsInConstructor
RealInstruction = GetRealInstruction(instructionSet, Argument);
// ReSharper restore DoNotCallOverridableMethodsInConstructor