This project is read-only.
1
Vote

CComplexObject.DefaultValue throws an exception when encountering a generic class

description

With the provision that I might have misunderstood how the openEHR library is supposed to be used I have discovered what I believe to be an error in the code. After successfully loading an operational template from a file, e.g. blood pressure, I perform the following call to create the corresponding RMType:
 
var rmType = currentOpT.Definition.DefaultValue as RmType;
 
The call to DefaultValue throws an exception when it encounters a generic type, e.g. History. The error message is:
 
Cannot create an instance of OpenEhr.RM.DataStructures.History.History`1[T] because Type.ContainsGenericParameters is true.
 
The exception is thrown when the following line of code is executed:
 
object defaultValue = constructor.Invoke(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { } , null);
 
As an aside, people coming to the project are being recommended to take a look at the GastroS application. However, in that application we find the following comments in their RMFactory class:
 
/// Really a temporary class for generating default RM type values for
/// constraints
 
and
 
    /// A crude temporary replacement of CObject.DefaultValue(), since right now its
    /// implementation seems to be incomplete.
 
Clearly, things aren't working as expected in the openEHR library.

comments