@@ -171,10 +171,14 @@ private static void WriteClass(IndentedTextWriter writer, ClassNode @class, ILog
171171 . WhereNot ( n => n is FunctionNode || n is BaseHexNode ) ;
172172 foreach ( var node in nodes )
173173 {
174- var type = GetTypeDefinition ( node ) ;
174+ var ( type , attribute ) = GetTypeDefinition ( node ) ;
175175 if ( type != null )
176176 {
177177 writer . WriteLine ( $ "[FieldOffset(0x{ node . Offset : X} )]") ;
178+ if ( attribute != null )
179+ {
180+ writer . WriteLine ( attribute ) ;
181+ }
178182 writer . Write ( $ "public readonly { type } { node . Name } ;") ;
179183 if ( ! string . IsNullOrEmpty ( node . Comment ) )
180184 {
@@ -198,7 +202,7 @@ private static void WriteClass(IndentedTextWriter writer, ClassNode @class, ILog
198202 /// </summary>
199203 /// <param name="node">The target node.</param>
200204 /// <returns>The type definition for the node or null if no simple type is available.</returns>
201- private static string GetTypeDefinition ( BaseNode node )
205+ private static ( string typeName , string attribute ) GetTypeDefinition ( BaseNode node )
202206 {
203207 Contract . Requires ( node != null ) ;
204208
@@ -211,15 +215,20 @@ private static string GetTypeDefinition(BaseNode node)
211215
212216 if ( nodeTypeToTypeDefinationMap . TryGetValue ( node . GetType ( ) , out var type ) )
213217 {
214- return type ;
218+ return ( type , null ) ;
215219 }
216220
217221 if ( node is EnumNode enumNode )
218222 {
219- return enumNode . Enum . Name ;
223+ return ( enumNode . Enum . Name , null ) ;
224+ }
225+
226+ if ( node is Utf8TextNode utf8TextNode )
227+ {
228+ return ( "string" , $ "[MarshalAs(UnmanagedType.ByValTStr, SizeConst = { utf8TextNode . Length } )]") ;
220229 }
221230
222- return null ;
231+ return ( null , null ) ;
223232 }
224233 }
225234}
0 commit comments