{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/buildtools/pulls/comments/73930531","id":73930531,"diff_hunk":"@@ -0,0 +1,38 @@\n+// Licensed to the .NET Foundation under one or more agreements.\n+// The .NET Foundation licenses this file to you under the MIT license.\n+// See the LICENSE file in the project root for more information.\n+\n+using System;\n+using System.Diagnostics;\n+using System.IO;\n+using System.Text;\n+\n+namespace Microsoft.DotNet.VersionTools.Util\n+{\n+    static class FileUtils\n+    {\n+        public static bool ReplaceFileContents(string path, Func<string, string> replacement)\n+        {\n+            string contents;\n+            Encoding encoding;\n+\n+            // Atttempt to preserve the file's encoding, using ASCII encoding (which has no BOM) if the file's\n+            // encoding cannot be detected. \n+            using (StreamReader reader = new StreamReader(new FileStream(path, FileMode.Open), Encoding.ASCII, true))","path":"src/Microsoft.DotNet.VersionTools/Util/FileUtils.cs","position":21,"original_position":21,"commit_id":"85446ddcbb1f7d15ee4491b5fea3d5266b69aaee","original_commit_id":"85446ddcbb1f7d15ee4491b5fea3d5266b69aaee","user":{"login":"eerhardt","id":8291187,"avatar_url":"https://avatars.githubusercontent.com/u/8291187?v=3","gravatar_id":"","url":"https://api.github.com/users/eerhardt","html_url":"https://github.com/eerhardt","followers_url":"https://api.github.com/users/eerhardt/followers","following_url":"https://api.github.com/users/eerhardt/following{/other_user}","gists_url":"https://api.github.com/users/eerhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/eerhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eerhardt/subscriptions","organizations_url":"https://api.github.com/users/eerhardt/orgs","repos_url":"https://api.github.com/users/eerhardt/repos","events_url":"https://api.github.com/users/eerhardt/events{/privacy}","received_events_url":"https://api.github.com/users/eerhardt/received_events","type":"User","site_admin":false},"body":"If you create the UTF8Encoding object yourself, you can create one that doesn't write a BOM.\r\n\r\n`new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)`\r\n\r\nThis is better because it handles unicode characters in the file.","created_at":"2016-08-08T18:42:35Z","updated_at":"2016-08-08T18:42:35Z","html_url":"https://github.com/dotnet/buildtools/pull/939#discussion_r73930531","pull_request_url":"https://api.github.com/repos/dotnet/buildtools/pulls/939","_links":{"self":{"href":"https://api.github.com/repos/dotnet/buildtools/pulls/comments/73930531"},"html":{"href":"https://github.com/dotnet/buildtools/pull/939#discussion_r73930531"},"pull_request":{"href":"https://api.github.com/repos/dotnet/buildtools/pulls/939"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/buildtools/pulls/939","id":80289974,"html_url":"https://github.com/dotnet/buildtools/pull/939","diff_url":"https://github.com/dotnet/buildtools/pull/939.diff","patch_url":"https://github.com/dotnet/buildtools/pull/939.patch","issue_url":"https://api.github.com/repos/dotnet/buildtools/issues/939","number":939,"state":"open","locked":false,"title":"Preserve BOM when updating files in VersionTools","user":{"login":"naamunds","id":8249261,"avatar_url":"https://avatars.githubusercontent.com/u/8249261?v=3","gravatar_id":"","url":"https://api.github.com/users/naamunds","html_url":"https://github.com/naamunds","followers_url":"https://api.github.com/users/naamunds/followers","following_url":"https://api.github.com/users/naamunds/following{/other_user}","gists_url":"https://api.github.com/users/naamunds/gists{/gist_id}","starred_url":"https://api.github.com/users/naamunds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naamunds/subscriptions","organizations_url":"https://api.github.com/users/naamunds/orgs","repos_url":"https://api.github.com/users/naamunds/repos","events_url":"https://api.github.com/users/naamunds/events{/privacy}","received_events_url":"https://api.github.com/users/naamunds/received_events","type":"User","site_admin":false},"body":"Fixes #935.\r\n\r\ncc: @dagood @eerhardt ","created_at":"2016-08-05T18:52:42Z","updated_at":"2016-08-08T18:42:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f2dfc9e80c6042db78dd83708cc16367d3100f3d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/buildtools/pulls/939/commits","review_comments_url":"https://api.github.com/repos/dotnet/buildtools/pulls/939/comments","review_comment_url":"https://api.github.com/repos/dotnet/buildtools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/buildtools/issues/939/comments","statuses_url":"https://api.github.com/repos/dotnet/buildtools/statuses/85446ddcbb1f7d15ee4491b5fea3d5266b69aaee","head":{"label":"naamunds:PreserveBom","ref":"PreserveBom","sha":"85446ddcbb1f7d15ee4491b5fea3d5266b69aaee","user":{"login":"naamunds","id":8249261,"avatar_url":"https://avatars.githubusercontent.com/u/8249261?v=3","gravatar_id":"","url":"https://api.github.com/users/naamunds","html_url":"https://github.com/naamunds","followers_url":"https://api.github.com/users/naamunds/followers","following_url":"https://api.github.com/users/naamunds/following{/other_user}","gists_url":"https://api.github.com/users/naamunds/gists{/gist_id}","starred_url":"https://api.github.com/users/naamunds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naamunds/subscriptions","organizations_url":"https://api.github.com/users/naamunds/orgs","repos_url":"https://api.github.com/users/naamunds/repos","events_url":"https://api.github.com/users/naamunds/events{/privacy}","received_events_url":"https://api.github.com/users/naamunds/received_events","type":"User","site_admin":false},"repo":{"id":39912245,"name":"buildtools","full_name":"naamunds/buildtools","owner":{"login":"naamunds","id":8249261,"avatar_url":"https://avatars.githubusercontent.com/u/8249261?v=3","gravatar_id":"","url":"https://api.github.com/users/naamunds","html_url":"https://github.com/naamunds","followers_url":"https://api.github.com/users/naamunds/followers","following_url":"https://api.github.com/users/naamunds/following{/other_user}","gists_url":"https://api.github.com/users/naamunds/gists{/gist_id}","starred_url":"https://api.github.com/users/naamunds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naamunds/subscriptions","organizations_url":"https://api.github.com/users/naamunds/orgs","repos_url":"https://api.github.com/users/naamunds/repos","events_url":"https://api.github.com/users/naamunds/events{/privacy}","received_events_url":"https://api.github.com/users/naamunds/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/naamunds/buildtools","description":"Build tools that are necessary for building the .NET Core projects","fork":true,"url":"https://api.github.com/repos/naamunds/buildtools","forks_url":"https://api.github.com/repos/naamunds/buildtools/forks","keys_url":"https://api.github.com/repos/naamunds/buildtools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/naamunds/buildtools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/naamunds/buildtools/teams","hooks_url":"https://api.github.com/repos/naamunds/buildtools/hooks","issue_events_url":"https://api.github.com/repos/naamunds/buildtools/issues/events{/number}","events_url":"https://api.github.com/repos/naamunds/buildtools/events","assignees_url":"https://api.github.com/repos/naamunds/buildtools/assignees{/user}","branches_url":"https://api.github.com/repos/naamunds/buildtools/branches{/branch}","tags_url":"https://api.github.com/repos/naamunds/buildtools/tags","blobs_url":"https://api.github.com/repos/naamunds/buildtools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/naamunds/buildtools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/naamunds/buildtools/git/refs{/sha}","trees_url":"https://api.github.com/repos/naamunds/buildtools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/naamunds/buildtools/statuses/{sha}","languages_url":"https://api.github.com/repos/naamunds/buildtools/languages","stargazers_url":"https://api.github.com/repos/naamunds/buildtools/stargazers","contributors_url":"https://api.github.com/repos/naamunds/buildtools/contributors","subscribers_url":"https://api.github.com/repos/naamunds/buildtools/subscribers","subscription_url":"https://api.github.com/repos/naamunds/buildtools/subscription","commits_url":"https://api.github.com/repos/naamunds/buildtools/commits{/sha}","git_commits_url":"https://api.github.com/repos/naamunds/buildtools/git/commits{/sha}","comments_url":"https://api.github.com/repos/naamunds/buildtools/comments{/number}","issue_comment_url":"https://api.github.com/repos/naamunds/buildtools/issues/comments{/number}","contents_url":"https://api.github.com/repos/naamunds/buildtools/contents/{+path}","compare_url":"https://api.github.com/repos/naamunds/buildtools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/naamunds/buildtools/merges","archive_url":"https://api.github.com/repos/naamunds/buildtools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/naamunds/buildtools/downloads","issues_url":"https://api.github.com/repos/naamunds/buildtools/issues{/number}","pulls_url":"https://api.github.com/repos/naamunds/buildtools/pulls{/number}","milestones_url":"https://api.github.com/repos/naamunds/buildtools/milestones{/number}","notifications_url":"https://api.github.com/repos/naamunds/buildtools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/naamunds/buildtools/labels{/name}","releases_url":"https://api.github.com/repos/naamunds/buildtools/releases{/id}","deployments_url":"https://api.github.com/repos/naamunds/buildtools/deployments","created_at":"2015-07-29T19:30:18Z","updated_at":"2016-01-21T21:50:47Z","pushed_at":"2016-08-05T18:51:28Z","git_url":"git://github.com/naamunds/buildtools.git","ssh_url":"git@github.com:naamunds/buildtools.git","clone_url":"https://github.com/naamunds/buildtools.git","svn_url":"https://github.com/naamunds/buildtools","homepage":"","size":3708,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"61a3697c517a348a5d72e4bf75c687e6c07c11a8","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295349,"name":"buildtools","full_name":"dotnet/buildtools","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/buildtools","description":"Build tools that are necessary for building the .NET Core projects","fork":false,"url":"https://api.github.com/repos/dotnet/buildtools","forks_url":"https://api.github.com/repos/dotnet/buildtools/forks","keys_url":"https://api.github.com/repos/dotnet/buildtools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/buildtools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/buildtools/teams","hooks_url":"https://api.github.com/repos/dotnet/buildtools/hooks","issue_events_url":"https://api.github.com/repos/dotnet/buildtools/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/buildtools/events","assignees_url":"https://api.github.com/repos/dotnet/buildtools/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/buildtools/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/buildtools/tags","blobs_url":"https://api.github.com/repos/dotnet/buildtools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/buildtools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/buildtools/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/buildtools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/buildtools/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/buildtools/languages","stargazers_url":"https://api.github.com/repos/dotnet/buildtools/stargazers","contributors_url":"https://api.github.com/repos/dotnet/buildtools/contributors","subscribers_url":"https://api.github.com/repos/dotnet/buildtools/subscribers","subscription_url":"https://api.github.com/repos/dotnet/buildtools/subscription","commits_url":"https://api.github.com/repos/dotnet/buildtools/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/buildtools/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/buildtools/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/buildtools/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/buildtools/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/buildtools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/buildtools/merges","archive_url":"https://api.github.com/repos/dotnet/buildtools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/buildtools/downloads","issues_url":"https://api.github.com/repos/dotnet/buildtools/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/buildtools/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/buildtools/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/buildtools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/buildtools/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/buildtools/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/buildtools/deployments","created_at":"2014-11-06T23:43:05Z","updated_at":"2016-08-04T10:36:28Z","pushed_at":"2016-08-08T18:15:26Z","git_url":"git://github.com/dotnet/buildtools.git","ssh_url":"git@github.com:dotnet/buildtools.git","clone_url":"https://github.com/dotnet/buildtools.git","svn_url":"https://github.com/dotnet/buildtools","homepage":"","size":4868,"stargazers_count":419,"watchers_count":419,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":199,"mirror_url":null,"open_issues_count":101,"forks":199,"open_issues":101,"watchers":419,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/buildtools/pulls/939"},"html":{"href":"https://github.com/dotnet/buildtools/pull/939"},"issue":{"href":"https://api.github.com/repos/dotnet/buildtools/issues/939"},"comments":{"href":"https://api.github.com/repos/dotnet/buildtools/issues/939/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/buildtools/pulls/939/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/buildtools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/buildtools/pulls/939/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/buildtools/statuses/85446ddcbb1f7d15ee4491b5fea3d5266b69aaee"}}}}
{"actor":{"display_login":"eerhardt"}}