{"action":"created","issue":{"url":"https://api.github.com/repos/SteveGilham/altcover/issues/43","repository_url":"https://api.github.com/repos/SteveGilham/altcover","labels_url":"https://api.github.com/repos/SteveGilham/altcover/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/SteveGilham/altcover/issues/43/comments","events_url":"https://api.github.com/repos/SteveGilham/altcover/issues/43/events","html_url":"https://github.com/SteveGilham/altcover/issues/43","id":389528420,"node_id":"MDU6SXNzdWUzODk1Mjg0MjA=","number":43,"title":"Instrumentation hangs when the yield keyword is used in a property that's part of an explicit interface implementation","user":{"login":"Anvoker","id":10464482,"node_id":"MDQ6VXNlcjEwNDY0NDgy","avatar_url":"https://avatars3.githubusercontent.com/u/10464482?v=4","gravatar_id":"","url":"https://api.github.com/users/Anvoker","html_url":"https://github.com/Anvoker","followers_url":"https://api.github.com/users/Anvoker/followers","following_url":"https://api.github.com/users/Anvoker/following{/other_user}","gists_url":"https://api.github.com/users/Anvoker/gists{/gist_id}","starred_url":"https://api.github.com/users/Anvoker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anvoker/subscriptions","organizations_url":"https://api.github.com/users/Anvoker/orgs","repos_url":"https://api.github.com/users/Anvoker/repos","events_url":"https://api.github.com/users/Anvoker/events{/privacy}","received_events_url":"https://api.github.com/users/Anvoker/received_events","type":"User","site_admin":false},"labels":[{"id":774049396,"node_id":"MDU6TGFiZWw3NzQwNDkzOTY=","url":"https://api.github.com/repos/SteveGilham/altcover/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-10T23:14:56Z","updated_at":"2018-12-12T16:46:00Z","closed_at":null,"author_association":"NONE","body":"I've encountered a really peculiar bug. If altcover is told to instrument a .dll that contains a property with a getter that returns an IEnumerable<T> and uses the yield keyword anywhere in its body AND that property is part of an explicit interface implementation then altcover will get permanently stuck in an infinite loop and never finish the instrumentation process. It will use up to 25% of my CPU and never give an error. The instrumented `AltCoverRepro2.dll` seems to be generated during this process, but the XML file, `AltCover.Recorder.g.dll`, and `AltCover.Recorder.g.pdb` are not generated which prevents me from using a runner.\r\n\r\nThis is the command I used:\r\n\r\n```\r\nH:\\Programe\\altcover\\tools\\net45\\AltCover.exe --opencover -s=nunit -t=System. -s=Microsoft -i=F:\\GitRepos\\AltCoverRepro2\\AltCoverRepro2\\bin\\Debug -o=F:\\GitRepos\\AltCoverRepro2\\AltCoverRepro2\\bin\\Debug\\instr -x=F:\\GitRepos\\AltCoverRepro2\\AltCoverRepro2\\bin\\Debug\\coverage.xml\r\n```\r\n\r\nAs soon as the offending yield usage is stubbed out with a `throw new NotImplementedException()` then the exact same command will successfully instrument the project. The three previously missing files are successfully generated. The project is also instrumented successfully if the property is switched from being explicit to being public.\r\n\r\nI have attached a repro project at the bottom but will include a reproduction inline here as well. It's also worth noting that I'm on Windows 10 Pro and this is being compiled with .NET Framework / Roslyn. I opted for this mode of operation because I wanted to be doing similar steps to what I'd do on Linux with Mono, since I'd like to move to developing on Linux.\r\n\r\n```csharp\r\npublic class EnumerableGetterExplicit_DoesNotWork<T, K>\r\n    : IReadOnlyDictionary<T, K>\r\n{\r\n    private int counter;\r\n\r\n    // Replace the content of this property's getter with\r\n    // \"=> throw new NotImplementedException();\"\r\n    // and the whole project is instrumented successfully.\r\n    // As long as this getter is left alone, instrumentation enters an\r\n    // infinite loop.\r\n    IEnumerable<K> IReadOnlyDictionary<T, K>.Values\r\n    {\r\n        get { yield break; }\r\n    }\r\n\r\n    // This works as is. It seems the problem doesn't appear unless the\r\n    // property is specifically part of an explicit interface\r\n    // implementation.\r\n    public IEnumerable<K> ValuesWorks\r\n    {\r\n        get\r\n        {\r\n            yield return default(K);\r\n            yield break;\r\n        }\r\n    }\r\n\r\n    // This works as is. As long as there isn't a yield used inside this\r\n    // getter then the property won't cause any trouble to the\r\n    // instrumentation process.\r\n    IEnumerable<T> IReadOnlyDictionary<T, K>.Keys\r\n    {\r\n        get { counter++; throw new NotImplementedException(); }\r\n        // The counter variable is just a blind hedge against the compiler\r\n        // doing something weird. It might optimize the getter out somehow\r\n        // if the body of the getter was just the exception throw.\r\n    }\r\n\r\n    K IReadOnlyDictionary<T, K>.this[T key] => throw new NotImplementedException();\r\n    int IReadOnlyCollection<KeyValuePair<T, K>>.Count => throw new NotImplementedException();\r\n    bool IReadOnlyDictionary<T, K>.ContainsKey(T key) => throw new NotImplementedException();\r\n    IEnumerator<KeyValuePair<T, K>> IEnumerable<KeyValuePair<T, K>>.GetEnumerator() => throw new NotImplementedException();\r\n    IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException();\r\n    bool IReadOnlyDictionary<T, K>.TryGetValue(T key, out K value) => throw new NotImplementedException();\r\n}\r\n```\r\n[AltCoverRepro_ExplicitGetterYieldInfiniteLoop2.zip](https://github.com/SteveGilham/altcover/files/2665262/AltCoverRepro_ExplicitGetterYieldInfiniteLoop2.zip)\r\n\r\nI've struggled literally all day to get this work until I managed to condense it down to this one bizarre case. My actual project is much larger than this but I managed to confirm this is the problem by stubbing out all occurrences of the keyword yield in explicit interface members - this made altcover successfully instrument the project right away. Usage of strong name keys did not seem to matter. My guess is that whatever code generates the IL necessary for instrumentation is somehow failing to parse this specific case."},"comment":{"url":"https://api.github.com/repos/SteveGilham/altcover/issues/comments/446657287","html_url":"https://github.com/SteveGilham/altcover/issues/43#issuecomment-446657287","issue_url":"https://api.github.com/repos/SteveGilham/altcover/issues/43","id":446657287,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjY1NzI4Nw==","user":{"login":"SteveGilham","id":7460854,"node_id":"MDQ6VXNlcjc0NjA4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/7460854?v=4","gravatar_id":"","url":"https://api.github.com/users/SteveGilham","html_url":"https://github.com/SteveGilham","followers_url":"https://api.github.com/users/SteveGilham/followers","following_url":"https://api.github.com/users/SteveGilham/following{/other_user}","gists_url":"https://api.github.com/users/SteveGilham/gists{/gist_id}","starred_url":"https://api.github.com/users/SteveGilham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SteveGilham/subscriptions","organizations_url":"https://api.github.com/users/SteveGilham/orgs","repos_url":"https://api.github.com/users/SteveGilham/repos","events_url":"https://api.github.com/users/SteveGilham/events{/privacy}","received_events_url":"https://api.github.com/users/SteveGilham/received_events","type":"User","site_admin":false},"created_at":"2018-12-12T16:46:00Z","updated_at":"2018-12-12T16:46:00Z","author_association":"OWNER","body":"Should be fixed in release 4.0.660"}}
{"actor":{"display_login":"SteveGilham"}}