private static MethodInfo LoadGenericDatumWriterMethod()

in src/DotPulsar/Schemas/AvroGenericRecordSchema.cs [225:250]


    private static MethodInfo LoadGenericDatumWriterMethod(IEnumerable<MethodInfo> methods)
    {
        const string name = "Write";
        const string secondParamFullname = "Avro.IO.Encoder";

        foreach (var method in methods)
        {
            if (method.Name != name || method.ReturnType != typeof(void))
                continue;

            var parameters = method.GetParameters();
            if (parameters.Length != 2)
                continue;

            var param1Fullname = parameters[1].ParameterType.FullName;
            if (param1Fullname is null)
                continue;

            if (parameters[0].ParameterType != typeof(T) || !param1Fullname.Equals(secondParamFullname))
                continue;

            return method;
        }

        throw new SchemaException($"A method with the name '{name}' matching the delegate was not found");
    }