diff options
Diffstat (limited to 'src/idl_gen_general.cpp')
-rw-r--r-- | src/idl_gen_general.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/idl_gen_general.cpp b/src/idl_gen_general.cpp index eda0214d..f3ed3e4f 100644 --- a/src/idl_gen_general.cpp +++ b/src/idl_gen_general.cpp @@ -1113,12 +1113,21 @@ class GeneralGenerator : public BaseGenerator { code += "); }\n"; break; case IDLOptions::kCSharp: + code += "#if ENABLE_SPAN_T\n"; + code += " public Span<byte> Get"; + code += MakeCamel(field.name, lang_.first_camel_upper); + code += "Bytes() { return "; + code += lang_.accessor_prefix + "__vector_as_span("; + code += NumToString(field.value.offset); + code += "); }\n"; + code += "#else\n"; code += " public ArraySegment<byte>? Get"; code += MakeCamel(field.name, lang_.first_camel_upper); code += "Bytes() { return "; code += lang_.accessor_prefix + "__vector_as_arraysegment("; code += NumToString(field.value.offset); code += "); }\n"; + code += "#endif\n"; // For direct blockcopying the data into a typed array code += " public "; |