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

using System;

namespace {{ namespace }}
{
{{ self::summary_doc_block(enumeration.summary_doc, "    ") }}    public enum {{ enumeration.class_name }} : {{ enumeration.c_style_underlying_type() }}
    {
{%- for variant in enumeration.variants %}
{{ self::summary_doc_block(variant.summary_doc, "        ") }}        {{ variant.name }} = {{ variant.tag }}{% if !loop.last %},{% endif %}
{%- endfor %}
    }

    internal static class {{ enumeration.wire_class_name }}
    {
        internal const int WireEncodedSize = 4;

        internal static {{ enumeration.class_name }} Decode(WireReader reader) =>
            reader.ReadI32() switch
            {
{%- for variant in enumeration.variants %}
                {{ variant.wire_tag }} => {{ enumeration.class_name }}.{{ variant.name }},
{%- endfor %}
                int tag => throw new InvalidOperationException($"Unknown {{ enumeration.class_name }} wire tag: {tag}"),
            };

        internal static void WireEncodeTo(this {{ enumeration.class_name }} value, WireWriter wire) =>
            wire.WriteI32(value switch
            {
{%- for variant in enumeration.variants %}
                {{ enumeration.class_name }}.{{ variant.name }} => {{ variant.wire_tag }},
{%- endfor %}
                _ => throw new InvalidOperationException($"Unknown {{ enumeration.class_name }} variant: {value}"),
            });
    }
{%- if let Some(methods_class_name) = enumeration.methods_class_name.as_ref() %}

    public static class {{ methods_class_name }}
    {
{%- for method in enumeration.methods %}
{% include "render_csharp/value_type_method.txt" %}
{%- endfor %}
    }
{%- endif %}
{%- if enumeration.is_error %}

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