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

loresoft / FluentCommand / 23278216331

19 Mar 2026 03:19AM UTC coverage: 57.398% (+0.7%) from 56.658%
23278216331

push

github

pwelter34
Enable nullable and improve source generators

1403 of 3069 branches covered (45.72%)

Branch coverage included in aggregate %.

527 of 907 new or added lines in 58 files covered. (58.1%)

22 existing lines in 10 files now uncovered.

4288 of 6846 relevant lines covered (62.64%)

330.58 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
        if (methodInfo == null)
×
23
            throw new ArgumentNullException(nameof(methodInfo));
×
24

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

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

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

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

60
    /// <summary>
61
    /// Gets a hash code key for the method using its name and parameter types.
62
    /// </summary>
63
    /// <param name="name">The name of the method.</param>
64
    /// <param name="parameterTypes">The method parameter types.</param>
65
    /// <returns>
66
    /// An integer representing the method key, suitable for use in hash-based collections.
67
    /// </returns>
68
    internal static int GetKey(string name, IEnumerable<Type> parameterTypes)
69
    {
70
        return Internal.HashCode.Seed
×
71
            .Combine(name)
×
72
            .CombineAll(parameterTypes);
×
73
    }
74
}
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