// This file contains adapter bridges that wrap user trait implementations and delegate to the plugin interface.
#nullable enable
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace {{ namespace }};
// MARK: - Internal stub adapters
//
// Each adapter sealed class conforms to the bridge interface `I{TraitName}` by delegating to
// a user-provided implementation instance. The adapter exposes itself to the Rust side via
// P/Invoke as the handle parameter, allowing e2e tests and user code to register implementations.
//
// Adapter stub names (returned by Name property):
{% for trait in traits -%}
// - _{{ trait.pascal_name }}BridgeAdapter → "csharp-bridge-{{ trait.snake_name }}-adapter"
{% endfor %}
//
// These names are used by e2e test cleanup to unregister adapters after each test.
{% for trait in traits %}
/// <summary>
/// Adapter bridge for {{ trait.pascal_name }} trait implementation.
/// Wraps a user-provided I{{ trait.pascal_name }} implementation and delegates all method calls.
/// </summary>
public sealed class _{{ trait.pascal_name }}BridgeAdapter : I{{ trait.pascal_name }}
{
private readonly I{{ trait.pascal_name }} _impl;
/// <summary>Create an adapter around a user-provided {{ trait.pascal_name }} implementation.</summary>
public _{{ trait.pascal_name }}BridgeAdapter(I{{ trait.pascal_name }} impl)
{
_impl = impl ?? throw new ArgumentNullException(nameof(impl));
}
// MARK: - Plugin lifecycle (if present)
{% if trait.has_super_trait %}
/// <summary>Get the plugin name.</summary>
public string Name => _impl.Name;
/// <summary>Get the plugin version.</summary>
public string Version => _impl.Version;
/// <summary>Initialize the plugin.</summary>
public void Initialize() => _impl.Initialize();
/// <summary>Shut down the plugin.</summary>
public void Shutdown() => _impl.Shutdown();
{% endif %}
// MARK: - Trait methods
{% for method in trait.methods %}
/// <summary>{{ method.name }}</summary>
{% if method.is_property %}
public {{ method.return_type }} {{ method.pascal_name }} => _impl.{{ method.pascal_name }};
{% elif method.is_void_return %}
public void {{ method.pascal_name }}({{ method.params_sig }})
{
_impl.{{ method.pascal_name }}({{ method.params_pass }});
}
{% else %}
public {{ method.return_type }} {{ method.pascal_name }}({{ method.params_sig }})
{
return _impl.{{ method.pascal_name }}({{ method.params_pass }});
}
{% endif %}
{% endfor %}
}
{% endfor %}