// <auto-generated>
// This file was generated by BoltFFI. Do not edit.
// </auto-generated>
#nullable enable

using System;
{%- if record.is_blittable %}
using System.Runtime.InteropServices;
{%- endif %}
{%- if record.has_pinned_params() %}
using System.Runtime.CompilerServices;
{%- endif %}
{%- if record.needs_system_text() %}
using System.Text;
{%- endif %}

namespace {{ namespace }}
{
{%- if record.is_blittable %}
    [StructLayout(LayoutKind.Sequential)]
{%- endif %}
{{ self::summary_doc_block(record.summary_doc, "    ") }}{{ self::param_doc_block(record.fields, "    ") }}    public readonly record struct {{ record.class_name }}(
{%- for field in record.fields %}
        {{ field.csharp_type }} {{ field.name }}{% if !loop.last %},{% endif %}
{%- endfor %}
    )
    {
        internal static {{ record.class_name }} Decode(WireReader reader) =>
            new {{ record.class_name }}(
{%- for field in record.fields %}
                {{ field.wire_decode_expr }}{% if !loop.last %},{% endif %}
{%- endfor %}
            );

        internal int WireEncodedSize() =>
{%- if record.is_empty() %}
            0;
{%- else %}
{%- for field in record.fields %}
            {{ field.wire_size_expr }}{% if !loop.last %} +{% else %};{% endif %}
{%- endfor %}
{%- endif %}

        internal void WireEncodeTo(WireWriter wire)
        {
{%- for field in record.fields %}
{%- for stmt in field.wire_encode_stmts %}
            {{ stmt }};
{%- endfor %}
{%- endfor %}
        }
{%- for method in record.methods %}
{% include "render_csharp/record_method.txt" %}
{%- endfor %}
    }
{%- if record.is_error %}

{%- let wrapped_name = record.class_name %}
{%- let message_expr = record.exception_message_expr() %}
{% include "render_csharp/typed_exception.txt" %}
{%- endif %}
}
