{"action":"created","issue":{"url":"https://api.github.com/repos/fsprojects/FSharp.TypeProviders.SDK/issues/276","repository_url":"https://api.github.com/repos/fsprojects/FSharp.TypeProviders.SDK","labels_url":"https://api.github.com/repos/fsprojects/FSharp.TypeProviders.SDK/issues/276/labels{/name}","comments_url":"https://api.github.com/repos/fsprojects/FSharp.TypeProviders.SDK/issues/276/comments","events_url":"https://api.github.com/repos/fsprojects/FSharp.TypeProviders.SDK/issues/276/events","html_url":"https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/276","id":377377877,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI4MzM1MDE3","number":276,"title":"Use most recent assembly containing type","user":{"login":"kevmal","id":7281367,"node_id":"MDQ6VXNlcjcyODEzNjc=","avatar_url":"https://avatars3.githubusercontent.com/u/7281367?v=4","gravatar_id":"","url":"https://api.github.com/users/kevmal","html_url":"https://github.com/kevmal","followers_url":"https://api.github.com/users/kevmal/followers","following_url":"https://api.github.com/users/kevmal/following{/other_user}","gists_url":"https://api.github.com/users/kevmal/gists{/gist_id}","starred_url":"https://api.github.com/users/kevmal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevmal/subscriptions","organizations_url":"https://api.github.com/users/kevmal/orgs","repos_url":"https://api.github.com/users/kevmal/repos","events_url":"https://api.github.com/users/kevmal/events{/privacy}","received_events_url":"https://api.github.com/users/kevmal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-05T12:25:00Z","updated_at":"2018-11-07T01:02:49Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/fsprojects/FSharp.TypeProviders.SDK/pulls/276","html_url":"https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/276","diff_url":"https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/276.diff","patch_url":"https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/276.patch"},"body":"Something like \r\n```fsharp\r\n    let prop1 = ProvidedProperty(\"InnerState\", typeof<string>, getterCode = fun args -> <@@ \"hello\" @@>)\r\n    myType.AddMember(prop1)\r\n    let meth2 = ProvidedMethod(\"InstanceMethod\", [], typeof<string>, isStatic=false, invokeCode = (fun args -> Expr.PropertyGet(args.[0],prop1)))\r\n    myType.AddMember(meth2)\r\n```\r\n\r\nin a generative type provider has issues in hosted environments. It'll compile fine since the asm only gets generated once but fsi and source checking will fail (particularly if static parameters change). This is due to `ProvidedTypesContext` always returning the first \"version\" of a given type. The new `invokeCode` will be called but with the wrong type for the `this` parameter resulting in an \"incorrect instance type\" error. The workaround for source checking would be to either use reflection \r\n```fsharp\r\nlet meth2 = \r\n    ProvidedMethod(\"InstanceMethod\", [], typeof<string>, isStatic=false, \r\n        invokeCode = (fun args -> Expr.PropertyGet(args.[0],args.[0].Type.GetProperty(\"InnerState\"))))\r\n```\r\n(which would fail if the type of \"InnerState\" changes) or to use unchecked expressions. In either case both still have issues when used in fsi.\r\n\r\nThis is probably the simplest change addressing this issue. It simply favors the most recent assembly containing the desired type instead of the first. However, it leaves open the issue that stale assemblies are not being removed from `ProvidedTypesContext.sourceAssemblies_`.\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/fsprojects/FSharp.TypeProviders.SDK/issues/comments/436465919","html_url":"https://github.com/fsprojects/FSharp.TypeProviders.SDK/pull/276#issuecomment-436465919","issue_url":"https://api.github.com/repos/fsprojects/FSharp.TypeProviders.SDK/issues/276","id":436465919,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjQ2NTkxOQ==","user":{"login":"kevmal","id":7281367,"node_id":"MDQ6VXNlcjcyODEzNjc=","avatar_url":"https://avatars3.githubusercontent.com/u/7281367?v=4","gravatar_id":"","url":"https://api.github.com/users/kevmal","html_url":"https://github.com/kevmal","followers_url":"https://api.github.com/users/kevmal/followers","following_url":"https://api.github.com/users/kevmal/following{/other_user}","gists_url":"https://api.github.com/users/kevmal/gists{/gist_id}","starred_url":"https://api.github.com/users/kevmal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevmal/subscriptions","organizations_url":"https://api.github.com/users/kevmal/orgs","repos_url":"https://api.github.com/users/kevmal/repos","events_url":"https://api.github.com/users/kevmal/events{/privacy}","received_events_url":"https://api.github.com/users/kevmal/received_events","type":"User","site_admin":false},"created_at":"2018-11-07T01:02:49Z","updated_at":"2018-11-07T01:02:49Z","author_association":"NONE","body":"Oops, fixed. "}}
{"actor":{"display_login":"kevmal"}}