-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Type of issue
- Bug
- Enhancement
- Compliance
- Question
- Help wanted
Current Behavior
BaseEventState.MemberviseClone() throws exception.
Expected Behavior
call of MemberviseClone() on BaseEventState inheritor instances should creates deep clones.
Steps To Reproduce
Try to call MemberviseClone() on any AlarmState inheritor instance.
Environment
- OS: any
- Environment: any
- Runtime: any
- Nuget Version: 1.5.376.244
- Component: Opc.Ua.Core/Stack/State/Anything else?
BaseEventState and inheritors do not have parameterless constructor but have a constructor with argument "parent". MemberwiseClone() for them doesn't take into account required argument "parent" of their constructor.
Sample for NonExclusiveLimitAlarmState and BaseEventState:
the only consructors:
public NonExclusiveLimitAlarmState(NodeState parent) : base(parent) { }
public BaseEventState(NodeState parent) : base(parent) { }
MemberwiseClone() have incorrect implementations defined in BaseEventState:
public new object MemberwiseClone() { BaseEventState clone = (BaseEventState)Activator.CreateInstance(this.GetType()); return CloneChildren(clone); }
In the same time more correct implementation should be like in BaseObjectState:
public new object MemberwiseClone() { BaseObjectState clone = (BaseObjectState)Activator.CreateInstance(this.GetType(), this.Parent); return CloneChildren(clone); }
I do not understand why special (incorrect) implementation of MemberwiseClone() is needed for BaseEventState and why base implementation from BaseObjectState is not used instead...