Search code examples
c#roslynscriptcs

Add a default using directive to ScriptCS


Is there a way that I can add a default using directive to ScriptCS? So when I start ScriptCS I do not need to include the namespace for classes in that namespace.

For example, I may need to interact with the Process class within the System.Diagnostics namespace a lot. If I want to create a new instance of this class, I need to do

var proc = new System.Diagnostics.Process();

I would rather do

var proc = new Process();

I know that I can add the using statement each time I start ScriptCS, but I would like it to always be there.


Solution

  • You can add additional assembly references and using statements into your en and by writing a Script Pack. You can see an example of injecting using statements in the Web API example.