Visitar URL original
Implement coerce logic for net method binding by generalloki · Pull Request #2590 · pythonnet/pythonnet · GitHub
Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update MethodBinder.cs
  • Loading branch information
generalloki authored and filmor committed May 6, 2026
commit 64d06ab543ff4d5ba8d19bc00d10e9e64370af2c
16 changes: 16 additions & 0 deletions src/runtime/MethodBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ namespace Python.Runtime
{
using MaybeMethodBase = MaybeMethodBase<MethodBase>;

/// <summary>
/// Delegate for custom coercion logic during Python method binding.
/// </summary>
/// <param name="arguments">A dictionary containing the Python arguments passed to the method.</param>
/// <param name="methods">An array of method overloads being considered for binding.</param>
/// <param name="foundBinding">
/// A reference to the method that was successfully bound. This can be modified by the delegate
/// to override the default binding logic. The delegate can set this to null to disable the method call
/// and report an error.
/// </param>
public delegate void MethodBinderCoerceBindDelegate(
Dictionary<string, PyObject> arguments,
MethodBase[] methods,
Expand Down Expand Up @@ -1088,8 +1098,14 @@ static internal class ParameterInfoExtensions
}
}

/// <summary>
/// Provides events related to method binding in the MethodBinder class.
/// </summary>
public static class MethodBinderEvents
{
/// <summary>
/// Event triggered to allow custom coercion logic during method binding.
/// </summary>
public static MethodBinderCoerceBindDelegate? CoerceBind;
}
}