Skip to content

Add support for emiting warning / errors from cecilifier #292

Open
@adrianoc

Description

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.

Activity

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

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions