@@ -171,10 +171,14 @@ private static void WriteClass(IndentedTextWriter writer, ClassNode @class, ILog
171
171
. WhereNot ( n => n is FunctionNode || n is BaseHexNode ) ;
172
172
foreach ( var node in nodes )
173
173
{
174
- var type = GetTypeDefinition ( node ) ;
174
+ var ( type , attribute ) = GetTypeDefinition ( node ) ;
175
175
if ( type != null )
176
176
{
177
177
writer . WriteLine ( $ "[FieldOffset(0x{ node . Offset : X} )]") ;
178
+ if ( attribute != null )
179
+ {
180
+ writer . WriteLine ( attribute ) ;
181
+ }
178
182
writer . Write ( $ "public readonly { type } { node . Name } ;") ;
179
183
if ( ! string . IsNullOrEmpty ( node . Comment ) )
180
184
{
@@ -198,7 +202,7 @@ private static void WriteClass(IndentedTextWriter writer, ClassNode @class, ILog
198
202
/// </summary>
199
203
/// <param name="node">The target node.</param>
200
204
/// <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 )
202
206
{
203
207
Contract . Requires ( node != null ) ;
204
208
@@ -211,15 +215,20 @@ private static string GetTypeDefinition(BaseNode node)
211
215
212
216
if ( nodeTypeToTypeDefinationMap . TryGetValue ( node . GetType ( ) , out var type ) )
213
217
{
214
- return type ;
218
+ return ( type , null ) ;
215
219
}
216
220
217
221
if ( node is EnumNode enumNode )
218
222
{
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 } )]") ;
220
229
}
221
230
222
- return null ;
231
+ return ( null , null ) ;
223
232
}
224
233
}
225
234
}
0 commit comments