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

DomCR / ACadSharp / 20490822353

24 Dec 2025 05:15PM UTC coverage: 76.65% (-0.4%) from 77.021%
20490822353

Pull #924

github

web-flow
Merge 99883e83c into 68e4e7c16
Pull Request #924: issue 923 - dim style override

7695 of 10931 branches covered (70.4%)

Branch coverage included in aggregate %.

22 of 179 new or added lines in 9 files covered. (12.29%)

4 existing lines in 4 files now uncovered.

28372 of 36123 relevant lines covered (78.54%)

158725.09 hits per line

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

78.18
/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
        /// <summary>
9
        /// Represents the mapping information for a DXF class, including metadata and property mappings used for serialization
10
        /// and deserialization of CAD objects.
11
        /// </summary>
12
        /// <remarks>Instances of this class are typically created and managed via the static Create methods, which
13
        /// provide caching to improve performance when mapping types multiple times. Use the ClearCache method to clear all
14
        /// cached mappings if the underlying type information changes or to force remapping.</remarks>
15
        public class DxfClassMap : DxfMapBase
16
        {
17
                /// <summary>
18
                /// Cache of created DXF mapped classes.
19
                /// </summary>
20
                private static readonly ConcurrentDictionary<Type, DxfClassMap> _cache = new ConcurrentDictionary<Type, DxfClassMap>();
1✔
21

22
                public DxfClassMap() : base()
28,163✔
23
                {
28,163✔
24
                }
28,163✔
25

26
                public DxfClassMap(string name) : base()
2,345✔
27
                {
2,345✔
28
                        this.Name = name;
2,345✔
29
                }
2,345✔
30

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

46
                public static DxfClassMap Create<T>(T obj)
47
                        where T : CadObject
NEW
48
                {
×
NEW
49
                        return Create(typeof(T), obj: obj);
×
NEW
50
                }
×
51

52
                /// <summary>
53
                /// Clears the map cache.
54
                /// </summary>
55
                public void ClearCache()
56
                {
×
57
                        _cache.Clear();
×
58
                }
×
59

60
                /// <inheritdoc/>
61
                public override string ToString()
62
                {
×
63
                        return $"DxfClassMap:{this.Name}";
×
64
                }
×
65

66
                internal static DxfClassMap Create(Type type, string name = null, CadObject obj = null)
67
                {
139,563✔
68
                        if (_cache.TryGetValue(type, out var classMap))
139,563✔
69
                        {
139,501✔
70
                                return classMap;
139,501✔
71
                        }
72

73
                        classMap = new DxfClassMap();
62✔
74

75
                        if (string.IsNullOrEmpty(name))
62✔
76
                        {
54✔
77
                                var att = type.GetCustomAttribute<DxfSubClassAttribute>();
54✔
78
                                if (att == null)
54!
NEW
79
                                {
×
UNCOV
80
                                        throw new ArgumentException($"{type.FullName} is not a dxf subclass");
×
81
                                }
82

83
                                classMap.Name = att.ClassName;
54✔
84
                        }
54✔
85
                        else
86
                        {
8✔
87
                                classMap.Name = name;
8✔
88
                        }
8✔
89

90
                        addClassProperties(classMap, type, obj);
62✔
91

92
                        DxfSubClassAttribute baseAtt = type.BaseType.GetCustomAttribute<DxfSubClassAttribute>();
62✔
93
                        if (baseAtt != null && baseAtt.IsEmpty)
62✔
94
                        {
21✔
95
                                //Properties in the table seem to be embeded to the hinerit type
96
                                addClassProperties(classMap, type.BaseType, obj);
21✔
97
                        }
21✔
98

99
                        _cache.TryAdd(type, classMap);
62✔
100

101
                        return classMap;
62✔
102
                }
139,563✔
103
        }
104
}
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