{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/2894","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/2894/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/2894/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/2894/events","html_url":"https://github.com/dotnet/roslyn/issues/2894","id":77912811,"number":2894,"title":"AnalysisContext.RegisterCodeBlockStartAction regressed: called twice in the middle of method","user":{"login":"AArnott","id":3548,"avatar_url":"https://avatars.githubusercontent.com/u/3548?v=3","gravatar_id":"","url":"https://api.github.com/users/AArnott","html_url":"https://github.com/AArnott","followers_url":"https://api.github.com/users/AArnott/followers","following_url":"https://api.github.com/users/AArnott/following{/other_user}","gists_url":"https://api.github.com/users/AArnott/gists{/gist_id}","starred_url":"https://api.github.com/users/AArnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AArnott/subscriptions","organizations_url":"https://api.github.com/users/AArnott/orgs","repos_url":"https://api.github.com/users/AArnott/repos","events_url":"https://api.github.com/users/AArnott/events{/privacy}","received_events_url":"https://api.github.com/users/AArnott/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"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Resolution-By%20Design","name":"Resolution-By Design","color":"cccccc"}],"state":"closed","locked":false,"assignee":null,"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":105,"closed_issues":421,"state":"open","created_at":"2015-01-15T20:45:24Z","updated_at":"2015-05-19T09:03:02Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-05-19T03:28:29Z","updated_at":"2015-05-19T13:33:08Z","closed_at":"2015-05-19T08:13:56Z","body":"The `RegisterCodeBlockStartAction` method used to be called at the start of each method, and is documented to do so. But after Dev14 RC, Roslyn regressed this and now the method is called twice in a single method, both *after* the method has begun being processed.\r\n\r\nThis caused a regression to be picked up by one of the unit tests for our own analyzer.\r\n\r\nRepro steps:\r\n\r\n1. Clone the [Repro project](https://github.com/AArnott/roslynbug2894.git)\r\n1. Open the solution and run tests to verify that they all work. This is against Roslyn 1.0.0-rc2\r\n1. Now update packages to the latest Roslyn nuget packages (or switch to the first commit in the repo, if you can restore those packages).\r\n1. Re-run tests. You'll see that `InvokeVsSolutionAfterVerifyOnUIThread` fails."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/103493346","html_url":"https://github.com/dotnet/roslyn/issues/2894#issuecomment-103493346","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/2894","id":103493346,"user":{"login":"AArnott","id":3548,"avatar_url":"https://avatars.githubusercontent.com/u/3548?v=3","gravatar_id":"","url":"https://api.github.com/users/AArnott","html_url":"https://github.com/AArnott","followers_url":"https://api.github.com/users/AArnott/followers","following_url":"https://api.github.com/users/AArnott/following{/other_user}","gists_url":"https://api.github.com/users/AArnott/gists{/gist_id}","starred_url":"https://api.github.com/users/AArnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AArnott/subscriptions","organizations_url":"https://api.github.com/users/AArnott/orgs","repos_url":"https://api.github.com/users/AArnott/repos","events_url":"https://api.github.com/users/AArnott/events{/privacy}","received_events_url":"https://api.github.com/users/AArnott/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T13:33:08Z","updated_at":"2015-05-19T13:33:08Z","body":"Thanks, @mavasani both for your analysis and proposed fixes. I wondered what the thread safety obligations were for an analyzer. Another approach Roslyn might have taken was to instantiate the analyzer multiple times for each parallel track so that no instance had to be thread-safe itself. Did you consider that?\r\n\r\nAlso: when debugging the problem myself I noticed that 1 or 2 statements were processed *before* the  `RegisterCodeBlockStartAction` callback was invoked even the first time. How is that correct? Regardless of parallelism, shouldn't a method start callback have been invoked before analyzing any of its contents?"}}