#load a .cs file without preprocessor or other hacking #76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This lets a .cs file be loaded and used as script. For me this solves some of the preprocessor directive hacking I was doing to reuse existing classes or get intellisense. (ideas gleaned from issue #36 )
There is a flowchart and some other docs that describe it more completely but the gist is that a derived SourceFileResolver is passed into the ScriptOptions, and it intercepts the calls to .cs files and uses SyntaxTree et.al. to provide a "namespace free" compiled version of the source that can be lifted into the script scope.
There are a few orphaned bits in the CsRewriter class that I left in because I think adding debugging support will require them.
I tried to not pollute this with the OutputBehavior PR. Please review and suggest any edits, corrections, or additions.
Example of the script with #load for .cs