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

DomCR / ACadSharp / 12905558226

22 Jan 2025 09:51AM UTC coverage: 75.963% (-0.02%) from 75.984%
12905558226

push

github

web-flow
Merge pull request #533 from DomCR/xdata-utils-n-docs

XData docs and utils

5280 of 7676 branches covered (68.79%)

Branch coverage included in aggregate %.

18 of 26 new or added lines in 2 files covered. (69.23%)

8 existing lines in 2 files now uncovered.

21079 of 27024 relevant lines covered (78.0%)

39136.08 hits per line

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

72.09
/src/ACadSharp/XData/ExtendedData.cs
1
using ACadSharp.Tables;
2
using System.Collections.Generic;
3
using System.Linq;
4

5
namespace ACadSharp.XData
6
{
7
        /// <summary>
8
        /// Extended data linked to an <see cref="AppId"/>.
9
        /// </summary>
10
        public class ExtendedData
11
        {
12
                /// <summary>
13
                /// Records contained in this Extended Data instance.
14
                /// </summary>
15
                public List<ExtendedDataRecord> Records { get; } = new();   //Should be private?
47,217✔
16

17
                /// <summary>
18
                /// Default constructor.
19
                /// </summary>
20
                public ExtendedData()
22,716✔
21
                {
22,716✔
22
                }
22,716✔
23

24
                /// <summary>
25
                /// Initialize an instance of <see cref="ExtendedData"/> with a collection of records.
26
                /// </summary>
27
                /// <param name="records">Records to add to the <see cref="ExtendedData"/>.</param>
28
                public ExtendedData(IEnumerable<ExtendedDataRecord> records) : this()
22,713✔
29
                {
22,713✔
30
                        this.Records.AddRange(records);
22,713✔
31
                }
22,713✔
32

33
                /// <summary>
34
                /// Make sure that the first and last record are <see cref="ExtendedDataControlString"/>.
35
                /// </summary>
36
                /// <remarks>
37
                /// The first control string must be the opening one and the last one closing.
38
                /// </remarks>
39
                public void AddControlStrings()
40
                {
2✔
41
                        if (!this.Records.Any())
2✔
42
                        {
1✔
43
                                this.Records.Add(ExtendedDataControlString.Open);
1✔
44
                                this.Records.Add(ExtendedDataControlString.Close);
1✔
45
                                return;
1✔
46
                        }
47

48
                        var first = this.Records.First();
1✔
49
                        if (first is not ExtendedDataControlString firstControl)
1!
50
                        {
1✔
51
                                this.Records.Insert(0, ExtendedDataControlString.Open);
1✔
52
                        }
1✔
NEW
53
                        else if (firstControl.IsClosing)
×
NEW
54
                        {
×
NEW
55
                                this.Records.Insert(0, ExtendedDataControlString.Open);
×
NEW
56
                        }
×
57

58
                        var last = this.Records.Last();
1✔
59
                        if (last is not ExtendedDataControlString lastControl)
1!
60
                        {
1✔
61
                                this.Records.Add(ExtendedDataControlString.Close);
1✔
62
                        }
1✔
NEW
63
                        else if (!lastControl.IsClosing)
×
NEW
64
                        {
×
NEW
65
                                this.Records.Add(ExtendedDataControlString.Close);
×
NEW
66
                        }
×
67
                }
2✔
68
        }
69
}
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