2

I've written a custom processor directive for scriptcs based on this answer, but I can't figure out how to make it available for use. I just get the error "Preprocessor directive expected". I'm guessing there's some special way of registering the directive, but I haven't found it yet.

Edit: I added some info to this issue on github.

Community
  • 1
  • 1
ryan.rousseau
  • 1,595
  • 1
  • 11
  • 22

1 Answers1

3

You need to register the line pre-processor with the services builder and in order to get that done you would need to use a module as explained here.

Unfortunately right now there is not a lot of documentation available on using modules (we plan to improve that some time in the future), but the previous link provides a link to this sample project which you can use as guidance.

For module development you don't need to install the module globally. You can take advantage of the feature described here. You will need to install the module using -g once you want to use it for real.

Damian Schenkelman
  • 3,505
  • 1
  • 15
  • 19
  • 1
    if you run with -debug flag you can load the module from bin relative to your script. for example scriptcs my.csx -debug -modules modulename – Filip W Apr 14 '14 at 11:18
  • 1
    Thanks very much for the info. After I get my hands dirty with it, I wouldn't mind contributing some documentation. – ryan.rousseau Apr 14 '14 at 12:22
  • @ryan.rousseau That would be awesome! :) – khellang Apr 14 '14 at 12:27
  • @ryan.rousseau it definitely would be! – Damian Schenkelman Apr 14 '14 at 12:48
  • I might be missing something. I created a ExecLinePreprocessor that inherits from DirectiveLineProcessor. I also created ExecModule which implements IModule. See [the gist here](https://gist.github.com/ryanrousseau/10659138). The module loads correctly, but it still doesn't find the line processor. I'm looking through the source and I can't find the connection between LineProcessors on IModuleConfiguration and the LineProcessors on ScriptServicesBuilder that is passed to RuntimeServices yet. I'll keep looking tonight, but if someone has a hint, that would be great. – ryan.rousseau Apr 14 '14 at 15:59
  • @khellang developed the line pre-processor feature so he is probably the person best suited to answer – Damian Schenkelman Apr 14 '14 at 17:21