public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { return(new CodeGeneratedMethod($"return {context.InputBufferVariableName}.{this.InputBufferReadMethodName}({context.OffsetVariableName});") { IsMethodInline = true, }); }
internal static string CreateParseBody( ITypeModel itemTypeModel, string createFlatBufferVector, ParserCodeGenContext context) { FlatSharpInternal.Assert(!string.IsNullOrEmpty(context.TableFieldContextVariableName), "expecting table field context"); if (context.Options.GreedyDeserialize) { string body = $"({createFlatBufferVector}).FlatBufferVectorToList()"; if (!context.Options.GenerateMutableObjects) { body += ".AsReadOnly()"; } return($"return {body};"); } else if (context.Options.Lazy) { return($"return {createFlatBufferVector};"); } else { FlatSharpInternal.Assert(context.Options.Progressive, "expecting progressive"); return($"return new FlatBufferProgressiveVector<{itemTypeModel.GetGlobalCompilableTypeName()}, {context.InputBufferTypeName}>({createFlatBufferVector});"); } }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { if (!context.Options.GreedyDeserialize) { throw new InvalidFlatBufferDefinitionException("Array vectors may only be used with Greedy serializers."); } var(classDef, className) = FlatBufferVectorHelpers.CreateFlatBufferVectorOfUnionSubclass( this.ItemTypeModel, context); FlatSharpInternal.Assert(!string.IsNullOrEmpty(context.TableFieldContextVariableName), "expecting table field context"); string createFlatBufferVector = $@"new {className}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName}.offset0 + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}.offset0), {context.OffsetVariableName}.offset1 + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}.offset1), {context.TableFieldContextVariableName})"; string body = $"return ({createFlatBufferVector}).ToArray();"; return(new CodeGeneratedMethod(body) { ClassDefinition = classDef }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { ValidateWriteThrough( writeThroughSupported: false, this, context.AllFieldContexts, context.Options); string method = nameof(InputBufferExtensions.ReadByteMemoryBlock); if (this.isReadOnly) { method = nameof(InputBufferExtensions.ReadByteReadOnlyMemoryBlock); } string memoryVectorRead = $"{context.InputBufferVariableName}.{method}({context.OffsetVariableName})"; string body; if (context.Options.GreedyDeserialize) { body = $"return {memoryVectorRead}.ToArray().AsMemory();"; } else { body = $"return {memoryVectorRead};"; } return(new CodeGeneratedMethod(body)); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { string method = nameof(InputBufferExtensions.ReadByteMemoryBlock); if (this.isReadOnly) { method = nameof(InputBufferExtensions.ReadByteReadOnlyMemoryBlock); } string memoryVectorRead = $"{context.InputBufferVariableName}.{method}({context.OffsetVariableName})"; string body; if (context.Options.GreedyDeserialize) { body = $"return {memoryVectorRead}.ToArray().AsMemory();"; } else { body = $"return {memoryVectorRead};"; } return(new CodeGeneratedMethod { MethodBody = body }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { return(new CodeGeneratedMethod { MethodBody = $"return {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadSharedString)}({context.OffsetVariableName});", }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { string body; string keyTypeName = CSharpHelpers.GetCompilableTypeName(this.keyTypeModel.ClrType); string valueTypeName = CSharpHelpers.GetCompilableTypeName(this.valueTypeModel.ClrType); (string vectorClassDef, string vectorClassName) = FlatBufferVectorHelpers.CreateFlatBufferVectorSubclass( this.valueTypeModel.ClrType, context.InputBufferTypeName, context.MethodNameMap[this.valueTypeModel.ClrType]); string createFlatBufferVector = $@"new {vectorClassName}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName} + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}), {this.PaddedMemberInlineSize})"; if (context.Options.PreallocateVectors) { // Eager indexed vector. string mutable = context.Options.GenerateMutableObjects.ToString().ToLowerInvariant(); body = $@"return new {nameof(IndexedVector<string, string>)}<{keyTypeName}, {valueTypeName}>({createFlatBufferVector}, {mutable});"; } else { // Lazy indexed vector. body = $@"return new {nameof(FlatBufferIndexedVector<string, string>)}<{keyTypeName}, {valueTypeName}>({createFlatBufferVector});"; } return(new CodeGeneratedMethod(body) { IsMethodInline = true, ClassDefinition = vectorClassDef }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { Type underlyingType = this.underlyingTypeModel.ClrType; string body = $"return ({this.GetCompilableTypeName()}){context.GetParseInvocation(underlyingType)};"; return(new CodeGeneratedMethod(body) { IsMethodInline = true, }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { string innerParse = context.GetParseInvocation(this.underlyingType); string body = $"return {innerParse};"; return(new CodeGeneratedMethod(body) { IsMethodInline = true, }); }
public override string CreateReadItemBody( ParserCodeGenContext context, string vtableVariableName) { context = context with { OffsetVariableName = $"{context.OffsetVariableName} + {this.Offset}", }; return($"return {context.GetParseInvocation(this.ItemTypeModel.ClrType)};"); }
public CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { // Parse buffer as underlying type name. string parseUnderlying = context.GetParseInvocation(typeof(TUnderlying)); string body = $"return {GetConvertFromUnderlyingInvocation(parseUnderlying)};"; return(new CodeGeneratedMethod(body) { IsMethodInline = true, }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { Type underlyingType = this.underlyingTypeModel.ClrType; string typeName = CSharpHelpers.GetCompilableTypeName(this.ClrType); return(new CodeGeneratedMethod { MethodBody = $"return ({typeName}){context.MethodNameMap[underlyingType]}({context.InputBufferVariableName}, {context.OffsetVariableName});", IsMethodInline = true, }); }
public static (string classDef, string className) CreateFlatBufferVectorSubclass( ITypeModel itemTypeModel, ParserCodeGenContext parseContext) { Type itemType = itemTypeModel.ClrType; string className = $"FlatBufferVector_{Guid.NewGuid():n}"; parseContext = parseContext with { InputBufferTypeName = "TInputBuffer", InputBufferVariableName = "memory", IsOffsetByRef = false, TableFieldContextVariableName = "fieldContext", }; var serializeContext = parseContext.GetWriteThroughContext("data", "item", "0"); string writeThroughBody = serializeContext.GetSerializeInvocation(itemType); if (itemTypeModel.SerializeMethodRequiresContext) { writeThroughBody = "throw new NotSupportedException(\"write through is not available for this type\")"; } string classDef = $@" public sealed class {className}<{parseContext.InputBufferTypeName}> : FlatBufferVector<{itemType.GetGlobalCompilableTypeName()}, {parseContext.InputBufferTypeName}> where {parseContext.InputBufferTypeName} : {nameof(IInputBuffer)} {{ public {className}( {parseContext.InputBufferTypeName} memory, int offset, int itemSize, {nameof(TableFieldContext)} fieldContext) : base(memory, offset, itemSize, fieldContext) {{ }} protected override void ParseItem( {parseContext.InputBufferTypeName} memory, int offset, {nameof(TableFieldContext)} fieldContext, out {itemType.GetGlobalCompilableTypeName()} item) {{ item = {parseContext.GetParseInvocation(itemType)}; }} protected override void WriteThrough({itemType.GetGlobalCompilableTypeName()} {serializeContext.ValueVariableName}, Span<byte> {serializeContext.SpanVariableName}) {{ {writeThroughBody}; }} }} "; return(classDef, className); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { string body; FlatSharpInternal.Assert(this.ItemTypeModel is not null, "Flatsharp internal error: ItemTypeModel null"); if (!context.Options.GreedyDeserialize) { throw new InvalidFlatBufferDefinitionException("Array vectors may only be used with Greedy serializers."); } ValidateWriteThrough( writeThroughSupported: false, this, context.AllFieldContexts, context.Options); (string vectorClassDef, string vectorClassName) = (string.Empty, string.Empty); if (this.ItemTypeModel.ClrType == typeof(byte)) { // can handle this as memory. string method = nameof(InputBufferExtensions.ReadByteReadOnlyMemoryBlock); string memoryVectorRead = $"{context.InputBufferVariableName}.{method}({context.OffsetVariableName})"; body = $"return {memoryVectorRead}.ToArray();"; } else { (vectorClassDef, vectorClassName) = FlatBufferVectorHelpers.CreateFlatBufferVectorSubclass( this.ItemTypeModel, context); FlatSharpInternal.Assert(!string.IsNullOrEmpty(context.TableFieldContextVariableName), "expecting table field context"); string createFlatBufferVector = $@"new {vectorClassName}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName} + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}), {this.PaddedMemberInlineSize}, {context.TableFieldContextVariableName})"; body = $"return ({createFlatBufferVector}).ToArray();"; } return(new CodeGeneratedMethod(body) { ClassDefinition = vectorClassDef }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { ValidateWriteThrough( writeThroughSupported: false, this, context.AllFieldContexts, context.Options); string body; string keyTypeName = CSharpHelpers.GetGlobalCompilableTypeName(this.keyTypeModel.ClrType); string valueTypeName = CSharpHelpers.GetGlobalCompilableTypeName(this.valueTypeModel.ClrType); (string vectorClassDef, string vectorClassName) = FlatBufferVectorHelpers.CreateFlatBufferVectorSubclass( this.valueTypeModel, context); FlatSharpInternal.Assert(!string.IsNullOrEmpty(context.TableFieldContextVariableName), "field context was null/empty"); string createFlatBufferVector = $@"new {vectorClassName}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName} + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}), {this.PaddedMemberInlineSize}, {context.TableFieldContextVariableName})"; string mutable = context.Options.GenerateMutableObjects.ToString().ToLowerInvariant(); if (context.Options.GreedyDeserialize) { // Eager indexed vector. body = $@"return new {nameof(IndexedVector<string, string>)}<{keyTypeName}, {valueTypeName}>({createFlatBufferVector}, {mutable});"; } else if (context.Options.Lazy) { // Lazy indexed vector. body = $@"return new {nameof(FlatBufferIndexedVector<string, string, IInputBuffer>)}<{keyTypeName}, {valueTypeName}, {context.InputBufferTypeName}>({createFlatBufferVector});"; } else { FlatSharpInternal.Assert(context.Options.Progressive, "expecting progressive"); body = $@"return new {nameof(FlatBufferProgressiveIndexedVector<string, string, IInputBuffer>)}<{keyTypeName}, {valueTypeName}, {context.InputBufferTypeName}>({createFlatBufferVector});"; } return(new CodeGeneratedMethod(body) { IsMethodInline = true, ClassDefinition = vectorClassDef }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { // We have to implement two items: The table class and the overall "read" method. // Let's start with the read method. string className = "structReader_" + Guid.NewGuid().ToString("n"); string classDefinition; // Implement the class { // Build up a list of property overrides. var propertyOverrides = new List <GeneratedProperty>(); for (int index = 0; index < this.Members.Count; ++index) { var value = this.Members[index]; PropertyInfo propertyInfo = value.PropertyInfo; Type propertyType = propertyInfo.PropertyType; GeneratedProperty generatedProperty = new GeneratedProperty(context.Options, index, propertyInfo); var propContext = context.With(offset: $"({context.OffsetVariableName} + {value.Offset})", inputBuffer: "buffer"); // These are always inline as they are only invoked from one place. generatedProperty.ReadValueMethodDefinition = $@" [MethodImpl(MethodImplOptions.AggressiveInlining)] private static {CSharpHelpers.GetCompilableTypeName(propertyType)} {generatedProperty.ReadValueMethodName}({context.InputBufferTypeName} buffer, int offset) {{ return {propContext.GetParseInvocation(propertyType)}; }} "; propertyOverrides.Add(generatedProperty); } classDefinition = CSharpHelpers.CreateDeserializeClass( className, this.ClrType, propertyOverrides, context.Options); } return(new CodeGeneratedMethod { ClassDefinition = classDefinition, MethodBody = $"return new {className}<{context.InputBufferTypeName}>({context.InputBufferVariableName}, {context.OffsetVariableName});", }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { string body; string keyTypeName = CSharpHelpers.GetCompilableTypeName(this.keyTypeModel.ClrType); string valueTypeName = CSharpHelpers.GetCompilableTypeName(this.valueTypeModel.ClrType); (string vectorClassDef, string vectorClassName) = FlatBufferVectorHelpers.CreateFlatBufferVectorSubclass( this.valueTypeModel.ClrType, context.InputBufferTypeName, context.MethodNameMap[this.valueTypeModel.ClrType]); (string dictionaryClassDef, string dictionaryClassName) = FlatBufferVectorHelpers.CreateFlatBufferDictionarySubclass( this.valueTypeModel.ClrType, this.keyTypeModel.ClrType, this.keyMemberModel.PropertyInfo.Name); string createFlatBufferVector = $@"new {vectorClassName}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName} + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}), {this.PaddedMemberInlineSize})"; string createDictionary = $@"new {dictionaryClassName}({createFlatBufferVector})"; if (context.Options.PreallocateVectors) { // We just call .ToDictionary() when in preallocate mode. Note that when full greedy mode is on, these items will be // greedily initialized as we traverse the list. Otherwise, they'll be allocated lazily. body = $"({createDictionary}).ToDictionary()"; if (!context.Options.GenerateMutableObjects) { // Finally, if we're not in the business of making mutable objects, then convert the list to read only. body = $"new System.Collections.ObjectModel.ReadOnlyDictionary<{keyTypeName}, {valueTypeName}>({body})"; } body = $"return {body};"; } else { body = $"return {createDictionary};"; } return(new CodeGeneratedMethod { MethodBody = body, IsMethodInline = true, ClassDefinition = string.Join("\r\n", vectorClassDef, dictionaryClassDef) }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { List <string> switchCases = new List <string>(); for (int i = 0; i < this.UnionElementTypeModel.Length; ++i) { var unionMember = this.UnionElementTypeModel[i]; int unionIndex = i + 1; string inlineAdjustment = string.Empty; if (unionMember.SerializesInline) { inlineAdjustment = $"offsetLocation += buffer.{nameof(InputBufferExtensions.ReadUOffset)}(offsetLocation);"; } var itemContext = context with { OffsetVariableName = "offsetLocation", IsOffsetByRef = false, }; string @case = $@" case {unionIndex}: {inlineAdjustment} return new {this.GetGlobalCompilableTypeName()}({itemContext.GetParseInvocation(unionMember.ClrType)}); "; switchCases.Add(@case); } string body = $@" byte discriminator = {context.InputBufferVariableName}.{nameof(IInputBuffer.ReadByte)}({context.OffsetVariableName}.offset0); int offsetLocation = {context.OffsetVariableName}.offset1; if (discriminator != 0 && offsetLocation == 0) throw new System.IO.InvalidDataException(""FlatBuffer union had discriminator set but no offset.""); switch (discriminator) {{ {string.Join("\r\n", switchCases)} default: throw new System.InvalidOperationException(""Exception parsing union '{this.GetCompilableTypeName()}'. Discriminator = "" + discriminator); }} "; return(new CodeGeneratedMethod(body)); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { string body; if (this.itemTypeModel is null) { throw new InvalidOperationException($"Flatsharp internal error: ItemTypeModel null"); } (string vectorClassDef, string vectorClassName) = (string.Empty, string.Empty); if (this.itemTypeModel.ClrType == typeof(byte)) { // can handle this as memory. string method = nameof(InputBufferExtensions.ReadByteMemoryBlock); if (this.ClrType == typeof(ReadOnlyMemory <byte>)) { method = nameof(InputBufferExtensions.ReadByteReadOnlyMemoryBlock); } string memoryVectorRead = $"{context.InputBufferVariableName}.{method}({context.OffsetVariableName})"; body = $"return {memoryVectorRead}.ToArray();"; } else { (vectorClassDef, vectorClassName) = FlatBufferVectorHelpers.CreateFlatBufferVectorSubclass( this.itemTypeModel.ClrType, context.InputBufferTypeName, context.MethodNameMap[this.itemTypeModel.ClrType]); string createFlatBufferVector = $@"new {vectorClassName}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName} + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}), {this.PaddedMemberInlineSize})"; body = $"return ({createFlatBufferVector}).ToArray();"; } return(new CodeGeneratedMethod(body) { ClassDefinition = vectorClassDef }); }
public static (string classDef, string className) CreateFlatBufferVectorOfUnionSubclass( ITypeModel typeModel, ParserCodeGenContext context) { string className = $"FlatBufferUnionVector_{Guid.NewGuid():n}"; context = context with { InputBufferTypeName = "TInputBuffer", InputBufferVariableName = "memory", IsOffsetByRef = true, TableFieldContextVariableName = "fieldContext", OffsetVariableName = "temp", }; string classDef = $@" public sealed class {className}<{context.InputBufferTypeName}> : FlatBufferVectorOfUnion<{typeModel.GetGlobalCompilableTypeName()}, {context.InputBufferTypeName}> where {context.InputBufferTypeName} : {nameof(IInputBuffer)} {{ public {className}( {context.InputBufferTypeName} memory, int discriminatorOffset, int offsetVectorOffset, {nameof(TableFieldContext)} fieldContext) : base(memory, discriminatorOffset, offsetVectorOffset, fieldContext) {{ }} protected override void ParseItem( {context.InputBufferTypeName} memory, int discriminatorOffset, int offsetOffset, {nameof(TableFieldContext)} {context.TableFieldContextVariableName}, out {typeModel.GetGlobalCompilableTypeName()} item) {{ var {context.OffsetVariableName} = (discriminatorOffset, offsetOffset); item = {context.GetParseInvocation(typeModel.ClrType)}; }} }} "; return(classDef, className); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { List <string> switchCases = new List <string>(); for (int i = 0; i < this.UnionElementTypeModel.Length; ++i) { var unionMember = this.UnionElementTypeModel[i]; int unionIndex = i + 1; string inlineAdjustment = string.Empty; if (unionMember.SerializesInline) { inlineAdjustment = $"offsetLocation += buffer.{nameof(InputBufferExtensions.ReadUOffset)}(offsetLocation);"; } string @case = $@" case {unionIndex}: {inlineAdjustment} return new {CSharpHelpers.GetCompilableTypeName(this.ClrType)}({context.MethodNameMap[unionMember.ClrType]}(buffer, offsetLocation)); "; switchCases.Add(@case); } string body = $@" byte discriminator = {context.InputBufferVariableName}.{nameof(IInputBuffer.ReadByte)}({context.OffsetVariableName}.offset0); int offsetLocation = {context.OffsetVariableName}.offset1; if (discriminator == 0 && offsetLocation != 0) throw new System.IO.InvalidDataException(""FlatBuffer union had discriminator set but no offset.""); switch (discriminator) {{ {string.Join("\r\n", switchCases)} default: return null; }} "; return(new CodeGeneratedMethod { MethodBody = body }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { var(classDef, className) = FlatBufferVectorHelpers.CreateFlatBufferVectorOfUnionSubclass( this.ItemTypeModel, context); string createFlatBufferVector = $@"new {className}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName}.offset0 + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}.offset0), {context.OffsetVariableName}.offset1 + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}.offset1), {context.TableFieldContextVariableName})"; return(new CodeGeneratedMethod(ListVectorTypeModel.CreateParseBody( this.ItemTypeModel, createFlatBufferVector, context)) { ClassDefinition = classDef }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { (string vectorClassDef, string vectorClassName) = FlatBufferVectorHelpers.CreateFlatBufferVectorSubclass( this.itemTypeModel.ClrType, context.InputBufferTypeName, context.MethodNameMap[this.itemTypeModel.ClrType]); string body; string createFlatBufferVector = $@"new {vectorClassName}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName} + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}), {this.PaddedMemberInlineSize})"; if (context.Options.PreallocateVectors) { // We just call .ToList(). Note that when full greedy mode is on, these items will be // greedily initialized as we traverse the list. Otherwise, they'll be allocated lazily. body = $"({createFlatBufferVector}).FlatBufferVectorToList()"; if (!context.Options.GenerateMutableObjects) { // Finally, if we're not in the business of making mutable objects, then convert the list to read only. body += ".AsReadOnly()"; } body = $"return {body};"; } else { body = $"return {createFlatBufferVector};"; } return(new CodeGeneratedMethod(body) { ClassDefinition = vectorClassDef }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { ValidateWriteThrough( writeThroughSupported: !this.isReadOnly, this, context.AllFieldContexts, context.Options); (string vectorClassDef, string vectorClassName) = FlatBufferVectorHelpers.CreateFlatBufferVectorSubclass( this.ItemTypeModel, context); string createFlatBufferVector = $@"new {vectorClassName}<{context.InputBufferTypeName}>( {context.InputBufferVariableName}, {context.OffsetVariableName} + {context.InputBufferVariableName}.{nameof(InputBufferExtensions.ReadUOffset)}({context.OffsetVariableName}), {this.PaddedMemberInlineSize}, {context.TableFieldContextVariableName})"; return(new CodeGeneratedMethod(CreateParseBody(this.ItemTypeModel, createFlatBufferVector, context)) { ClassDefinition = vectorClassDef }); }
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { // We have to implement two items: The table class and the overall "read" method. // Let's start with the read method. string className = "structReader_" + Guid.NewGuid().ToString("n"); DeserializeClassDefinition classDef = DeserializeClassDefinition.Create( className, this.onDeserializeMethod, this, -1, context.Options); // Build up a list of property overrides. for (int index = 0; index < this.Members.Count; ++index) { var value = this.Members[index]; classDef.AddProperty(value, context); } return(new CodeGeneratedMethod($"return {className}<{context.InputBufferTypeName}>.GetOrCreate({context.InputBufferVariableName}, {context.OffsetVariableName});") { ClassDefinition = classDef.ToString(), }); }
public abstract CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context);
public override CodeGeneratedMethod CreateParseMethodBody(ParserCodeGenContext context) { return(new CodeGeneratedMethod($"return {context.InputBufferVariableName}.{nameof(IInputBuffer.ReadString)}({context.OffsetVariableName});")); }