{"action":"created","comment":{"url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments/36585585","id":36585585,"diff_hunk":"@@ -0,0 +1,124 @@\n+using System;\n+\n+namespace StyleCop.Analyzers.OrderingRules\n+{\n+    using System.Collections.Generic;\n+    using System.Collections.Immutable;\n+    using System.Composition;\n+    using System.Linq;\n+    using System.Threading;\n+    using System.Threading.Tasks;\n+    using Microsoft.CodeAnalysis;\n+    using Microsoft.CodeAnalysis.CodeActions;\n+    using Microsoft.CodeAnalysis.CodeFixes;\n+    using Microsoft.CodeAnalysis.CSharp;\n+    using Microsoft.CodeAnalysis.CSharp.Syntax;\n+    using StyleCop.Analyzers.Helpers;\n+\n+    /// <summary>\n+    /// Implements code fixes for <see cref=\"SA1203ConstantsMustAppearBeforeFields\"/>.\n+    /// </summary>\n+    [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1203CodeFixProvider))]\n+    [Shared]\n+    public class SA1203CodeFixProvider : CodeFixProvider\n+    {\n+        private static readonly ImmutableArray<string> FixableDiagnostics =\n+            ImmutableArray.Create(SA1203ConstantsMustAppearBeforeFields.DiagnosticId);\n+\n+        /// <inheritdoc/>\n+        public override ImmutableArray<string> FixableDiagnosticIds => FixableDiagnostics;\n+\n+        /// <inheritdoc/>\n+        public override FixAllProvider GetFixAllProvider()\n+        {\n+            return WellKnownFixAllProviders.BatchFixer;\n+        }\n+\n+        /// <inheritdoc/>\n+        public override Task RegisterCodeFixesAsync(CodeFixContext context)\n+        {\n+            foreach (Diagnostic diagnostic in context.Diagnostics.Where(d => FixableDiagnostics.Contains(d.Id)))\n+            {\n+                context.RegisterCodeFix(CodeAction.Create(OrderingResources.SA1203CodeFix, token => GetTransformedDocumentAsync(context.Document, diagnostic, token), equivalenceKey: nameof(SA1203CodeFixProvider)), diagnostic);\n+            }\n+\n+            return SpecializedTasks.CompletedTask;\n+        }\n+\n+        private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)\n+        {\n+            var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);\n+\n+            while (true)\n+            {\n+                var typeDeclarationNode =\n+                    syntaxRoot.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<TypeDeclarationSyntax>();\n+\n+                var fieldReplaced = false;\n+\n+                var allFields = GetOrderHelperForFields(typeDeclarationNode);","path":"StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203CodeFixProvider.cs","position":59,"original_position":59,"commit_id":"6e043646eb6924592115cc9dbf6682a92464c842","original_commit_id":"6e043646eb6924592115cc9dbf6682a92464c842","user":{"login":"Maxwe11","id":1083827,"avatar_url":"https://avatars.githubusercontent.com/u/1083827?v=3","gravatar_id":"","url":"https://api.github.com/users/Maxwe11","html_url":"https://github.com/Maxwe11","followers_url":"https://api.github.com/users/Maxwe11/followers","following_url":"https://api.github.com/users/Maxwe11/following{/other_user}","gists_url":"https://api.github.com/users/Maxwe11/gists{/gist_id}","starred_url":"https://api.github.com/users/Maxwe11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Maxwe11/subscriptions","organizations_url":"https://api.github.com/users/Maxwe11/orgs","repos_url":"https://api.github.com/users/Maxwe11/repos","events_url":"https://api.github.com/users/Maxwe11/events{/privacy}","received_events_url":"https://api.github.com/users/Maxwe11/received_events","type":"User","site_admin":false},"body":"for same declaration we will allocate new list with same fields","created_at":"2015-08-09T08:19:04Z","updated_at":"2015-08-09T08:19:04Z","html_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1167#discussion_r36585585","pull_request_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1167","_links":{"self":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments/36585585"},"html":{"href":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1167#discussion_r36585585"},"pull_request":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1167"}}},"pull_request":{"url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1167","id":41964058,"html_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1167","diff_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1167.diff","patch_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1167.patch","issue_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/1167","number":1167,"state":"open","locked":false,"title":"Codefix sa1203 take2","user":{"login":"hvanbakel","id":4130108,"avatar_url":"https://avatars.githubusercontent.com/u/4130108?v=3","gravatar_id":"","url":"https://api.github.com/users/hvanbakel","html_url":"https://github.com/hvanbakel","followers_url":"https://api.github.com/users/hvanbakel/followers","following_url":"https://api.github.com/users/hvanbakel/following{/other_user}","gists_url":"https://api.github.com/users/hvanbakel/gists{/gist_id}","starred_url":"https://api.github.com/users/hvanbakel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvanbakel/subscriptions","organizations_url":"https://api.github.com/users/hvanbakel/orgs","repos_url":"https://api.github.com/users/hvanbakel/repos","events_url":"https://api.github.com/users/hvanbakel/events{/privacy}","received_events_url":"https://api.github.com/users/hvanbakel/received_events","type":"User","site_admin":false},"body":"Fix for #1104 \r\n\r\nNew branch, with the proper commits. Maybe the flag enum solution can work for other tests as well. I haven't implemented this in the analyzer, it's now just used for the code fix.","created_at":"2015-08-09T02:17:26Z","updated_at":"2015-08-09T08:19:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6eb031270369422f9db6268ff7f500ef7e27ecd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1167/commits","review_comments_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1167/comments","review_comment_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/1167/comments","statuses_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/statuses/6e043646eb6924592115cc9dbf6682a92464c842","head":{"label":"hvanbakel:codefix-SA1203-take2","ref":"codefix-SA1203-take2","sha":"6e043646eb6924592115cc9dbf6682a92464c842","user":{"login":"hvanbakel","id":4130108,"avatar_url":"https://avatars.githubusercontent.com/u/4130108?v=3","gravatar_id":"","url":"https://api.github.com/users/hvanbakel","html_url":"https://github.com/hvanbakel","followers_url":"https://api.github.com/users/hvanbakel/followers","following_url":"https://api.github.com/users/hvanbakel/following{/other_user}","gists_url":"https://api.github.com/users/hvanbakel/gists{/gist_id}","starred_url":"https://api.github.com/users/hvanbakel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvanbakel/subscriptions","organizations_url":"https://api.github.com/users/hvanbakel/orgs","repos_url":"https://api.github.com/users/hvanbakel/repos","events_url":"https://api.github.com/users/hvanbakel/events{/privacy}","received_events_url":"https://api.github.com/users/hvanbakel/received_events","type":"User","site_admin":false},"repo":{"id":40282840,"name":"StyleCopAnalyzers","full_name":"hvanbakel/StyleCopAnalyzers","owner":{"login":"hvanbakel","id":4130108,"avatar_url":"https://avatars.githubusercontent.com/u/4130108?v=3","gravatar_id":"","url":"https://api.github.com/users/hvanbakel","html_url":"https://github.com/hvanbakel","followers_url":"https://api.github.com/users/hvanbakel/followers","following_url":"https://api.github.com/users/hvanbakel/following{/other_user}","gists_url":"https://api.github.com/users/hvanbakel/gists{/gist_id}","starred_url":"https://api.github.com/users/hvanbakel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvanbakel/subscriptions","organizations_url":"https://api.github.com/users/hvanbakel/orgs","repos_url":"https://api.github.com/users/hvanbakel/repos","events_url":"https://api.github.com/users/hvanbakel/events{/privacy}","received_events_url":"https://api.github.com/users/hvanbakel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hvanbakel/StyleCopAnalyzers","description":"An implementation of StyleCop rules using the .NET Compiler Platform","fork":true,"url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers","forks_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/forks","keys_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/teams","hooks_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/hooks","issue_events_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/issues/events{/number}","events_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/events","assignees_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/assignees{/user}","branches_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/branches{/branch}","tags_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/tags","blobs_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/git/refs{/sha}","trees_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/statuses/{sha}","languages_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/languages","stargazers_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/stargazers","contributors_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/contributors","subscribers_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/subscribers","subscription_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/subscription","commits_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/commits{/sha}","git_commits_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/git/commits{/sha}","comments_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/comments{/number}","issue_comment_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/issues/comments{/number}","contents_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/contents/{+path}","compare_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/merges","archive_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/downloads","issues_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/issues{/number}","pulls_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/pulls{/number}","milestones_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/milestones{/number}","notifications_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/labels{/name}","releases_url":"https://api.github.com/repos/hvanbakel/StyleCopAnalyzers/releases{/id}","created_at":"2015-08-06T03:42:39Z","updated_at":"2015-08-06T03:42:43Z","pushed_at":"2015-08-09T02:32:47Z","git_url":"git://github.com/hvanbakel/StyleCopAnalyzers.git","ssh_url":"git@github.com:hvanbakel/StyleCopAnalyzers.git","clone_url":"https://github.com/hvanbakel/StyleCopAnalyzers.git","svn_url":"https://github.com/hvanbakel/StyleCopAnalyzers","homepage":null,"size":6790,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"DotNetAnalyzers:master","ref":"master","sha":"2c9b10144e7764629aedc0d1b39c9608ba0f9218","user":{"login":"DotNetAnalyzers","id":9735576,"avatar_url":"https://avatars.githubusercontent.com/u/9735576?v=3","gravatar_id":"","url":"https://api.github.com/users/DotNetAnalyzers","html_url":"https://github.com/DotNetAnalyzers","followers_url":"https://api.github.com/users/DotNetAnalyzers/followers","following_url":"https://api.github.com/users/DotNetAnalyzers/following{/other_user}","gists_url":"https://api.github.com/users/DotNetAnalyzers/gists{/gist_id}","starred_url":"https://api.github.com/users/DotNetAnalyzers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DotNetAnalyzers/subscriptions","organizations_url":"https://api.github.com/users/DotNetAnalyzers/orgs","repos_url":"https://api.github.com/users/DotNetAnalyzers/repos","events_url":"https://api.github.com/users/DotNetAnalyzers/events{/privacy}","received_events_url":"https://api.github.com/users/DotNetAnalyzers/received_events","type":"Organization","site_admin":false},"repo":{"id":26768275,"name":"StyleCopAnalyzers","full_name":"DotNetAnalyzers/StyleCopAnalyzers","owner":{"login":"DotNetAnalyzers","id":9735576,"avatar_url":"https://avatars.githubusercontent.com/u/9735576?v=3","gravatar_id":"","url":"https://api.github.com/users/DotNetAnalyzers","html_url":"https://github.com/DotNetAnalyzers","followers_url":"https://api.github.com/users/DotNetAnalyzers/followers","following_url":"https://api.github.com/users/DotNetAnalyzers/following{/other_user}","gists_url":"https://api.github.com/users/DotNetAnalyzers/gists{/gist_id}","starred_url":"https://api.github.com/users/DotNetAnalyzers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DotNetAnalyzers/subscriptions","organizations_url":"https://api.github.com/users/DotNetAnalyzers/orgs","repos_url":"https://api.github.com/users/DotNetAnalyzers/repos","events_url":"https://api.github.com/users/DotNetAnalyzers/events{/privacy}","received_events_url":"https://api.github.com/users/DotNetAnalyzers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers","description":"An implementation of StyleCop rules using the .NET Compiler Platform","fork":false,"url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers","forks_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/forks","keys_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/teams","hooks_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/hooks","issue_events_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/events{/number}","events_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/events","assignees_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/assignees{/user}","branches_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/branches{/branch}","tags_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/tags","blobs_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/refs{/sha}","trees_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/statuses/{sha}","languages_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/languages","stargazers_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/stargazers","contributors_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/contributors","subscribers_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/subscribers","subscription_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/subscription","commits_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/commits{/sha}","git_commits_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/commits{/sha}","comments_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/comments{/number}","issue_comment_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/comments{/number}","contents_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/contents/{+path}","compare_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/merges","archive_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/downloads","issues_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues{/number}","pulls_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls{/number}","milestones_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/milestones{/number}","notifications_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/labels{/name}","releases_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/releases{/id}","created_at":"2014-11-17T17:29:54Z","updated_at":"2015-08-08T08:39:20Z","pushed_at":"2015-08-09T02:17:26Z","git_url":"git://github.com/DotNetAnalyzers/StyleCopAnalyzers.git","ssh_url":"git@github.com:DotNetAnalyzers/StyleCopAnalyzers.git","clone_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers.git","svn_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers","homepage":null,"size":10217,"stargazers_count":140,"watchers_count":140,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":37,"mirror_url":null,"open_issues_count":155,"forks":37,"open_issues":155,"watchers":140,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1167"},"html":{"href":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1167"},"issue":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/1167"},"comments":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/1167/comments"},"review_comments":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1167/comments"},"review_comment":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1167/commits"},"statuses":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/statuses/6e043646eb6924592115cc9dbf6682a92464c842"}}}}