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

SamboyCoding / Tomlet / 12645117425

07 Jan 2025 04:19AM UTC coverage: 91.317% (-0.5%) from 91.859%
12645117425

Pull #47

github

web-flow
Merge d6b623c12 into 0d521fbbe
Pull Request #47: feat: runtime comment provider

975 of 1140 branches covered (85.53%)

63 of 80 new or added lines in 13 files covered. (78.75%)

1956 of 2142 relevant lines covered (91.32%)

216.87 hits per line

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

87.5
/Tomlet/Attributes/TomlCommentProviderAttribute.cs
1
using System;
2
using System.Linq;
3

4
namespace Tomlet.Attributes;
5

6
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
7
public class TomlCommentProviderAttribute : Attribute
8
{
9
    private readonly Type _provider;
10
    private readonly object[] _args;
11
    private readonly Type[] _constructorParamsType;
12

13
    public string GetComment()
14
    {
22✔
15
        var constructor = _provider.GetConstructor(_constructorParamsType) ??
22!
16
                          throw new ArgumentException("Fail to get a constructor matching the parameters");
22✔
17
        var instance = constructor.Invoke(_args) as ICommentProvider ??
22!
18
                       throw new Exception("Fail to create an instance of the provider");
22✔
19
        return instance.GetComment();
22✔
20
    }
22✔
21

22
    public TomlCommentProviderAttribute(Type provider, object[] args)
142✔
23
    {
142✔
24
        if (!typeof(ICommentProvider).IsAssignableFrom(provider))
142!
NEW
25
        {
×
NEW
26
            throw new ArgumentException("Provider must implement ICommentProvider");
×
27
        }
28

29
        _provider = provider;
142✔
30
        _args = args ?? new object[] { };
142!
31
        _constructorParamsType = args?.Select(a => a.GetType()).ToArray() ?? new Type[] { };
284!
32
    }
142✔
33
}
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

© 2025 Coveralls, Inc