{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/2250","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/2250/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/2250/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/2250/events","html_url":"https://github.com/dotnet/roslyn/pull/2250","id":70809281,"number":2250,"title":"re-filter signature help providers if the file's content type has changed","user":{"login":"brettfo","id":926281,"avatar_url":"https://avatars.githubusercontent.com/u/926281?v=3","gravatar_id":"","url":"https://api.github.com/users/brettfo","html_url":"https://github.com/brettfo","followers_url":"https://api.github.com/users/brettfo/followers","following_url":"https://api.github.com/users/brettfo/following{/other_user}","gists_url":"https://api.github.com/users/brettfo/gists{/gist_id}","starred_url":"https://api.github.com/users/brettfo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettfo/subscriptions","organizations_url":"https://api.github.com/users/brettfo/orgs","repos_url":"https://api.github.com/users/brettfo/repos","events_url":"https://api.github.com/users/brettfo/events{/privacy}","received_events_url":"https://api.github.com/users/brettfo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-IDE","name":"Area-IDE","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-24T22:24:20Z","updated_at":"2015-04-24T23:17:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/2250","html_url":"https://github.com/dotnet/roslyn/pull/2250","diff_url":"https://github.com/dotnet/roslyn/pull/2250.diff","patch_url":"https://github.com/dotnet/roslyn/pull/2250.patch"},"body":"When a file is opened and the user types a character, the list of all signature help providers is filtered based on the buffer's content type and cached.  If the content type is then changed without closing the file (e.g., renaming File1.cs to File1.vb) then another character is typed, the cached list of signature help providers is stale and any of those providers could be invoked based on `ISignatureHelpProvider.IsTriggerCharacter()` and `IsRetriggerCharacter()` which could ultimately lead to a crash when/if a syntax node is explicitly cast to a language-specific syntax node that doesn't match.\r\n\r\nThe fix is to also track the content type used to initially filter the list and invalidate the cache if the content type has changed.  There is also the added benefit with this change that after renaming a file extension, signature help continues to work as expected.\r\n\r\nWriting a unit test for this ended up being very code-intensive and contrived, but I could be convinced to add an internal integration test for this scenario if people think it's important enough.\r\n\r\nThis also fixes another crashing bug I found while working on this where the mis-matched content type could cause the navigation bars to try to navigate with a negative index.  I audited all other instances of calling `GetCurrentSelection(int, out int)` and we either explicitly check for a negative index before navigation or we're appropriately guarded otherwise.\r\n\r\nFixes #1940."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/96094376","html_url":"https://github.com/dotnet/roslyn/pull/2250#issuecomment-96094376","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/2250","id":96094376,"user":{"login":"rchande","id":3751401,"avatar_url":"https://avatars.githubusercontent.com/u/3751401?v=3","gravatar_id":"","url":"https://api.github.com/users/rchande","html_url":"https://github.com/rchande","followers_url":"https://api.github.com/users/rchande/followers","following_url":"https://api.github.com/users/rchande/following{/other_user}","gists_url":"https://api.github.com/users/rchande/gists{/gist_id}","starred_url":"https://api.github.com/users/rchande/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rchande/subscriptions","organizations_url":"https://api.github.com/users/rchande/orgs","repos_url":"https://api.github.com/users/rchande/repos","events_url":"https://api.github.com/users/rchande/events{/privacy}","received_events_url":"https://api.github.com/users/rchande/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T23:17:40Z","updated_at":"2015-04-24T23:17:40Z","body":"I assume you found that Completion didn't have this problem when you tested the fix?\r\n\r\n:+1: "}}