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

DomCR / ACadSharp / 24669708962

20 Apr 2026 01:38PM UTC coverage: 77.118% (+0.04%) from 77.076%
24669708962

Pull #1041

github

web-flow
Merge 6a14a7067 into 98bd2e4f4
Pull Request #1041: issue-1035 Add progress reporting to CAD file reading process

8455 of 11917 branches covered (70.95%)

Branch coverage included in aggregate %.

74 of 84 new or added lines in 8 files covered. (88.1%)

2 existing lines in 1 file now uncovered.

30421 of 38494 relevant lines covered (79.03%)

153505.78 hits per line

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

75.0
/src/ACadSharp/IO/CadReader.cs
1
using System;
2
using System.IO;
3

4
namespace ACadSharp.IO;
5

6
public static class CadReader
7
{
8
        /// <summary>
9
        /// Creates an <see cref="ICadReader"/> instance for the specified CAD file format.
10
        /// </summary>
11
        /// <remarks>Supported file formats include DWG and DXF. The method selects the appropriate reader based on the
12
        /// file extension.</remarks>
13
        /// <param name="filename">The path to the CAD file to read. The file extension determines the reader type. Must not be null or empty.</param>
14
        /// <param name="notification">An optional event handler for receiving notifications during the reading process. Can be null if no notifications
15
        /// are needed.</param>
16
        /// <returns>An <see cref="ICadReader"/> instance capable of reading the specified CAD file.</returns>
17
        /// <exception cref="NotSupportedException">Thrown if the file extension is not supported.</exception>
18
        public static ICadReader CreateReader(string filename, NotificationEventHandler notification = null)
19
        {
133✔
20
                switch (GetFileFormat(filename))
133!
21
                {
22
                        case CadFileFormat.DWG:
23
                                return new DwgReader(filename, notification);
49✔
24
                        case CadFileFormat.DXF:
25
                                return new DxfReader(filename, notification);
84✔
26
                        case CadFileFormat.Unknown:
27
                        default:
NEW
28
                                throw new NotSupportedException($"Extension {Path.GetExtension(filename)} is not supported.");
×
29
                }
30
        }
133✔
31

32
        /// <summary>
33
        /// Determines the CAD file format based on the file extension of the specified filename.
34
        /// </summary>
35
        /// <remarks>The method does not validate whether the file exists or whether the file content matches the
36
        /// extension. Only the file extension is considered when determining the format.</remarks>
37
        /// <param name="filename">The path or name of the file whose format is to be identified. The file extension is used to determine the format.</param>
38
        /// <returns>A value of the CadFileFormat enumeration that corresponds to the file's extension. Returns  <see cref="CadFileFormat.DWG"/> for
39
        /// ".dwg" files,  <see cref="CadFileFormat.DXF"/> for ".dxf" files, or <see cref="CadFileFormat.Unknown"/> if the extension is not recognized.</returns>
40
        public static CadFileFormat GetFileFormat(string filename)
41
        {
133✔
42
                switch (Path.GetExtension(filename))
133!
43
                {
44
                        case ".dwg":
45
                                return CadFileFormat.DWG;
49✔
46
                        case ".dxf":
47
                                return CadFileFormat.DXF;
84✔
48
                        default:
NEW
49
                                return CadFileFormat.Unknown;
×
50
                }
51
        }
133✔
52
}
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