Meziantou.Framework.ObjectMethodExecutor 2.0.4

Prefix Reserved
dotnet add package Meziantou.Framework.ObjectMethodExecutor --version 2.0.4
                    
NuGet\Install-Package Meziantou.Framework.ObjectMethodExecutor -Version 2.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meziantou.Framework.ObjectMethodExecutor" Version="2.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Framework.ObjectMethodExecutor" Version="2.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.Framework.ObjectMethodExecutor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meziantou.Framework.ObjectMethodExecutor --version 2.0.4
                    
#r "nuget: Meziantou.Framework.ObjectMethodExecutor, 2.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meziantou.Framework.ObjectMethodExecutor@2.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meziantou.Framework.ObjectMethodExecutor&version=2.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.Framework.ObjectMethodExecutor&version=2.0.4
                    
Install as a Cake Tool

Meziantou.Framework.ObjectMethodExecutor

Allow to execute synchronous and asynchronous methods using reflection. ExecuteAsync support all methods returning an abject with a compatible GetAwaiter method.

public sealed class Sample
{
    public int Offset { get; init; }

    public async Task<int> AsyncMethod(int a, int b)
    {
        await Task.Yield();
        return Offset + a + b;
    }
}

Create an executor from the MethodInfo of the method, then call it:

var methodInfo = typeof(Sample).GetMethod(nameof(Sample.AsyncMethod))!;
var executor = ObjectMethodExecutor.Create(methodInfo);

var instance = new Sample { Offset = 10 };
var parameters = new object?[] { 1, 2 };
if (executor.IsMethodAsync)
{
    // You can call ExecuteAsync even if the underlying method is not async.
    // It returns an awaitable that completes with the return value of the method.
    var result = await executor.ExecuteAsync(instance, parameters);
    Assert.Equal(13, result);
}
else
{
    var result = executor.Execute(instance, parameters);
    Assert.Equal(13, result);
}
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net11.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.4 216 10/24/2026
2.0.3 121 10/21/2026
2.0.2 364 9/6/2026
2.0.1 145 8/29/2026
2.0.0 511 7/5/2026
1.0.9 321 6/13/2026
1.0.8 145 6/7/2026
1.0.7 965 1/18/2026
1.0.6 861 11/2/2025
1.0.5 805 9/3/2025
1.0.4 893 5/5/2025
1.0.3 180 3/1/2025
1.0.2 181 11/17/2024
1.0.1 332 11/15/2023
1.0.0 336 3/4/2023