{"action":"created","comment":{"url":"https://api.github.com/repos/PowerShell/PowerShell/pulls/comments/147495102","pull_request_review_id":72604893,"id":147495102,"diff_hunk":"@@ -932,13 +910,22 @@ protected override void EndProcessing()\n             {\n                 // Load the source if they want to load from a file\n                 if (String.Equals(ParameterSetName, \"FromPath\", StringComparison.OrdinalIgnoreCase) ||\n-                    String.Equals(ParameterSetName, \"FromLiteralPath\", StringComparison.OrdinalIgnoreCase))\n+                    String.Equals(ParameterSetName, \"FromLiteralPath\", StringComparison.OrdinalIgnoreCase)\n+                   )\n                 {\n-                    this.sourceCode = \"\";\n+                    StringBuilder sb = new StringBuilder(paths.Length);\n+\n                     foreach (string file in paths)\n                     {\n-                        this.sourceCode += System.IO.File.ReadAllText(file) + \"\\n\";\n+                        sb.Append(System.IO.File.ReadAllText(file));","path":"src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs","position":null,"original_position":92,"commit_id":"fc1a6d96f45db6c87a013ffaea62d0d102fe107d","original_commit_id":"d0d4cc7514ef1ac2b4e556d91e161d1fd6f88bfb","user":{"login":"daxian-dbw","id":127450,"avatar_url":"https://avatars2.githubusercontent.com/u/127450?v=4","gravatar_id":"","url":"https://api.github.com/users/daxian-dbw","html_url":"https://github.com/daxian-dbw","followers_url":"https://api.github.com/users/daxian-dbw/followers","following_url":"https://api.github.com/users/daxian-dbw/following{/other_user}","gists_url":"https://api.github.com/users/daxian-dbw/gists{/gist_id}","starred_url":"https://api.github.com/users/daxian-dbw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daxian-dbw/subscriptions","organizations_url":"https://api.github.com/users/daxian-dbw/orgs","repos_url":"https://api.github.com/users/daxian-dbw/repos","events_url":"https://api.github.com/users/daxian-dbw/events{/privacy}","received_events_url":"https://api.github.com/users/daxian-dbw/received_events","type":"User","site_admin":false},"body":"I don't understand your comment about `CompileAssemblyFromFile` (is it a class?). Could you please elaborate it a bit more? I quickly search about `CSharpSyntaxTree.ParseText`, and didn't find a good way to make it consume multiple files all together directly from files. That API takes a `SourceText` type, which has a static method `Create` that takes a file path, but not multiple files. But I'm sure there should be ways to do it, otherwise, how would a compiler to work 😄.\r\n\r\nFor some background, the perf issue of Add-Type was reported by Azure Profiler team. They find this exact code causes a lot LOH allocations in some services and if we treat the `path.length == 1` case specially, we can save, as quoted, \"5.39 million samples here, or around 1% of total PowerShell.exe CPU cost\". It was about the windows powershell, but this piece of code is same for powershell core.","created_at":"2017-10-27T19:15:54Z","updated_at":"2017-10-27T19:15:54Z","html_url":"https://github.com/PowerShell/PowerShell/pull/5243#discussion_r147495102","pull_request_url":"https://api.github.com/repos/PowerShell/PowerShell/pulls/5243","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/PowerShell/PowerShell/pulls/comments/147495102"},"html":{"href":"https://github.com/PowerShell/PowerShell/pull/5243#discussion_r147495102"},"pull_request":{"href":"https://api.github.com/repos/PowerShell/PowerShell/pulls/5243"}},"in_reply_to_id":147264339},"pull_request":{"url":"https://api.github.com/repos/PowerShell/PowerShell/pulls/5243","id":148942459,"html_url":"https://github.com/PowerShell/PowerShell/pull/5243","diff_url":"https://github.com/PowerShell/PowerShell/pull/5243.diff","patch_url":"https://github.com/PowerShell/PowerShell/pull/5243.patch","issue_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/5243","number":5243,"state":"open","locked":false,"title":"Fix performance issues in Add-Type","user":{"login":"iSazonov","id":22290914,"avatar_url":"https://avatars2.githubusercontent.com/u/22290914?v=4","gravatar_id":"","url":"https://api.github.com/users/iSazonov","html_url":"https://github.com/iSazonov","followers_url":"https://api.github.com/users/iSazonov/followers","following_url":"https://api.github.com/users/iSazonov/following{/other_user}","gists_url":"https://api.github.com/users/iSazonov/gists{/gist_id}","starred_url":"https://api.github.com/users/iSazonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iSazonov/subscriptions","organizations_url":"https://api.github.com/users/iSazonov/orgs","repos_url":"https://api.github.com/users/iSazonov/repos","events_url":"https://api.github.com/users/iSazonov/events{/privacy}","received_events_url":"https://api.github.com/users/iSazonov/received_events","type":"User","site_admin":false},"body":"Related #5158.\r\n\r\n### Fix description\r\n\r\nCommit 1. Minor optimizations in `OutputError()`.\r\n\r\nCommit 2. Before the fix we read sources files twice in base.EndProcessing() and in this.EndProcessing() - it is excluded. Also now we read source files in StringBuilder to exclude large reallocations. Added one test.\r\n\r\n### Additional considerations\r\nI expect the fix remove performance issues reported in #5158. So we can close the Issue by the PR and open new Issue to discuss refactoring the code to use ` CompileAssemblyFromFile()`. Using Roslyn can open paths to enhance the Add-Type cmdlet's capabilities but requires a lot of work.","created_at":"2017-10-26T13:57:35Z","updated_at":"2017-10-27T19:15:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a4b4d643bd251454b4109b4c83176c80182a98e","assignee":{"login":"iSazonov","id":22290914,"avatar_url":"https://avatars2.githubusercontent.com/u/22290914?v=4","gravatar_id":"","url":"https://api.github.com/users/iSazonov","html_url":"https://github.com/iSazonov","followers_url":"https://api.github.com/users/iSazonov/followers","following_url":"https://api.github.com/users/iSazonov/following{/other_user}","gists_url":"https://api.github.com/users/iSazonov/gists{/gist_id}","starred_url":"https://api.github.com/users/iSazonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iSazonov/subscriptions","organizations_url":"https://api.github.com/users/iSazonov/orgs","repos_url":"https://api.github.com/users/iSazonov/repos","events_url":"https://api.github.com/users/iSazonov/events{/privacy}","received_events_url":"https://api.github.com/users/iSazonov/received_events","type":"User","site_admin":false},"assignees":[{"login":"iSazonov","id":22290914,"avatar_url":"https://avatars2.githubusercontent.com/u/22290914?v=4","gravatar_id":"","url":"https://api.github.com/users/iSazonov","html_url":"https://github.com/iSazonov","followers_url":"https://api.github.com/users/iSazonov/followers","following_url":"https://api.github.com/users/iSazonov/following{/other_user}","gists_url":"https://api.github.com/users/iSazonov/gists{/gist_id}","starred_url":"https://api.github.com/users/iSazonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iSazonov/subscriptions","organizations_url":"https://api.github.com/users/iSazonov/orgs","repos_url":"https://api.github.com/users/iSazonov/repos","events_url":"https://api.github.com/users/iSazonov/events{/privacy}","received_events_url":"https://api.github.com/users/iSazonov/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"lzybkr","id":2148248,"avatar_url":"https://avatars3.githubusercontent.com/u/2148248?v=4","gravatar_id":"","url":"https://api.github.com/users/lzybkr","html_url":"https://github.com/lzybkr","followers_url":"https://api.github.com/users/lzybkr/followers","following_url":"https://api.github.com/users/lzybkr/following{/other_user}","gists_url":"https://api.github.com/users/lzybkr/gists{/gist_id}","starred_url":"https://api.github.com/users/lzybkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lzybkr/subscriptions","organizations_url":"https://api.github.com/users/lzybkr/orgs","repos_url":"https://api.github.com/users/lzybkr/repos","events_url":"https://api.github.com/users/lzybkr/events{/privacy}","received_events_url":"https://api.github.com/users/lzybkr/received_events","type":"User","site_admin":false},{"login":"JamesWTruher","id":10214008,"avatar_url":"https://avatars2.githubusercontent.com/u/10214008?v=4","gravatar_id":"","url":"https://api.github.com/users/JamesWTruher","html_url":"https://github.com/JamesWTruher","followers_url":"https://api.github.com/users/JamesWTruher/followers","following_url":"https://api.github.com/users/JamesWTruher/following{/other_user}","gists_url":"https://api.github.com/users/JamesWTruher/gists{/gist_id}","starred_url":"https://api.github.com/users/JamesWTruher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JamesWTruher/subscriptions","organizations_url":"https://api.github.com/users/JamesWTruher/orgs","repos_url":"https://api.github.com/users/JamesWTruher/repos","events_url":"https://api.github.com/users/JamesWTruher/events{/privacy}","received_events_url":"https://api.github.com/users/JamesWTruher/received_events","type":"User","site_admin":false},{"login":"dantraMSFT","id":12105071,"avatar_url":"https://avatars0.githubusercontent.com/u/12105071?v=4","gravatar_id":"","url":"https://api.github.com/users/dantraMSFT","html_url":"https://github.com/dantraMSFT","followers_url":"https://api.github.com/users/dantraMSFT/followers","following_url":"https://api.github.com/users/dantraMSFT/following{/other_user}","gists_url":"https://api.github.com/users/dantraMSFT/gists{/gist_id}","starred_url":"https://api.github.com/users/dantraMSFT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dantraMSFT/subscriptions","organizations_url":"https://api.github.com/users/dantraMSFT/orgs","repos_url":"https://api.github.com/users/dantraMSFT/repos","events_url":"https://api.github.com/users/dantraMSFT/events{/privacy}","received_events_url":"https://api.github.com/users/dantraMSFT/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/PowerShell/PowerShell/pulls/5243/commits","review_comments_url":"https://api.github.com/repos/PowerShell/PowerShell/pulls/5243/comments","review_comment_url":"https://api.github.com/repos/PowerShell/PowerShell/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/5243/comments","statuses_url":"https://api.github.com/repos/PowerShell/PowerShell/statuses/fc1a6d96f45db6c87a013ffaea62d0d102fe107d","head":{"label":"iSazonov:exclude-readalltext","ref":"exclude-readalltext","sha":"fc1a6d96f45db6c87a013ffaea62d0d102fe107d","user":{"login":"iSazonov","id":22290914,"avatar_url":"https://avatars2.githubusercontent.com/u/22290914?v=4","gravatar_id":"","url":"https://api.github.com/users/iSazonov","html_url":"https://github.com/iSazonov","followers_url":"https://api.github.com/users/iSazonov/followers","following_url":"https://api.github.com/users/iSazonov/following{/other_user}","gists_url":"https://api.github.com/users/iSazonov/gists{/gist_id}","starred_url":"https://api.github.com/users/iSazonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iSazonov/subscriptions","organizations_url":"https://api.github.com/users/iSazonov/orgs","repos_url":"https://api.github.com/users/iSazonov/repos","events_url":"https://api.github.com/users/iSazonov/events{/privacy}","received_events_url":"https://api.github.com/users/iSazonov/received_events","type":"User","site_admin":false},"repo":{"id":69433034,"name":"PowerShell","full_name":"iSazonov/PowerShell","owner":{"login":"iSazonov","id":22290914,"avatar_url":"https://avatars2.githubusercontent.com/u/22290914?v=4","gravatar_id":"","url":"https://api.github.com/users/iSazonov","html_url":"https://github.com/iSazonov","followers_url":"https://api.github.com/users/iSazonov/followers","following_url":"https://api.github.com/users/iSazonov/following{/other_user}","gists_url":"https://api.github.com/users/iSazonov/gists{/gist_id}","starred_url":"https://api.github.com/users/iSazonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iSazonov/subscriptions","organizations_url":"https://api.github.com/users/iSazonov/orgs","repos_url":"https://api.github.com/users/iSazonov/repos","events_url":"https://api.github.com/users/iSazonov/events{/privacy}","received_events_url":"https://api.github.com/users/iSazonov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iSazonov/PowerShell","description":"PowerShell for every system!","fork":true,"url":"https://api.github.com/repos/iSazonov/PowerShell","forks_url":"https://api.github.com/repos/iSazonov/PowerShell/forks","keys_url":"https://api.github.com/repos/iSazonov/PowerShell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iSazonov/PowerShell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iSazonov/PowerShell/teams","hooks_url":"https://api.github.com/repos/iSazonov/PowerShell/hooks","issue_events_url":"https://api.github.com/repos/iSazonov/PowerShell/issues/events{/number}","events_url":"https://api.github.com/repos/iSazonov/PowerShell/events","assignees_url":"https://api.github.com/repos/iSazonov/PowerShell/assignees{/user}","branches_url":"https://api.github.com/repos/iSazonov/PowerShell/branches{/branch}","tags_url":"https://api.github.com/repos/iSazonov/PowerShell/tags","blobs_url":"https://api.github.com/repos/iSazonov/PowerShell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iSazonov/PowerShell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iSazonov/PowerShell/git/refs{/sha}","trees_url":"https://api.github.com/repos/iSazonov/PowerShell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iSazonov/PowerShell/statuses/{sha}","languages_url":"https://api.github.com/repos/iSazonov/PowerShell/languages","stargazers_url":"https://api.github.com/repos/iSazonov/PowerShell/stargazers","contributors_url":"https://api.github.com/repos/iSazonov/PowerShell/contributors","subscribers_url":"https://api.github.com/repos/iSazonov/PowerShell/subscribers","subscription_url":"https://api.github.com/repos/iSazonov/PowerShell/subscription","commits_url":"https://api.github.com/repos/iSazonov/PowerShell/commits{/sha}","git_commits_url":"https://api.github.com/repos/iSazonov/PowerShell/git/commits{/sha}","comments_url":"https://api.github.com/repos/iSazonov/PowerShell/comments{/number}","issue_comment_url":"https://api.github.com/repos/iSazonov/PowerShell/issues/comments{/number}","contents_url":"https://api.github.com/repos/iSazonov/PowerShell/contents/{+path}","compare_url":"https://api.github.com/repos/iSazonov/PowerShell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iSazonov/PowerShell/merges","archive_url":"https://api.github.com/repos/iSazonov/PowerShell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iSazonov/PowerShell/downloads","issues_url":"https://api.github.com/repos/iSazonov/PowerShell/issues{/number}","pulls_url":"https://api.github.com/repos/iSazonov/PowerShell/pulls{/number}","milestones_url":"https://api.github.com/repos/iSazonov/PowerShell/milestones{/number}","notifications_url":"https://api.github.com/repos/iSazonov/PowerShell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iSazonov/PowerShell/labels{/name}","releases_url":"https://api.github.com/repos/iSazonov/PowerShell/releases{/id}","deployments_url":"https://api.github.com/repos/iSazonov/PowerShell/deployments","created_at":"2016-09-28T06:30:22Z","updated_at":"2017-02-07T09:21:08Z","pushed_at":"2017-10-27T15:47:55Z","git_url":"git://github.com/iSazonov/PowerShell.git","ssh_url":"git@github.com:iSazonov/PowerShell.git","clone_url":"https://github.com/iSazonov/PowerShell.git","svn_url":"https://github.com/iSazonov/PowerShell","homepage":"https://microsoft.com/powershell","size":29626,"stargazers_count":1,"watchers_count":1,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"PowerShell:master","ref":"master","sha":"282deb7ee10d3e11854f1ba1c41adb26ccca0d59","user":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars3.githubusercontent.com/u/11524380?v=4","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"repo":{"id":49609581,"name":"PowerShell","full_name":"PowerShell/PowerShell","owner":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars3.githubusercontent.com/u/11524380?v=4","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PowerShell/PowerShell","description":"PowerShell for every system!","fork":false,"url":"https://api.github.com/repos/PowerShell/PowerShell","forks_url":"https://api.github.com/repos/PowerShell/PowerShell/forks","keys_url":"https://api.github.com/repos/PowerShell/PowerShell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PowerShell/PowerShell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PowerShell/PowerShell/teams","hooks_url":"https://api.github.com/repos/PowerShell/PowerShell/hooks","issue_events_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/events{/number}","events_url":"https://api.github.com/repos/PowerShell/PowerShell/events","assignees_url":"https://api.github.com/repos/PowerShell/PowerShell/assignees{/user}","branches_url":"https://api.github.com/repos/PowerShell/PowerShell/branches{/branch}","tags_url":"https://api.github.com/repos/PowerShell/PowerShell/tags","blobs_url":"https://api.github.com/repos/PowerShell/PowerShell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PowerShell/PowerShell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PowerShell/PowerShell/git/refs{/sha}","trees_url":"https://api.github.com/repos/PowerShell/PowerShell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PowerShell/PowerShell/statuses/{sha}","languages_url":"https://api.github.com/repos/PowerShell/PowerShell/languages","stargazers_url":"https://api.github.com/repos/PowerShell/PowerShell/stargazers","contributors_url":"https://api.github.com/repos/PowerShell/PowerShell/contributors","subscribers_url":"https://api.github.com/repos/PowerShell/PowerShell/subscribers","subscription_url":"https://api.github.com/repos/PowerShell/PowerShell/subscription","commits_url":"https://api.github.com/repos/PowerShell/PowerShell/commits{/sha}","git_commits_url":"https://api.github.com/repos/PowerShell/PowerShell/git/commits{/sha}","comments_url":"https://api.github.com/repos/PowerShell/PowerShell/comments{/number}","issue_comment_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/comments{/number}","contents_url":"https://api.github.com/repos/PowerShell/PowerShell/contents/{+path}","compare_url":"https://api.github.com/repos/PowerShell/PowerShell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PowerShell/PowerShell/merges","archive_url":"https://api.github.com/repos/PowerShell/PowerShell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PowerShell/PowerShell/downloads","issues_url":"https://api.github.com/repos/PowerShell/PowerShell/issues{/number}","pulls_url":"https://api.github.com/repos/PowerShell/PowerShell/pulls{/number}","milestones_url":"https://api.github.com/repos/PowerShell/PowerShell/milestones{/number}","notifications_url":"https://api.github.com/repos/PowerShell/PowerShell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PowerShell/PowerShell/labels{/name}","releases_url":"https://api.github.com/repos/PowerShell/PowerShell/releases{/id}","deployments_url":"https://api.github.com/repos/PowerShell/PowerShell/deployments","created_at":"2016-01-13T23:41:35Z","updated_at":"2017-10-27T13:37:43Z","pushed_at":"2017-10-27T18:57:22Z","git_url":"git://github.com/PowerShell/PowerShell.git","ssh_url":"git@github.com:PowerShell/PowerShell.git","clone_url":"https://github.com/PowerShell/PowerShell.git","svn_url":"https://github.com/PowerShell/PowerShell","homepage":"https://microsoft.com/powershell","size":30775,"stargazers_count":8158,"watchers_count":8158,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1209,"mirror_url":null,"archived":false,"open_issues_count":1045,"forks":1209,"open_issues":1045,"watchers":8158,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PowerShell/PowerShell/pulls/5243"},"html":{"href":"https://github.com/PowerShell/PowerShell/pull/5243"},"issue":{"href":"https://api.github.com/repos/PowerShell/PowerShell/issues/5243"},"comments":{"href":"https://api.github.com/repos/PowerShell/PowerShell/issues/5243/comments"},"review_comments":{"href":"https://api.github.com/repos/PowerShell/PowerShell/pulls/5243/comments"},"review_comment":{"href":"https://api.github.com/repos/PowerShell/PowerShell/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PowerShell/PowerShell/pulls/5243/commits"},"statuses":{"href":"https://api.github.com/repos/PowerShell/PowerShell/statuses/fc1a6d96f45db6c87a013ffaea62d0d102fe107d"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"daxian-dbw"}}