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

DomCR / ACadSharp / 17737836230

15 Sep 2025 03:12PM UTC coverage: 2.092% (-76.2%) from 78.245%
17737836230

push

github

web-flow
Merge pull request #790 from DomCR/addflag-refactor

addflag refactor

141 of 9225 branches covered (1.53%)

Branch coverage included in aggregate %.

0 of 93 new or added lines in 10 files covered. (0.0%)

24910 existing lines in 372 files now uncovered.

724 of 32119 relevant lines covered (2.25%)

5.76 hits per line

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

0.0
/src/ACadSharp/PropertyReflection.cs
1
using System;
2
using System.Collections.Concurrent;
3
using System.Collections.Generic;
4
using System.Linq.Expressions;
5
using System.Reflection;
6

7
namespace ACadSharp
8
{
9
        internal class PropertyExpression<TClass, TAttribute>
10
                where TClass : class
11
                where TAttribute : Attribute
12
        {
13
                public class Prop
14
                {
UNCOV
15
                        public Func<TClass, object> Getter { get; internal set; }
×
16

UNCOV
17
                        public Action<TClass, object> Setter { get; internal set; }
×
18

UNCOV
19
                        public TAttribute Attribute { get; internal set; }
×
20

UNCOV
21
                        public PropertyInfo Property { get; internal set; }
×
22
                }
23

UNCOV
24
                private static readonly ConcurrentDictionary<string, Prop> _cache = new ConcurrentDictionary<string, Prop>();
×
25

UNCOV
26
                public IReadOnlyDictionary<string, Prop> Cache = _cache;
×
27

UNCOV
28
                public PropertyExpression(Func<PropertyInfo, TAttribute, string> keySelector)
×
UNCOV
29
                {
×
UNCOV
30
                        var properties = typeof(TClass).GetProperties();
×
UNCOV
31
                        foreach (var property in properties)
×
UNCOV
32
                        {
×
UNCOV
33
                                var attribute = property.GetCustomAttribute<TAttribute>();
×
UNCOV
34
                                if (attribute == null)
×
UNCOV
35
                                        continue;
×
36

UNCOV
37
                                var eventLogCustomType = property.DeclaringType;
×
UNCOV
38
                                var propertyType = property.PropertyType;
×
39

UNCOV
40
                                var instance = Expression.Parameter(typeof(TClass));
×
41

UNCOV
42
                                Func<TClass, object> getter = null;
×
UNCOV
43
                                var getMethod = property.GetGetMethod(true);
×
UNCOV
44
                                if (getMethod != null)
×
UNCOV
45
                                {
×
UNCOV
46
                                        getter =
×
UNCOV
47
                                                Expression.Lambda<Func<TClass, object>>(
×
UNCOV
48
                                                                Expression.Convert(
×
UNCOV
49
                                                                        Expression.Call(
×
UNCOV
50
                                                                                Expression.Convert(instance, eventLogCustomType),
×
UNCOV
51
                                                                                getMethod),
×
UNCOV
52
                                                                        typeof(object)),
×
UNCOV
53
                                                                instance)
×
UNCOV
54
                                                        .Compile();
×
UNCOV
55
                                }
×
56

UNCOV
57
                                Action<TClass, object> setter = null;
×
UNCOV
58
                                var setMethod = property.GetSetMethod(true);
×
UNCOV
59
                                if (setMethod != null)
×
UNCOV
60
                                {
×
UNCOV
61
                                        var parameter = Expression.Parameter(typeof(object));
×
UNCOV
62
                                        setter =
×
UNCOV
63
                                                Expression.Lambda<Action<TClass, object>>(
×
UNCOV
64
                                                                Expression.Call(
×
UNCOV
65
                                                                        Expression.Convert(instance, eventLogCustomType),
×
UNCOV
66
                                                                        setMethod,
×
UNCOV
67
                                                                        Expression.Convert(parameter, propertyType)),
×
UNCOV
68
                                                                instance, parameter)
×
UNCOV
69
                                                        .Compile();
×
UNCOV
70
                                }
×
71

UNCOV
72
                                _cache.TryAdd(keySelector(property, attribute), new Prop
×
UNCOV
73
                                {
×
UNCOV
74
                                        Getter = getter,
×
UNCOV
75
                                        Setter = setter,
×
UNCOV
76
                                        Attribute = attribute,
×
UNCOV
77
                                        Property = property
×
UNCOV
78
                                });
×
UNCOV
79
                        }
×
UNCOV
80
                }
×
81

82
                public Prop GetProperty(string propName)
UNCOV
83
                {
×
UNCOV
84
                        return _cache[propName];
×
UNCOV
85
                }
×
86
        }
87
}
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