I think you will find that this is not a bug and the assert failure has nothing to do with MetaInformation.
You've probably not noticed (and I dont think its clearly described in doc anywhere obvious) but its enforced (asserted) that
a class instances fields (unless declared as being nillable) are not allowed to be nil at the end of the initializer.
(so that once inited the instance is in a known valid state)
This is what youre seeing.
The auto generating property code is generating backing variables for the properties - theres no explicit constructor/initializer being
given so a noArg noop constructor is generated( by the compiler) at the end of which the String backing variable (_name for property name) is nil
triggering the assert failure.
I.e you can see the same effect with this code that has nothing to do with metainfo
- Code: Select all
#cobra
class Show
pro showid from var as int # =0
pro name from var as String # = ''
pro displayName as String
get
return '[.showid] - [.name]'
def main is shared
s = Show()
This goes away if the properties are explicitly initialized since that puts the backing variables in a non nil state by the end of the Initializer.
So its doing what its supposed to - telling you that your class code initialization is incorrect
Secondly
Please if you post code describing something failing make sure its complete - That way its a quick cut and paste and compile to see what the problem is - if its easy to do that in one step its more likely that it will be done rapidly and the results examined and something intelligible can be said/provided about the problem.
None of the cobra code (fragments) you give below compiles (much less runs) because its
a) missing a main method
b) missing a reference to the XmlAttribute
(and possibly for ease of reproduction c) missing the compiler cmdline invocation used)
my first few stabs at correcting this actually worked fine since the code I made up wasnt instantiating Show ( I use an explicitly shared main)
so thats 4 extra compile/run cycles plus some doc lookup and associated fiddling about to perhaps poorly reproduce what you already knew/had but didnt describe.
Fortunately (for your feedback) its a slow night...