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

DomCR / ACadSharp / 29143042407

11 Jul 2026 06:34AM UTC coverage: 2.912% (-73.0%) from 75.918%
29143042407

push

github

web-flow
Merge pull request #1146 from ilCosmico/acds-read-payload-anchor

Read the AcDs payload area offset from the data segment header

264 of 12999 branches covered (2.03%)

Branch coverage included in aggregate %.

0 of 30 new or added lines in 1 file covered. (0.0%)

31243 existing lines in 465 files now uncovered.

1337 of 41984 relevant lines covered (3.18%)

5.38 hits per line

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

0.0
/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>
UNCOV
20
        private static readonly ConcurrentDictionary<Type, DxfClassMap> _cache = new ConcurrentDictionary<Type, DxfClassMap>();
×
21

UNCOV
22
        public DxfClassMap() : base()
×
UNCOV
23
        {
×
UNCOV
24
        }
×
25

UNCOV
26
        public DxfClassMap(string name) : base()
×
UNCOV
27
        {
×
UNCOV
28
                this.Name = name;
×
UNCOV
29
        }
×
30

UNCOV
31
        public DxfClassMap(DxfClassMap map) : base()
×
UNCOV
32
        {
×
UNCOV
33
                this.Name = map.Name;
×
UNCOV
34
                foreach (var item in map.DxfProperties)
×
UNCOV
35
                {
×
UNCOV
36
                        this.DxfProperties.Add(item.Key, new DxfProperty(item.Value));
×
UNCOV
37
                }
×
UNCOV
38
        }
×
39

40
        /// <summary>
41
        /// Creates a DXF map of the passed type.
42
        /// </summary>
43
        /// <remarks>
44
        /// Will return a cached instance if it exists.  if not, it will be created on call.
45
        /// Use the <see cref="ClearCache"/> method to clear the cache and force a new mapping to be created.
46
        /// </remarks>
47
        /// <typeparam name="T">Type of CadObject to map.</typeparam>
48
        /// <returns>Mapped class</returns>
49
        public static DxfClassMap Create<T>()
50
                where T : CadObject
UNCOV
51
        {
×
UNCOV
52
                return Create(typeof(T));
×
UNCOV
53
        }
×
54

55
        /// <summary>
56
        /// Creates a new instance of the DxfClassMap for the specified CAD object type and instance.
57
        /// </summary>
58
        /// <typeparam name="T">The type of CAD object for which to create the class map. Must inherit from CadObject.</typeparam>
59
        /// <param name="obj">The CAD object instance to associate with the created class map.</param>
60
        /// <returns>A DxfClassMap instance representing the mapping for the specified CAD object type and instance.</returns>
61
        public static DxfClassMap Create<T>(T obj)
62
                where T : CadObject
UNCOV
63
        {
×
UNCOV
64
                return Create(typeof(T), obj: obj);
×
UNCOV
65
        }
×
66

67
        /// <summary>
68
        /// Clears the map cache.
69
        /// </summary>
70
        public void ClearCache()
71
        {
×
72
                _cache.Clear();
×
73
        }
×
74

75
        /// <inheritdoc/>
76
        public override string ToString()
77
        {
×
78
                return $"DxfClassMap:{this.Name}";
×
79
        }
×
80

81
        internal static DxfClassMap Create(Type type, string name = null, CadObject obj = null)
UNCOV
82
        {
×
UNCOV
83
                if (!_cache.TryGetValue(type, out var classMap) || obj != null)
×
UNCOV
84
                {
×
UNCOV
85
                        classMap = new DxfClassMap();
×
86

UNCOV
87
                        if (string.IsNullOrEmpty(name))
×
UNCOV
88
                        {
×
UNCOV
89
                                var att = type.GetCustomAttribute<DxfSubClassAttribute>();
×
UNCOV
90
                                if (att == null)
×
91
                                {
×
92
                                        throw new ArgumentException($"{type.FullName} is not a dxf subclass");
×
93
                                }
94

UNCOV
95
                                classMap.Name = att.ClassName;
×
UNCOV
96
                        }
×
97
                        else
UNCOV
98
                        {
×
UNCOV
99
                                classMap.Name = name;
×
UNCOV
100
                        }
×
101

UNCOV
102
                        addClassProperties(classMap, type, obj);
×
103

UNCOV
104
                        DxfSubClassAttribute baseAtt = type.BaseType.GetCustomAttribute<DxfSubClassAttribute>();
×
UNCOV
105
                        if (baseAtt != null && baseAtt.IsEmpty)
×
UNCOV
106
                        {
×
107
                                //Properties in the table seem to be embeded to the hinerit type
UNCOV
108
                                addClassProperties(classMap, type.BaseType, obj);
×
UNCOV
109
                        }
×
110

UNCOV
111
                        _cache.TryAdd(type, classMap);
×
UNCOV
112
                }
×
113

UNCOV
114
                return new DxfClassMap(classMap);
×
UNCOV
115
        }
×
116
}
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