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

DomCR / ACadSharp / 20457200384

23 Dec 2025 09:42AM UTC coverage: 76.854% (-0.3%) from 77.148%
20457200384

Pull #924

github

web-flow
Merge fde81b197 into 886606be2
Pull Request #924: issue 923 - dim style override

7696 of 10903 branches covered (70.59%)

Branch coverage included in aggregate %.

49 of 176 new or added lines in 8 files covered. (27.84%)

123 existing lines in 7 files now uncovered.

28361 of 36013 relevant lines covered (78.75%)

159201.5 hits per line

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

84.31
/src/ACadSharp/DxfClassMap.cs
1
using ACadSharp.Attributes;
2
using System;
3
using System.Collections.Concurrent;
4
using System.Reflection;
5

6
namespace ACadSharp
7
{
8
        public class DxfClassMap : DxfMapBase
9
        {
10
                /// <summary>
11
                /// Cache of created DXF mapped classes.
12
                /// </summary>
13
                private static readonly ConcurrentDictionary<Type, DxfClassMap> _cache = new ConcurrentDictionary<Type, DxfClassMap>();
1✔
14

15
                public DxfClassMap() : base()
28,166✔
16
                {
28,166✔
17
                }
28,166✔
18

19
                public DxfClassMap(string name) : base()
2,346✔
20
                {
2,346✔
21
                        this.Name = name;
2,346✔
22
                }
2,346✔
23

24
                /// <summary>
25
                /// Creates a DXF map of the passed type.
26
                /// </summary>
27
                /// <remarks>
28
                ///   Will return a cached instance if it exists.  if not, it will be created on call.
29
                /// Use the <see cref="ClearCache"/> method to clear the cache and force a new mapping to be created.
30
                /// </remarks>
31
                /// <typeparam name="T">Type of CadObject to map.</typeparam>
32
                /// <returns>Mapped class</returns>
33
                public static DxfClassMap Create<T>()
34
                        where T : CadObject
35
                {
37,363✔
36
                        return Create(typeof(T));
37,363✔
37
                }
37,363✔
38

39
                /// <summary>
40
                /// Clears the map cache.
41
                /// </summary>
42
                public void ClearCache()
UNCOV
43
                {
×
UNCOV
44
                        _cache.Clear();
×
UNCOV
45
                }
×
46

47
                /// <inheritdoc/>
48
                public override string ToString()
NEW
49
                {
×
NEW
50
                        return $"DxfClassMap:{this.Name}";
×
NEW
51
                }
×
52

53
                internal static DxfClassMap Create(Type type, string name = null)
54
                {
139,563✔
55
                        if (_cache.TryGetValue(type, out var classMap))
139,563✔
56
                        {
139,501✔
57
                                return classMap;
139,501✔
58
                        }
59

60
                        classMap = new DxfClassMap();
62✔
61

62
                        if (string.IsNullOrEmpty(name))
62✔
63
                        {
54✔
64
                                var att = type.GetCustomAttribute<DxfSubClassAttribute>();
54✔
65
                                if (att == null)
54!
NEW
66
                                        throw new ArgumentException($"{type.FullName} is not a dxf subclass");
×
67
                                classMap.Name = att.ClassName;
54✔
68
                        }
54✔
69
                        else
70
                        {
8✔
71
                                classMap.Name = name;
8✔
72
                        }
8✔
73

74
                        addClassProperties(classMap, type);
62✔
75

76
                        DxfSubClassAttribute baseAtt = type.BaseType.GetCustomAttribute<DxfSubClassAttribute>();
62✔
77
                        if (baseAtt != null && baseAtt.IsEmpty)
62✔
78
                        {
21✔
79
                                //Properties in the table seem to be embeded to the hinerit type
80
                                addClassProperties(classMap, type.BaseType);
21✔
81
                        }
21✔
82

83
                        _cache.TryAdd(type, classMap);
62✔
84

85
                        return classMap;
62✔
86
                }
139,563✔
87
        }
88
}
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