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

Add support for emiting warning / errors from cecilifier #292

Open
adrianoc opened this issue May 15, 2024 · 0 comments
Open

Add support for emiting warning / errors from cecilifier #292

adrianoc opened this issue May 15, 2024 · 0 comments

Comments

@adrianoc
Copy link
Owner

adrianoc commented May 15, 2024

As of today whenever we want to call user's attention to some aspect of the generated code we have two alternatives

  1. emit a comment in the generated code: far from ideal, users may simply overlook it.
  2. throw an exception: Ugly, prevents user from seeing any generated code; may mislead users to think they found bugs

We intend to add a mechanism to allow Cecilifier to emit warnings/errors in a way that will be harder to overlook them.

API

internal interface IVisitorContext
{
   // ... 
     void EmitWarning(string message);
     void EmitError(string message);
}

Bebavior

Invoking these members will:

  1. Show the message in the frontend (as a notification, similar to the notifications used to report compilation errors)
  2. Add a #warning message / #error message directive in the generated code so if user overlooks 1 they have another chance notice the warning in the code and if they don't and try to compile they will get a compilation warning/error.

Known use cases

The main driver for this feature is to report unsupported C# features but most likely there are other use cases.

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

No branches or pull requests

1 participant