locked
Custom Tool (BaseCodeGeneratorWithSite) won't show errors RRS feed

  • Question

  • Hi,

      I have created a custom tool that inherits from BaseCodeGeneratorWithSite. This overrides GetDefaultExtension and GenerateCode, and makes use of base.CreateExceptionMessage (if there's an exception) and base.GeneratorErrorCallback (if I detect errors with the input).

      I've registered this with /codebase (not GAC'd) and added it to the "VisualStudio\10.0_Config\Generators" key with GeneratesDesignTimeSource set to 1.

      My input file is called "xyz.action" and my default extension is ".action.cs". I have the custom tool's name specified in the "Custom Tool" property of my input file, and when I save or go to "Run Custom Tool", it generates the output correctly.

      However, if there are errors in my input file, the errors are not output to the VS Output/Error List (I was expecting GeneratorErrorCallback to write things there?). I have tried this with the input file's "Build Action" set to "Content" and set to "Compile". When set to "Content", VS just generates the output. When set to "Compile", VS generates the output, but also tries to compile the input as if it were C#, i.e., I get C# errors linked to the input file (even though the input file is called xyz.action?)

      Of all the few examples and tutorials I've read on this, none of them mention how to handle errors and only one mentioned the Build Action, which it said it should be "Compile". There were a few other interesting posts... well, their title seemed interesting, but they only covered details such as 404: page cannot be found.

      Is a BaseCodeGeneratorWithSite custom tool supposed to be able to generate VS errors, and if so, how?

    Thank you kindly,
    Regards,
    Eliott

    Saturday, May 17, 2014 2:20 AM

Answers

  • Hi,

      Just a work-around: I am now writing the errors into the generated output with the #error directive and setting the input's "Build Action" to "Content". It won't link to the source of the errors, but at least gives me visibility of them.

    Thank you,
    Kind regards,
    Eliott

    Saturday, May 17, 2014 12:35 PM

All replies

  • Hi,

      Just a work-around: I am now writing the errors into the generated output with the #error directive and setting the input's "Build Action" to "Content". It won't link to the source of the errors, but at least gives me visibility of them.

    Thank you,
    Kind regards,
    Eliott

    Saturday, May 17, 2014 12:35 PM
  • Hi,

    I'm glad to hear that you've got it working!

    And thank you for sharing the solution here, it will benefit others who come across the similar issue.

    Best regards, 


    • Edited by Anna Cc Monday, May 19, 2014 5:29 AM
    Monday, May 19, 2014 5:29 AM