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

DomCR / ACadSharp / 20459304191

23 Dec 2025 11:18AM UTC coverage: 76.82% (-0.3%) from 77.148%
20459304191

Pull #924

github

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

7697 of 10907 branches covered (70.57%)

Branch coverage included in aggregate %.

8 of 148 new or added lines in 8 files covered. (5.41%)

2 existing lines in 2 files now uncovered.

28370 of 36043 relevant lines covered (78.71%)

159070.31 hits per line

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

79.63
/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,198✔
23
                {
28,198✔
24
                }
28,198✔
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));
×
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!
79
                                        throw new ArgumentException($"{type.FullName} is not a dxf subclass");
×
80
                                classMap.Name = att.ClassName;
54✔
81
                        }
54✔
82
                        else
83
                        {
8✔
84
                                classMap.Name = name;
8✔
85
                        }
8✔
86

87
                        addClassProperties(classMap, type);
62✔
88

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

96
                        _cache.TryAdd(type, classMap);
62✔
97

98
                        return classMap;
62✔
99
                }
139,563✔
100
        }
101
}
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