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

Parsing failures management #23

Closed
Adhara3 opened this issue Jan 16, 2023 · 2 comments
Closed

Parsing failures management #23

Adhara3 opened this issue Jan 16, 2023 · 2 comments
Labels
enhancement New feature or request public API This request involves user API

Comments

@Adhara3
Copy link
Collaborator

Adhara3 commented Jan 16, 2023

Today we do silently swallow errors when parsing.
My idea is to provide an optional IParsingObserver which will allow user to react (or at least know!) to errors.

Quick example

public interface IParseObserver
{
  void DuplicateMessage(int messageId);
  void DuplicateSignalInMessage(int messageId, string signalName);
  void DuplicateValueTableKey(double key, string value);
  // etc...
}

public class StrictParseObserver : IParseObserver
{
  public void DuplicateMessage(int message)
  {
	// This implementation is just an example
	// The idea is that the parsing here will stop and fail
	throw new ParsingException($"More than one message in dbc is defined with ID {message}, which does not follow the official spec");
  }
  
  // Etc...
}

// We could also provide an implementation that does nothing, like today
public class SilentParseObserver : IParseObserver
{
  public void DuplicateMessage(int message)
  {
  }
  
  // Etc...
}

// But a user could inject something custom like this
public class StrictParseObserver : IParseObserver
{
  public void DuplicateMessage(int message)
  {
	// I don't want to break, I just want to log the issue to create a report
	Console.WriteLine($"More than one message in dbc is defined with ID {message}, which does not follow the official spec");
  }
  
  // Etc...
}

Hope you get the idea.
A

@EFeru
Copy link
Owner

EFeru commented Jan 21, 2023

Interesting proposal. Looks like a way to provide consistency checks. I would say if there is no issue on increasing too much the parsing time, i mean why not.

@Adhara3
Copy link
Collaborator Author

Adhara3 commented Jan 23, 2023

Interesting proposal. Looks like a way to provide consistency checks. I would say if there is no issue on increasing too much the parsing time, i mean why not.

A successful parsing will pay no extra time

A

Whitehouse112 added a commit to Whitehouse112/DbcParser that referenced this issue Aug 21, 2023
Added observer to listen for parsing failures. Code clean up.
Whitehouse112 added a commit to Whitehouse112/DbcParser that referenced this issue Aug 24, 2023
Added parsing failures management for each line parser.
Created silent and simple failure observer classes
Whitehouse112 added a commit to Whitehouse112/DbcParser that referenced this issue Aug 24, 2023
Added parsing failure tests. Removed old and no more valid tests
Whitehouse112 added a commit to Whitehouse112/DbcParser that referenced this issue Aug 24, 2023
EFeru pushed a commit that referenced this issue Sep 11, 2023
* #23 Parsing failures management

Added observer to listen for parsing failures. Code clean up.

* #23 Added parsing failures management for each line parser

Added parsing failures management for each line parser.
Created silent and simple failure observer classes

* #23 Added parsing failure tests

Added parsing failure tests. Removed old and no more valid tests

* #23 Added parsing failure observer in Demo application

* #41 EnumCustomProperty parsing fails if more than one white-space character is used as separator. Updated and added some test

EnumCustomProperty parsing fails if more than one white-space chracter is used as separator. Updated and added some test, code clean up.

* #42 Bugfixed on NS definition

Now every NS definition at the top of a file is ignored
Whitehouse112 added a commit to Whitehouse112/DbcParser that referenced this issue Sep 13, 2023
Added support for signed integer in VAL_ regex. Fixed bug in EFeru#41 preventing custom definition from being correctly parsed
Whitehouse112 added a commit to Whitehouse112/DbcParser that referenced this issue Sep 13, 2023
EFeru#23 Now signed integer is correctly parsed in VAL_ regex
EFeru#41 Bug preventing BA_DEF_ regex to be correctly parsed is now fixed
Adhara3 added a commit that referenced this issue Sep 14, 2023
@Adhara3 Adhara3 closed this as completed Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request public API This request involves user API
Projects
None yet
Development

No branches or pull requests

2 participants