{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/9639","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/9639/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/9639/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/9639/events","html_url":"https://github.com/dotnet/roslyn/issues/9639","id":139798304,"number":9639,"title":"VB - Optimized compilation of async method skips disposal if enumeration happened last","user":{"login":"brandondahler","id":1155895,"avatar_url":"https://avatars.githubusercontent.com/u/1155895?v=3","gravatar_id":"","url":"https://api.github.com/users/brandondahler","html_url":"https://github.com/brandondahler","followers_url":"https://api.github.com/users/brandondahler/followers","following_url":"https://api.github.com/users/brandondahler/following{/other_user}","gists_url":"https://api.github.com/users/brandondahler/gists{/gist_id}","starred_url":"https://api.github.com/users/brandondahler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandondahler/subscriptions","organizations_url":"https://api.github.com/users/brandondahler/orgs","repos_url":"https://api.github.com/users/brandondahler/repos","events_url":"https://api.github.com/users/brandondahler/events{/privacy}","received_events_url":"https://api.github.com/users/brandondahler/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Compilers","name":"Area-Compilers","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Bug","name":"Bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":{"login":"VSadov","id":8218165,"avatar_url":"https://avatars.githubusercontent.com/u/8218165?v=3","gravatar_id":"","url":"https://api.github.com/users/VSadov","html_url":"https://github.com/VSadov","followers_url":"https://api.github.com/users/VSadov/followers","following_url":"https://api.github.com/users/VSadov/following{/other_user}","gists_url":"https://api.github.com/users/VSadov/gists{/gist_id}","starred_url":"https://api.github.com/users/VSadov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VSadov/subscriptions","organizations_url":"https://api.github.com/users/VSadov/orgs","repos_url":"https://api.github.com/users/VSadov/repos","events_url":"https://api.github.com/users/VSadov/events{/privacy}","received_events_url":"https://api.github.com/users/VSadov/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-03-10T06:23:22Z","updated_at":"2016-04-15T21:16:51Z","closed_at":"2016-04-15T21:16:51Z","body":"**Version Used**: \r\nVS 2015 Update 1 Enterprise\r\n.NET Framework 4.6\r\nVisual Basic Compiler version 1.1.0.51204\r\n\r\n**Steps to Reproduce**:\r\n1. Compile VB Console Application below with optimizations on.\r\n2. Execute program\r\n\r\n**Expected Behavior**:\r\nConsole should output \"Disposed\".\r\n\r\n**Actual Behavior**:\r\nConsole outputs \"Finaiized\".\r\n\r\n\r\n**Work Arounds**:\r\n- Compile without optimizations on; or\r\n- Uncomment GC.KeepAline(...) line; or\r\n- Use C# (bug not exhibited using equivalent code)\r\n\r\n\r\n**Code**:\r\n```\r\nModule Module1\r\n    Private Class Disposable\r\n        Implements IDisposable\r\n\r\n        Protected Overrides Sub Finalize()\r\n            Console.WriteLine(\"Finalized\")\r\n        End Sub\r\n\r\n\r\n        Public Sub Dispose() Implements IDisposable.Dispose\r\n            Console.WriteLine(\"Disposed\")\r\n            GC.SuppressFinalize(Me)\r\n        End Sub\r\n    End Class\r\n\r\n    Sub Main()\r\n        Test().Wait()\r\n    End Sub\r\n\r\n    Private Async Function Test() As Task\r\n        Using disposable = New Disposable()\r\n            For Each p In System.Linq.Enumerable.Range(0, 10)\r\n                Await Task.Yield()\r\n            Next\r\n\r\n            'GC.KeepAlive(disposable)\r\n        End Using\r\n    End Function\r\n\r\nEnd Module\r\n```\r\n\r\n\r\nPS:\r\nSorry if this isn't the correct place for this type of bug report.  If it is not, can someone point me in a better direction?\r\n\r\nBrandon Dahler"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/210649136","html_url":"https://github.com/dotnet/roslyn/issues/9639#issuecomment-210649136","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/9639","id":210649136,"user":{"login":"brandondahler","id":1155895,"avatar_url":"https://avatars.githubusercontent.com/u/1155895?v=3","gravatar_id":"","url":"https://api.github.com/users/brandondahler","html_url":"https://github.com/brandondahler","followers_url":"https://api.github.com/users/brandondahler/followers","following_url":"https://api.github.com/users/brandondahler/following{/other_user}","gists_url":"https://api.github.com/users/brandondahler/gists{/gist_id}","starred_url":"https://api.github.com/users/brandondahler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandondahler/subscriptions","organizations_url":"https://api.github.com/users/brandondahler/orgs","repos_url":"https://api.github.com/users/brandondahler/repos","events_url":"https://api.github.com/users/brandondahler/events{/privacy}","received_events_url":"https://api.github.com/users/brandondahler/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T21:16:51Z","updated_at":"2016-04-15T21:16:51Z","body":"This appears to have been fixed with Microsoft (R) Visual Basic Compiler version 1.2.0.60317 that was released via Visual Studio 2015 Update 2.  \r\n\r\nThanks all involved :+1: "}}