EFeru / DbcParser

.NET CAN bus dbc file parser
MIT License
76 stars 28 forks source link

EnumCustomProperty parsing fails if more than one white-space character is used as separator #41

Closed JuRichter closed 1 year ago

JuRichter commented 1 year ago

Line in dbc file: BA_DEF_ BO_ "GenMsgSendType" ENUM "Cyclic","Event","CyclicIfActive","SpontanWithDelay","CyclicAndSpontan";

Propose fix in PropertiesDefinitionLineParser.cs: Line 16: Add: private readonly char[] PropertySeparatorChar = { ' ' };

Line 92: Replace: var enumDefinition = match.Groups[10].Value.Replace("\"", "").Split(' ')[1]; By: var enumDefinition = match.Groups[10].Value.Replace("\"", "").Split(PropertySeparatorChar, StringSplitOptions.RemoveEmptyEntries)[1];

Whitehouse112 commented 1 year ago

Hi @JuRichter , thanks for the feedback. The regex to parse the enum custom property has been modified to correctly read more white-spaces without the need of the Split() function. This will be available in the next release.

Regards

JuRichter commented 1 year ago

Thanks a lot!

Brainy0207 commented 1 year ago

One of the last changes to the regex for parsing enum definitions caused a strange issue.

Assume this definition: BA_DEF_ BU_ "AttributeName" ENUM "Val1","Val2","Val3";

Parsing this definition would duplicate the last value. .Values = { "Val1", "Val2", "Val3Val3" };

I submitted a PR (#46) to fix the issue and add some test code.