{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/2643","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/2643/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/2643/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/2643/events","html_url":"https://github.com/dotnet/roslyn/issues/2643","id":75291865,"number":2643,"title":"RegisterCodeFixesAsync does not indicate which diagnostics are in the context","user":{"login":"sharwell","id":1408396,"avatar_url":"https://avatars.githubusercontent.com/u/1408396?v=3","gravatar_id":"","url":"https://api.github.com/users/sharwell","html_url":"https://github.com/sharwell","followers_url":"https://api.github.com/users/sharwell/followers","following_url":"https://api.github.com/users/sharwell/following{/other_user}","gists_url":"https://api.github.com/users/sharwell/gists{/gist_id}","starred_url":"https://api.github.com/users/sharwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharwell/subscriptions","organizations_url":"https://api.github.com/users/sharwell/orgs","repos_url":"https://api.github.com/users/sharwell/repos","events_url":"https://api.github.com/users/sharwell/events{/privacy}","received_events_url":"https://api.github.com/users/sharwell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Analyzers","name":"Area-Analyzers","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Bug","name":"Bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"mavasani","id":10605811,"avatar_url":"https://avatars.githubusercontent.com/u/10605811?v=3","gravatar_id":"","url":"https://api.github.com/users/mavasani","html_url":"https://github.com/mavasani","followers_url":"https://api.github.com/users/mavasani/followers","following_url":"https://api.github.com/users/mavasani/following{/other_user}","gists_url":"https://api.github.com/users/mavasani/gists{/gist_id}","starred_url":"https://api.github.com/users/mavasani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mavasani/subscriptions","organizations_url":"https://api.github.com/users/mavasani/orgs","repos_url":"https://api.github.com/users/mavasani/repos","events_url":"https://api.github.com/users/mavasani/events{/privacy}","received_events_url":"https://api.github.com/users/mavasani/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dotnet/roslyn/milestones/1","html_url":"https://github.com/dotnet/roslyn/milestones/1.0%20(stable)","labels_url":"https://api.github.com/repos/dotnet/roslyn/milestones/1/labels","id":937397,"number":1,"title":"1.0 (stable)","description":"This is our 1.0 Milestone. ","creator":{"login":"jaredpar","id":146967,"avatar_url":"https://avatars.githubusercontent.com/u/146967?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"open_issues":111,"closed_issues":409,"state":"open","created_at":"2015-01-15T20:45:24Z","updated_at":"2015-05-18T21:05:13Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-05-11T17:12:37Z","updated_at":"2015-05-18T21:16:41Z","closed_at":null,"body":"The [documentation for `CodeFixProvider.RegisterCodeFixesAsync`](https://github.com/dotnet/roslyn/blob/9e392f1cf230ae6af3d560150097a7c40681b197/src/Workspaces/Core/Portable/CodeFixes/CodeFixProvider.cs#L19-L22) does not indicate whether or not the `CodeFixContext.Diagnostics` property is allowed to contain diagnostics which are not present in the result of `FixableDiagnostics` for the same `CodeFixProvider`.\r\n\r\nUnfortunately, if this precondition is not documented, we cannot use it as a [simplifying assumption in our code fixes](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/acb3ffb8be59448a8cbcf963c36195186e4676bc/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205CodeFixProvider.cs#L36)."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/103214159","html_url":"https://github.com/dotnet/roslyn/issues/2643#issuecomment-103214159","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/2643","id":103214159,"user":{"login":"mavasani","id":10605811,"avatar_url":"https://avatars.githubusercontent.com/u/10605811?v=3","gravatar_id":"","url":"https://api.github.com/users/mavasani","html_url":"https://github.com/mavasani","followers_url":"https://api.github.com/users/mavasani/followers","following_url":"https://api.github.com/users/mavasani/following{/other_user}","gists_url":"https://api.github.com/users/mavasani/gists{/gist_id}","starred_url":"https://api.github.com/users/mavasani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mavasani/subscriptions","organizations_url":"https://api.github.com/users/mavasani/orgs","repos_url":"https://api.github.com/users/mavasani/repos","events_url":"https://api.github.com/users/mavasani/events{/privacy}","received_events_url":"https://api.github.com/users/mavasani/received_events","type":"User","site_admin":false},"created_at":"2015-05-18T21:16:41Z","updated_at":"2015-05-18T21:16:41Z","body":"@sharwell @shyamnamboodiripad @Srivatsn @heejaechang I think this one seems to be by design, unless we decide to change `CodeFixContext` constructor API parameters.\r\n\r\n`CodeFixProvider.RegisterCodeFixesAsync` method invocation from the IDE code fixer service guarantees that none of the diagnostics in the `CodeFixContext` are outside the fixer's `FixableDiagnosticIds`. However, given that the constructor of `CodeFixContext` is public, and has no association to the underlying fixer (see here: http://source.roslyn.io/Microsoft.CodeAnalysis.Workspaces/R/571cdf75a90d323d.html), some other fixer host (such as a command line tool) is free to create a context with random diagnostics and invoke `RegisterCodeFixesAsync` API.\r\n\r\nI think current implementation of Sam's fixer, which explicitly walks all the provided diagnostics in CodeFixContext and filters out non-fixable diagnostics is correct. The right fix on our side would be to change CodeFixContext constructor to take a `CodeFixProvider` argument, and throw/filter any diagnostic provided to the constructor that is not fixable by the given fixer. This is going to be a public API change though. Should we make this for 1.0?\r\n"}}