{"action":"created","comment":{"url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments/36389677","id":36389677,"diff_hunk":"@@ -0,0 +1,95 @@\n+namespace StyleCop.Analyzers.OrderingRules\n+{\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 = syntaxRoot.FindNode(diagnostic.Location.SourceSpan).Ancestors().OfType<TypeDeclarationSyntax>().First();\n+                if (typeDeclarationNode == null)\n+                {\n+                    return document;\n+                }\n+\n+                var allFields = typeDeclarationNode.Members.OfType<FieldDeclarationSyntax>().ToArray();\n+                var fieldReplaced = false;\n+\n+                FieldDeclarationSyntax firstNonConst = null;\n+                foreach (var field in allFields)\n+                {\n+                    if (firstNonConst != null && field.Modifiers.Any(m => m.IsKind(SyntaxKind.ConstKeyword)))\n+                    {\n+                        syntaxRoot = MoveField(syntaxRoot, field, firstNonConst);\n+                        fieldReplaced = true;\n+                        break;\n+                    }\n+\n+                    if (firstNonConst == null && !field.Modifiers.Any(m => m.IsKind(SyntaxKind.ConstKeyword)))","path":"StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203CodeFixProvider.cs","position":70,"original_position":70,"commit_id":"2920dd47fe885ec2fcb0d0521ae8e3da37a836ce","original_commit_id":"2920dd47fe885ec2fcb0d0521ae8e3da37a836ce","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":"`field.Modifiers.Any(m => m.IsKind(SyntaxKind.ConstKeyword)`\r\ncould be computed once","created_at":"2015-08-06T08:03:26Z","updated_at":"2015-08-06T08:03:26Z","html_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1129#discussion_r36389677","pull_request_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1129","_links":{"self":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments/36389677"},"html":{"href":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1129#discussion_r36389677"},"pull_request":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1129"}}},"pull_request":{"url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1129","id":41753180,"html_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1129","diff_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1129.diff","patch_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1129.patch","issue_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/1129","number":1129,"state":"open","locked":false,"title":"Code fix for SA1203","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\nThis only checks constants. Which given the discussion seems the proper implementation for this rule. It doesn't touch statics/instance fields (although they might move as a result of inserting a node before that was previously after).","created_at":"2015-08-06T05:31:40Z","updated_at":"2015-08-06T08:03:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8ae2d068bbba8e11dac136659d6d8b94e6aeb9a1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1129/commits","review_comments_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1129/comments","review_comment_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/1129/comments","statuses_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/statuses/2920dd47fe885ec2fcb0d0521ae8e3da37a836ce","head":{"label":"hvanbakel:codefix-SA1203","ref":"codefix-SA1203","sha":"2920dd47fe885ec2fcb0d0521ae8e3da37a836ce","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-06T05:28:18Z","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":7851,"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":"42930ebeef95499f1e7939c5b26f52b5053d1868","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-05T13:50:21Z","pushed_at":"2015-08-06T05:31:41Z","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":7851,"stargazers_count":136,"watchers_count":136,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":161,"forks":36,"open_issues":161,"watchers":136,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1129"},"html":{"href":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/1129"},"issue":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/1129"},"comments":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/1129/comments"},"review_comments":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1129/comments"},"review_comment":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/1129/commits"},"statuses":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/statuses/2920dd47fe885ec2fcb0d0521ae8e3da37a836ce"}}}}