• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / FluentCommand / 26594173245

28 May 2026 06:28PM UTC coverage: 55.553% (+0.7%) from 54.902%
26594173245

push

github

pwelter34
Move JSON support, add docs and examples

1358 of 3215 branches covered (42.24%)

Branch coverage included in aggregate %.

103 of 234 new or added lines in 9 files covered. (44.02%)

371 existing lines in 26 files now uncovered.

4389 of 7130 relevant lines covered (61.56%)

312.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/FluentCommand/Reflection/MethodAccessor.cs
1
using System.Diagnostics;
2
using System.Reflection;
3

4
namespace FluentCommand.Reflection;
5

6
/// <summary>
7
/// Provides an accessor for <see cref="MethodInfo"/>, enabling efficient dynamic invocation of methods
8
/// and access to method metadata. Implements <see cref="IMethodAccessor"/> for late-bound method operations.
9
/// </summary>
10
[DebuggerDisplay("Name: {Name}")]
11
public class MethodAccessor : IMethodAccessor
12
{
13
    private readonly Lazy<Func<object?, object?[], object?>> _invoker;
14

15
    /// <summary>
16
    /// Initializes a new instance of the <see cref="MethodAccessor"/> class using the specified <see cref="MethodInfo"/>.
17
    /// </summary>
18
    /// <param name="methodInfo">The <see cref="MethodInfo"/> representing the method to access.</param>
19
    /// <exception cref="ArgumentNullException">Thrown if <paramref name="methodInfo"/> is <c>null</c>.</exception>
20
    public MethodAccessor(MethodInfo methodInfo)
×
21
    {
22
        ArgumentNullException.ThrowIfNull(methodInfo);
×
23

UNCOV
24
        MethodInfo = methodInfo;
×
25
        Name = methodInfo.Name;
×
26
        _invoker = new Lazy<Func<object?, object?[], object?>>(() => ExpressionFactory.CreateMethod(MethodInfo));
UNCOV
27
    }
×
28

29
    /// <summary>
30
    /// Gets the <see cref="MethodInfo"/> associated with this accessor.
31
    /// </summary>
32
    /// <value>The <see cref="MethodInfo"/> representing the method.</value>
33
    public MethodInfo MethodInfo { get; }
34

35
    /// <summary>
36
    /// Gets the name of the method.
37
    /// </summary>
38
    /// <value>The name of the method.</value>
39
    public string Name { get; }
40

41
    /// <summary>
42
    /// Invokes the method represented by this accessor on the specified <paramref name="instance"/> with the given arguments.
43
    /// </summary>
44
    /// <param name="instance">
45
    /// The object on which to invoke the method. For static methods, this argument is ignored and can be <c>null</c>.
46
    /// </param>
47
    /// <param name="arguments">An array of arguments to pass to the method.</param>
48
    /// <returns>
49
    /// An <see cref="object"/> containing the return value of the invoked method, or <c>null</c> for methods with <c>void</c> return type.
50
    /// </returns>
51
    /// <exception cref="ArgumentNullException">Thrown if required arguments are <c>null</c>.</exception>
52
    /// <exception cref="TargetParameterCountException">Thrown if the number of parameters in <paramref name="arguments"/> does not match the method signature.</exception>
53
    /// <exception cref="TargetInvocationException">Thrown if the invoked method throws an exception.</exception>
54
    public object? Invoke(object? instance, params object?[] arguments)
55
    {
UNCOV
56
        return _invoker.Value.Invoke(instance, arguments);
×
57
    }
58

59
    /// <summary>
60
    /// Gets a hash code key for the method using its name and parameter types.
61
    /// </summary>
62
    /// <param name="name">The name of the method.</param>
63
    /// <param name="parameterTypes">The method parameter types.</param>
64
    /// <returns>
65
    /// An integer representing the method key, suitable for use in hash-based collections.
66
    /// </returns>
67
    internal static int GetKey(string name, IEnumerable<Type> parameterTypes)
68
    {
UNCOV
69
        return Internal.HashCode.Seed
×
70
            .Combine(name)
×
71
            .CombineAll(parameterTypes);
×
72
    }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc