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

DomCR / ACadSharp / 16421321209

21 Jul 2025 03:32PM UTC coverage: 75.148% (+0.05%) from 75.1%
16421321209

Pull #559

github

web-flow
Merge 493648da9 into b070875e7
Pull Request #559: Issue 557 dimension block

5980 of 8757 branches covered (68.29%)

Branch coverage included in aggregate %.

320 of 444 new or added lines in 17 files covered. (72.07%)

4 existing lines in 2 files now uncovered.

23862 of 30954 relevant lines covered (77.09%)

79113.33 hits per line

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

68.97
/src/ACadSharp/IO/CadWriterBase.cs
1
using CSUtilities.Text;
2
using System.Text;
3
using System;
4
using System.IO;
5
using ACadSharp.Classes;
6

7
namespace ACadSharp.IO
8
{
9
        /// <summary>
10
        /// Base class for the CAD writers.
11
        /// </summary>
12
        public abstract class CadWriterBase<T> : ICadWriter
13
                where T : CadWriterConfiguration, new()
14
        {
15
                /// <inheritdoc/>
16
                public event NotificationEventHandler OnNotification;
17

18
                /// <summary>
19
                /// Configuration for the writer.
20
                /// </summary>
21
                public T Configuration { get; set; } = new T();
576✔
22

23
                protected Stream _stream;
24

25
                protected CadDocument _document;
26

27
                protected Encoding _encoding;
28

29
                protected CadWriterBase(Stream stream, CadDocument document)
75✔
30
                {
75✔
31
                        this._stream = stream;
75✔
32
                        this._document = document;
75✔
33
                }
75✔
34

35
                /// <inheritdoc/>
36
                public virtual void Write()
37
                {
74✔
38
                        this._document.UpdateDxfClasses(this.Configuration.ResetDxfClasses);
74✔
39

40
                        this._encoding = this.getListedEncoding(this._document.Header.CodePage);
74✔
41
                }
74✔
42

43
                /// <inheritdoc/>
44
                public abstract void Dispose();
45

46
                protected Encoding getListedEncoding(string codePage)
47
                {
74✔
48
                        CodePage code = CadUtils.GetCodePage(codePage);
74✔
49

50
                        try
51
                        {
74✔
52
#if !NET48
53
                                Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
74✔
54
#endif
55
                                return Encoding.GetEncoding((int)code);
74✔
56
                        }
57
                        catch (Exception ex)
×
58
                        {
×
59
                                this.triggerNotification($"Encoding with code {code} not found, using Windows-1252 as default", NotificationType.Warning, ex);
×
60
                        }
×
61

62
                        return TextEncoding.Windows1252();
×
63
                }
74✔
64

65
                protected void triggerNotification(string message, NotificationType notificationType, Exception ex = null)
UNCOV
66
                {
×
UNCOV
67
                        this.triggerNotification(this, new NotificationEventArgs(message, notificationType, ex));
×
UNCOV
68
                }
×
69

70
                protected void triggerNotification(object sender, NotificationEventArgs e)
71
                {
56✔
72
                        this.OnNotification?.Invoke(sender, e);
56!
73
                }
56✔
74
        }
75
}
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