{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/715","repository_url":"https://api.github.com/repos/Microsoft/visualfsharp","labels_url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/715/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/715/comments","events_url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/715/events","html_url":"https://github.com/Microsoft/visualfsharp/pull/715","id":115608370,"number":715,"title":"[WIP] Allow compilation to in memory stream, part 1: Fsc output","user":{"login":"enricosada","id":147243,"avatar_url":"https://avatars.githubusercontent.com/u/147243?v=3","gravatar_id":"","url":"https://api.github.com/users/enricosada","html_url":"https://github.com/enricosada","followers_url":"https://api.github.com/users/enricosada/followers","following_url":"https://api.github.com/users/enricosada/following{/other_user}","gists_url":"https://api.github.com/users/enricosada/gists{/gist_id}","starred_url":"https://api.github.com/users/enricosada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enricosada/subscriptions","organizations_url":"https://api.github.com/users/enricosada/orgs","repos_url":"https://api.github.com/users/enricosada/repos","events_url":"https://api.github.com/users/enricosada/events{/privacy}","received_events_url":"https://api.github.com/users/enricosada/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/visualfsharp/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":25,"created_at":"2015-11-06T23:03:08Z","updated_at":"2016-06-06T15:15:55Z","closed_at":"2016-06-06T15:15:55Z","pull_request":{"url":"https://api.github.com/repos/Microsoft/visualfsharp/pulls/715","html_url":"https://github.com/Microsoft/visualfsharp/pull/715","diff_url":"https://github.com/Microsoft/visualfsharp/pull/715.diff","patch_url":"https://github.com/Microsoft/visualfsharp/pull/715.patch"},"body":"this pr is the first of a multuple set to allow in memory compilation and output\r\n\r\nsee fsharp/FSharp.Compiler.Service#266\r\nuser voice: https://fslang.uservoice.com/forums/245727-f-language/suggestions/6717137-allow-for-completely-in-memory-compilation\r\n\r\nthe refactoring plan is to start with the lower level, convert paths to stream factories and bubble up these arguments up to fsc main.\r\nThere we can build a better api for in memory compilation ( really nice for testing or compiler service i think)\r\n\r\ncurrent fsc main:\r\n```fsharp\r\n    main0(argv,bannerAlreadyPrinted,exiter, errorLoggerProvider, disposables)\r\n    |> main1\r\n    |> main2\r\n    |> main2b\r\n    |> main2c\r\n    |> main3 \r\n    |> main4\r\n```\r\n\r\ninside `main0` the command line argument are parsed and outfile/pdbfile path is set and passed to all other funcions ( `main1` to `main4` )\r\n\r\nthis pr add output/pdb/mdb to stream or file. \r\nThe output of assembly directly to memorystream works, pdb/mdb/signed require disk io with temp file.\r\n\r\nthe api to specify where send out/pdb/mdb is\r\n\r\n```fsharp\r\ntype EmitTo =\r\n    | EmittedFile of string\r\n    | EmittedStream of Stream\r\n``` \r\n\r\nwith error and deferred creation\r\n\r\n```fsharp\r\ntype EmitStreamProvider = Lazy<Choice<EmitTo, Diagnostic>>\r\ntype Diagnostic = string\r\n```\r\n\r\n1. `Choice<EmitTo, Diagnostic>`:\r\n  -  to use success/fail pattern instead of exception based control flow\r\n  - we can refactor (later) the control flow as computation expression  \r\n2. `Lazy`:\r\n  -  deferred creation\r\n  - once\r\n  - we can ask ( `Lazy.IsValueCreated` ) if the factory is called, and easy cleanup the files on error\r\n3. both `EmittedFile of string` and `EmittedStream of Stream` , not only `Stream`\r\n  - performance, useless continue to copy stream (build+sign, pdb) if i need a real file\r\n  - current implementation (pdb/sign) require file on disk, useless hide that complexity. if we later improve pdb/sign, this api is ok \r\n  - easy to consume api\r\n\r\nAs side note, roslyn do pretty much the same with [EmitStreamProvider](http://source.roslyn.codeplex.com/#Microsoft.CodeAnalysis/Compilation.EmitStreamProvider.cs,0a7a5f6ff635682d,references), so we can wrap later when a bridge is ready ( working on a partial bridge :smile: )\r\n\r\ni need a feedback about naming, i think is weak (for example `EmittedFile` -> `EmitToFile`? dunno)\r\n\r\n "},"comment":{"url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/comments/223990256","html_url":"https://github.com/Microsoft/visualfsharp/pull/715#issuecomment-223990256","issue_url":"https://api.github.com/repos/Microsoft/visualfsharp/issues/715","id":223990256,"user":{"login":"enricosada","id":147243,"avatar_url":"https://avatars.githubusercontent.com/u/147243?v=3","gravatar_id":"","url":"https://api.github.com/users/enricosada","html_url":"https://github.com/enricosada","followers_url":"https://api.github.com/users/enricosada/followers","following_url":"https://api.github.com/users/enricosada/following{/other_user}","gists_url":"https://api.github.com/users/enricosada/gists{/gist_id}","starred_url":"https://api.github.com/users/enricosada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enricosada/subscriptions","organizations_url":"https://api.github.com/users/enricosada/orgs","repos_url":"https://api.github.com/users/enricosada/repos","events_url":"https://api.github.com/users/enricosada/events{/privacy}","received_events_url":"https://api.github.com/users/enricosada/received_events","type":"User","site_admin":false},"created_at":"2016-06-06T15:15:55Z","updated_at":"2016-06-06T15:15:55Z","body":"i'll close now and reopen a new pr after a rebase, too much diff atm"}}
{"actor":{"display_login":"enricosada"}}