Problem with generics in auto-generated code (.NET)
Posted: 28 Aug 2017, 17:24
Hi,
I am generating .NET code from modeller.
The generic type of RelativeLocation VariableType below should be compatible with its super type that is not generic.
Therefore T should get a constraint of being a vector or a subtype of vector (see in red).
The red part of code is not generated automatically and causes compilation problems and inconsistency.
/// <summary>
/// A typed object which represents a RelativeLocation.
/// </summary>
public partial class RelativeLocation<T> : RelativeLocation where T : Vector
{
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>
/// The value.
/// </value>
[UaInstanceDeclaration(IsValue = true, NamespaceUri = IRIS.DDHub.Namespaces.DDHub)]
public new T Value
{
get { return (T)((base.Value)??default(T)); }
set { base.Value = value; }
}
}
I am generating .NET code from modeller.
The generic type of RelativeLocation VariableType below should be compatible with its super type that is not generic.
Therefore T should get a constraint of being a vector or a subtype of vector (see in red).
The red part of code is not generated automatically and causes compilation problems and inconsistency.
/// <summary>
/// A typed object which represents a RelativeLocation.
/// </summary>
public partial class RelativeLocation<T> : RelativeLocation where T : Vector
{
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>
/// The value.
/// </value>
[UaInstanceDeclaration(IsValue = true, NamespaceUri = IRIS.DDHub.Namespaces.DDHub)]
public new T Value
{
get { return (T)((base.Value)??default(T)); }
set { base.Value = value; }
}
}