{"action":"created","issue":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3634","repository_url":"https://api.github.com/repos/Starcounter/Starcounter","labels_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3634/labels{/name}","comments_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3634/comments","events_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3634/events","html_url":"https://github.com/Starcounter/Starcounter/issues/3634","id":155454729,"number":3634,"title":"Unable to bind JSON view-model with :IBount to a nullable type","user":{"login":"miyconst","id":6435556,"avatar_url":"https://avatars.githubusercontent.com/u/6435556?v=3","gravatar_id":"","url":"https://api.github.com/users/miyconst","html_url":"https://github.com/miyconst","followers_url":"https://api.github.com/users/miyconst/followers","following_url":"https://api.github.com/users/miyconst/following{/other_user}","gists_url":"https://api.github.com/users/miyconst/gists{/gist_id}","starred_url":"https://api.github.com/users/miyconst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miyconst/subscriptions","organizations_url":"https://api.github.com/users/miyconst/orgs","repos_url":"https://api.github.com/users/miyconst/repos","events_url":"https://api.github.com/users/miyconst/events{/privacy}","received_events_url":"https://api.github.com/users/miyconst/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/Typed%20JSON","name":"Typed JSON","color":"006b75"}],"state":"open","locked":false,"assignee":{"login":"chrhol","id":1658979,"avatar_url":"https://avatars.githubusercontent.com/u/1658979?v=3","gravatar_id":"","url":"https://api.github.com/users/chrhol","html_url":"https://github.com/chrhol","followers_url":"https://api.github.com/users/chrhol/followers","following_url":"https://api.github.com/users/chrhol/following{/other_user}","gists_url":"https://api.github.com/users/chrhol/gists{/gist_id}","starred_url":"https://api.github.com/users/chrhol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrhol/subscriptions","organizations_url":"https://api.github.com/users/chrhol/orgs","repos_url":"https://api.github.com/users/chrhol/repos","events_url":"https://api.github.com/users/chrhol/events{/privacy}","received_events_url":"https://api.github.com/users/chrhol/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-05-18T09:25:29Z","updated_at":"2016-06-02T11:39:44Z","closed_at":null,"body":"I am trying to use a `struct` type as a binding type for a JSON view-model, but this has side effects. The struct types can't be null, and as soon as an instance of the view-model created it's `Data` populated with a default value of the `struct`. If the `struct` is a database type, and my case it is, it is automatically saved into database. To avoid this I try to bind to a nullable version of the struct:\r\n\r\n```cs\r\npublic class JsonPage : IBound<MyStruct?> {\r\n}\r\n```\r\n\r\nBut the `?` sign is ignored and the `JsonPage.Data` property type is still `MyStruct`. The generated code looks as follow:\r\n\r\n```cs\r\npublic new MyStruct Data { get { return (MyStruct)base.Data; } set { base.Data = value; } }\r\n```\r\n\r\nChanging `MyStruct?` with `Nullable<MyStruct>` produces even worse result, which does not even compile:\r\n\r\n```cs\r\npublic new NullableMyStruct Data { get { return (NullableMyStruct)base.Data; } set { base.Data = value; } }\r\n```\r\n\r\nInstead of ignoring `?` and `<>` it should be copied together with type name. I manually changed the generated code to:\r\n\r\n```cs\r\npublic new MyStruct? Data { get { return base.Data as MyStruct?; } set { base.Data = value; } }\r\n```\r\n\r\nIt compiles and works.\r\n\r\n**Note:** this is not the same issue as https://github.com/Starcounter/Starcounter/issues/3256. In this case we still do not support nullable values inside JSON, but only fix a code generation issue.\r\n\r\nNullable bound objects are already supported, as I can define `IBount<MyClass>` while any class is a nullable type.\r\n\r\ncc @per-samuelsson, @chrhol "},"comment":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/comments/223267205","html_url":"https://github.com/Starcounter/Starcounter/issues/3634#issuecomment-223267205","issue_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3634","id":223267205,"user":{"login":"per-samuelsson","id":2902045,"avatar_url":"https://avatars.githubusercontent.com/u/2902045?v=3","gravatar_id":"","url":"https://api.github.com/users/per-samuelsson","html_url":"https://github.com/per-samuelsson","followers_url":"https://api.github.com/users/per-samuelsson/followers","following_url":"https://api.github.com/users/per-samuelsson/following{/other_user}","gists_url":"https://api.github.com/users/per-samuelsson/gists{/gist_id}","starred_url":"https://api.github.com/users/per-samuelsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/per-samuelsson/subscriptions","organizations_url":"https://api.github.com/users/per-samuelsson/orgs","repos_url":"https://api.github.com/users/per-samuelsson/repos","events_url":"https://api.github.com/users/per-samuelsson/events{/privacy}","received_events_url":"https://api.github.com/users/per-samuelsson/received_events","type":"User","site_admin":false},"created_at":"2016-06-02T11:39:44Z","updated_at":"2016-06-02T11:39:44Z","body":"> Is the new parser in use now for our nightly builds @per-samuelsson or have we disabled it?\r\n\r\nIt's in use by default, but I'm still working trying to solve #3666, that will happen on some environments. But yeah, the Roslyn-parser should cover this case. Came with something good then at least :smile: "}}
{"actor":{"display_login":"per-samuelsson"}}