Reflection: space in MetaData

Archives Forums/BlitzMax Bug Reports/Reflection: space in MetaData

fredborg(Posted 2008) [#1]
Hi,

If a space is present in a metadata string it won't show up during runtime:
Type TTypeA

	Field testA:Int {uiName="a thing"}	
	Field testB:Int {uiName="a_thing"}
	
EndType

Local obj:TTypeA = New TTypeA
Local t:TTypeId = TTypeId.ForObject(obj)

For Local f:TField = EachIn t.Fields()
	Print f.name()+", uiName=~q"+f.MetaData("uiName")+"~q"
Next
Replacing the space with an underscore as an example solves the problem.


fredborg(Posted 2008) [#2]
And a fix for reflection.bmx:
Function ExtractMetaData$( meta$,key$ )
	'not currently safe: , or = in metadata could stuff it up
	'should use a map
	If Not key Return meta
	key=" "+key+"="
	meta=" "+meta+" "
	Local i=meta.Tolower().Find( key.Tolower() )
	If i=-1 Return
	i:+key.length
	
	Local ret:String =meta[i..meta.Find( " ",i )]
	If ret.StartsWith( "~q" )
		ret = meta[i+1..meta.Find("~q",i+1)]
	EndIf
	Return ret
End Function