Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with empty $FINGERPRINTGUID #83

Closed
Tilwin90 opened this issue Apr 19, 2018 · 1 comment
Closed

Problem with empty $FINGERPRINTGUID #83

Tilwin90 opened this issue Apr 19, 2018 · 1 comment

Comments

@Tilwin90
Copy link

Tilwin90 commented Apr 19, 2018

We have a .CDX file with the following FINGERPRINTGUID section:

"$FINGERPRINTGUID
2

9"

Because no actual GUID is specified in-between, the framework attempts to read an empty string as a GUID. Here is the full stack trace:

at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result) in f:\dd\ndp\clr\src\BCL\system\guid.cs:line 462
at System.Guid.Parse(String input) in f:\dd\ndp\clr\src\BCL\system\guid.cs:line 262
at IxMilia.Dxf.DxfHeader.GuidString(String s) in D:\IxMilia\Dxf\src\IxMilia.Dxf\Sections\DxfHeader.cs:line 87
at IxMilia.Dxf.DxfHeader.SetHeaderVariable(String keyName, DxfCodePair pair) in D:\IxMilia\Dxf\src\IxMilia.Dxf\Sections\Generated\DxfHeaderGenerated.cs:line 4562
at IxMilia.Dxf.Sections.DxfHeaderSection.HeaderSectionFromBuffer(DxfCodePairBufferReader buffer) in D:\IxMilia\Dxf\src\IxMilia.Dxf\Sections\DxfHeaderSection.cs:line 437
at IxMilia.Dxf.Sections.DxfSection.FromBuffer(DxfCodePairBufferReader buffer, DxfAcadVersion version) in D:\IxMilia\Dxf\src\IxMilia.Dxf\Sections\DxfSection.cs:line 71
at IxMilia.Dxf.DxfFile.LoadFromReader(IDxfCodePairReader reader) in D:\IxMilia\Dxf\src\IxMilia.Dxf\DxfFile.cs:line 257
at IxMilia.Dxf.DxfFile.Load(Stream stream) in D:\IxMilia\Dxf\src\IxMilia.Dxf\DxfFile.cs:line 188

The file can be opened just fine by regular DXF readers.
Would there be any chance this field could get ignored in this situation?

UPDATE:
I pulled the sources locally, and indeed the issue is that the static method DxfHeader.GuidString attempts convert an empty string to a Guid, resulting in an error. If performing a check for NullOrWhitespace before propagating the Guid conversion, and returning an empty Guid otherwise, it seems to work just fine.

@brettfo
Copy link
Member

brettfo commented Apr 20, 2018

Good catch!

I slightly modified your suggestion and used Guid.TryParse() to ensure we always get something valid or Guid.Empty.

Fixed in commit 10eb796.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants