Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output behavior take 2 #75

Closed

Conversation

StingyJack
Copy link
Contributor

This is a replacement for PR's #67 and #69. I had to branch, reset hard, then cherry pick the other commits in before this. That should take care of the somewhat dirty history. Please comment if you want changes, but do let me rescind the PR if you are not satisfied, I think the "push" from before is what got me into difficulty with commits.

--Summary from #67 and 69--
Scripty suffers from the ISVSingleFileGenerator's behavior of always overwriting any output so long as it can compile (just like T4's - which is what scripty is replacing for me). With both ISVSingleFileGenerator, I find that visual studio saves the file all the frigging time, constantly regenerating output. I had looked into creating a custom T4 host a while back and it seemed difficult and had aged documentation, but it seemed far less difficult (sans git woes) to add configurable output behavior to Scripty.

The output behavior still defaults to the original way and will generate outputs if the code compiles, but there are two other possibilities...

Never generate output nothing from output is written
Script Controls Output - letting the script selectively determine which outputs it wants to keep. ex...

Output["debug.log"].KeepOutput = errorOccured;
Output["CodeFile.cs"].KeepOutput = true;
//or just this if you only used the default outputter
Output.KeepOutput = false;

I added a Tools -> Options -> ScriptyOptions page in Visual Studio to allow setting this for ScriptyGenerator (also now there a place where more settings can be added). There's also a set of command line switches for scripty.exe

This change opens the door for other usages of scripty outside of codegen or build time activity, and even outside of a specific project/solution scope as a script engine.

The temp files were because I have no idea how large of an output some are generating. There was at least one person who wanted raw bytes to make files. Temp files seemed safer than ram and if anything catastrophic happened they could be available for forensics. A default of memory stream and allowance for opting into disk temp files via setting/switch like the outputbehavior could be added I suppose

There were some member naming I changed to clarify the internal usages of default output and additional outputs, and there seemed to be some odd interplay when set file path/extension were used with multiple outputs, as well as flush/close was getting called 2x sometimes or sometimes not at all.

Let me know what needs work, and thanks for your patience.

@daveaglick
Copy link
Owner

thanks for your patience

And thanks for your patience 😄 - I know I haven't been the most responsive maintainer when it comes to this project.

I like a lot of what you've done here. The settings, extra CLI options, testing, etc. I would like to remove the temporary files. It makes the whole output pipeline that much more complex and I'm already struggling with the amount of complexity while maintaining the project. The "what if it fails and we need a dump of output" risk is one I'm willing to accept for the reduction in complexity.

Also, just FYI, this PR might be OBE at some point after it's merged. This project has spiraled a bit beyond my original vision and I'm debating whether I should reign it in. If I do, it'll probably result in a breaking change where Scripty is no longer controlling output at all, but instead exposing file system and Roslyn APIs so that the script can output on it's own, add files to the project/Workspace on it's own, etc. Don't know if I'll go this route yet, or what such a simplification would look like, but it's a possibility.

@StingyJack
Copy link
Contributor Author

I get the buffer vs file, just wasnt sure and picked one with a singular, but albeit minor reason over the other.

OBE - Order of the British Empire?

No rush, and no pressure - its here if you want it. Between this, the direct class ref, and debugging I have the things I was needing for my codegen stuff. (I had to take a break on the debugging, that one was hurting brain but its close to working. I can just output.writeline() to a separate log file until then.)

Well... I thought so anyway. now with VS 2017 and net core I may need something else. =D

Thanks for putting in some good bones for this project. Its been very useful and a good learning experience for me.

@daveaglick
Copy link
Owner

I did a number of years as a defense contractor and am from the DC area - I forget that not everyone knows "military" jargon 😄 OBE = overcome by events. Basically, no longer relevant.

That said, I would love to pull this in once the file buffering bits are removed. I'm still going back and forth on whether I want to go back to square one and in the meantime this is a helpful addition.

@StingyJack
Copy link
Contributor Author

Closing for now while i work on those bits

@StingyJack StingyJack closed this Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants