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

loresoft / EntityChange / 13417967502

19 Feb 2025 04:51PM UTC coverage: 45.43% (+5.7%) from 39.697%
13417967502

push

github

pwelter34
fix failing test

287 of 726 branches covered (39.53%)

Branch coverage included in aggregate %.

563 of 1145 relevant lines covered (49.17%)

73.33 hits per line

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

0.0
/src/EntityChange/Reflection/MethodAccessor.cs
1
#nullable disable
2

3
using System.Diagnostics;
4
using System.Reflection;
5

6
namespace EntityChange.Reflection;
7

8
/// <summary>
9
/// An accessor class for <see cref="MethodInfo"/>.
10
/// </summary>
11
[DebuggerDisplay("Name: {Name}")]
12
public class MethodAccessor : IMethodAccessor
13
{
14
    private readonly Lazy<Func<object, object[], object>> _invoker;
15

16
    /// <summary>
17
    /// Initializes a new instance of the <see cref="MethodAccessor"/> class.
18
    /// </summary>
19
    /// <param name="methodInfo">The method info.</param>
20
    public MethodAccessor(MethodInfo methodInfo)
×
21
    {
22
        if (methodInfo == null)
×
23
            throw new ArgumentNullException(nameof(methodInfo));
×
24

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

30
    /// <summary>
31
    /// Gets the method info.
32
    /// </summary>
33
    public MethodInfo MethodInfo { get; }
×
34

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

43
    /// <summary>
44
    /// Invokes the method on the specified <paramref name="instance"/>.
45
    /// </summary>
46
    /// <param name="instance">The object on which to invoke the method. If a method is static, this argument is ignored.</param>
47
    /// <param name="arguments">An argument list for the invoked method.</param>
48
    /// <returns>
49
    /// An object containing the return value of the invoked method.
50
    /// </returns>
51
    public object Invoke(object instance, params object[] arguments)
52
    {
53
        return _invoker.Value.Invoke(instance, arguments);
×
54
    }
55

56
    /// <summary>
57
    /// Gets the method key using a hash code from the name and paremeter types.
58
    /// </summary>
59
    /// <param name="name">The name of the method.</param>
60
    /// <param name="parameterTypes">The method parameter types.</param>
61
    /// <returns>The method key</returns>
62
    internal static int GetKey(string name, IEnumerable<Type> parameterTypes)
63
    {
64
        unchecked
65
        {
66
            int result = name?.GetHashCode() ?? 0;
×
67
            result = parameterTypes.Aggregate(result,
×
68
              (r, p) => (r * 397) ^ (p?.GetHashCode() ?? 0));
×
69

70
            return result;
×
71
        }
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