Skip to content

Add AssertRoundtrip for custom roundtrip test assertions - #1256

Merged
DomCR merged 23 commits into
masterfrom
writer-roundtrip-assert
Sep 23, 2026
Merged

DomCR merged 23 commits into
masterfrom
writer-roundtrip-assert

Conversation

@DomCR

@DomCR DomCR commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Description

Introduce AssertRoundtrip property to SingleCaseGenerator, enabling custom assertions on CadDocument after roundtrip operations.
Update SingleLine test to use this mechanism and invoke it in DwgWriterSingleObjectTests, allowing more flexible and targeted validation in tests.

Introduce AssertRoundtrip property to SingleCaseGenerator, enabling custom assertions on CadDocument after roundtrip operations. Update SingleLine test to use this mechanism and invoke it in DwgWriterSingleObjectTests, allowing more flexible and targeted validation in tests.
@DomCR DomCR added the code refactoring Improvements in the existing code label Sep 21, 2026
Replaces flat SegmentIndex/StartEndPointPairs in LeaderLine with a BreakInfo class and a list of BreakInfo entries. Updates reading, writing, cloning, and document assignment logic to support multiple break info entries per leader line, improving structure and clarity.
Set default values for key MultiLeader and MultiLeaderObjectContextData properties to ensure valid initial states. Refactor LeaderContentType enum for clarity. Update DwgObjectReader to use _mergedReaders for color reading. Simplify DwgObjectWriter logic for writing leader roots and annotation context data. Perform minor code cleanup.
Add conditional logic for R2007Pre arrowhead handling in DwgObjectWriter. Refactor CadMLeaderTemplate for clarity: mark as internal, improve formatting, streamline constructors and build method, and clarify attribute handle resolution. Add placeholder for ArrowheadHandles processing.
Made CadDictionaryTemplate public, refactored constructors, and improved the build method for better root dictionary handling, entry resolution, and error notifications. Cleaned up redundant code for clarity.
Refactored the iteration over dictionary entries to use a for loop with EntryHandles and EntryNames arrays instead of foreach. This ensures correct pairing of handles and names, and updates all related logic to use the new approach for improved consistency and reliability.
Introduce AssertRoundtrip lambdas in test methods to verify round-trip serialization/deserialization of CAD objects. Refactor tests to use local variables for entity handles, ensuring consistent and thorough validation of object equality and collection counts across the test suite. This standardizes and improves test reliability.
Refactored the Transparency struct with improved XML docs, property accessors, and validation logic. Enhanced FromAlphaValue and ToAlphaValue methods for clarity. Updated WriterSingleObjectTests to skip unsupported assertions for older ACad versions and set CodePage for Chinese text tests.
Explicitly set HasTextContents to true after assigning the
TextLabel property, ensuring the MultiLeader context data
correctly reflects the presence of text contents. No other
logic was changed.
Refactored DwgObjectWriter to use EntryHandles/EntryNames for accurate dictionary entry association and writing. Improved WriterSingleObjectTests to assert SpatialFilter presence and boundary point preservation after roundtrip. Added System.ComponentModel using directive.
Add version check in AssertRoundtrip to bypass MText comparison for AC1018 (R2000) and earlier, as MText encoding is not supported in those versions. Also add System.Diagnostics using directive.
Add optional roundtrip assertion via AssertRoundtrip in DxfWriterSingleObjectTests. Replace single entity assertion in WriterSingleObjectTests with checks for correct entity ownership and matching PaperSpace entity counts.
Introduce Format property to WriterSingleObjectTests for distinguishing DWG and DXF formats. Update roundtrip assertions to account for format and version-specific behavior, skipping unsupported checks for DXF and older versions. Import ACadSharp.IO namespace.
Updated WriterSingleObjectTests to skip color equality checks for layers in unsupported DWG versions. Removed ClipBoundaryVertices count assertions in raster and wipeout tests. DxfSectionWriterBase now writes clip boundary vertices unconditionally, regardless of clip type.
Renamed LineType in test to "LTYPE_PAINT" for consistency.
Added serialization of LineType, LineTypeExt1, and LineTypeExt2 handles (group codes 345-347) in DxfTablesSectionWriter for DimensionStyle.
Changed LineType name from "LTYPE:PAINT" to "LTYPE_PAINT" for consistency. Added a conditional to skip mesh roundtrip assertions when the file format is DXF.
Added logic to read and set CloningFlags from group code 280 in readXRecordEntries before processing other XRecord data. This ensures proper handling of dictionary cloning flags during DXF object parsing.
@DomCR DomCR added the minor Updates the minor version on merge. label Sep 22, 2026
Introduce BreakInfo with deep clone support and XML docs. Refactor LeaderLine to improve cloning and documentation, moving BreakInfoEntries and ensuring deep copies. Refactor StartEndPointPair as a top-level struct with better docs, a constructor, and a Clone method. Remove redundant code from old LeaderLine.Clone.
@DomCR
DomCR merged commit 286495a into master Sep 23, 2026
5 checks passed
@DomCR
DomCR deleted the writer-roundtrip-assert branch September 23, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code refactoring Improvements in the existing code minor Updates the minor version on merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant