{"action":"opened","number":4145,"pull_request":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/4145","id":92474514,"html_url":"https://github.com/swagger-api/swagger-codegen/pull/4145","diff_url":"https://github.com/swagger-api/swagger-codegen/pull/4145.diff","patch_url":"https://github.com/swagger-api/swagger-codegen/pull/4145.patch","issue_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/4145","number":4145,"state":"open","locked":false,"title":"[csharp] Use default rather than null in ctor","user":{"login":"jimschubert","id":109659,"avatar_url":"https://avatars.githubusercontent.com/u/109659?v=3","gravatar_id":"","url":"https://api.github.com/users/jimschubert","html_url":"https://github.com/jimschubert","followers_url":"https://api.github.com/users/jimschubert/followers","following_url":"https://api.github.com/users/jimschubert/following{/other_user}","gists_url":"https://api.github.com/users/jimschubert/gists{/gist_id}","starred_url":"https://api.github.com/users/jimschubert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimschubert/subscriptions","organizations_url":"https://api.github.com/users/jimschubert/orgs","repos_url":"https://api.github.com/users/jimschubert/repos","events_url":"https://api.github.com/users/jimschubert/events{/privacy}","received_events_url":"https://api.github.com/users/jimschubert/received_events","type":"User","site_admin":false},"body":"### PR checklist\r\n\r\n- [x] Read the [contribution guildelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md).\r\n- [ ] Ran the shell/batch script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh` and `./bin/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)\r\n- [x] Filed the PR against the correct branch: master for non-breaking changes and `2.3.0` branch for breaking (non-backward compatible) changes.\r\n\r\n### Description of the PR\r\n\r\nSee #3608\r\n\r\nThis improves the defaults on constructor parameters by using `defaults(type)` rather than `null` for all inputs.\r\n\r\nThere seems to have been some weird usage of nullable types, possibly on parameters that aren't defined in the target swagger definition as nullable although I'm not 100% sure and didn't spend a lot of time investigating this.\r\n\r\nThis PR changes constructor parameters in models to:\r\n\r\n1. Default to a default if present\r\n2. Set to `default(TheType)` if no default value is defined\r\n\r\n## Examples\r\n\r\n### Old Behavior: Dog\r\n\r\n```\r\npublic Dog(string ClassName = null, string Color = null, string Breed = null)\r\n{\r\n    // to ensure \"ClassName\" is required (not null)\r\n    if (ClassName == null)\r\n    {\r\n        throw new InvalidDataException(\"ClassName is a required property for Dog and cannot be null\");\r\n    }\r\n    else\r\n    {\r\n        this.ClassName = ClassName;\r\n    }\r\n    // use default value if no \"Color\" provided\r\n    if (Color == null)\r\n    {\r\n        this.Color = \"red\";\r\n    }\r\n    else\r\n    {\r\n        this.Color = Color;\r\n    }\r\n    this.Breed = Breed;\r\n}\r\n```\r\n\r\n### New Behavior: Dog\r\n\r\n```\r\n public Dog(string ClassName = default(string), string Color = \"red\", string Breed = default(string))\r\n{\r\n    // to ensure \"ClassName\" is required (not null)\r\n    if (ClassName == null)\r\n    {\r\n        throw new InvalidDataException(\"ClassName is a required property for Dog and cannot be null\");\r\n    }\r\n    else\r\n    {\r\n        this.ClassName = ClassName;\r\n    }\r\n    // use default value if no \"Color\" provided\r\n    if (Color == null)\r\n    {\r\n        this.Color = \"red\";\r\n    }\r\n    else\r\n    {\r\n        this.Color = Color;\r\n    }\r\n    this.Breed = Breed;\r\n}\r\n```\r\n\r\n### New Behavior: Other constructor examples\r\n\r\n```\r\npublic Cat(string ClassName = default(string), \r\n            string Color = \"red\", \r\n            bool? Declawed = default(bool?)\r\n) { }\r\n\r\npublic EnumArrays(JustSymbolEnum? JustSymbol = default(JustSymbolEnum?), \r\n            List<ArrayEnumEnum> ArrayEnum = default(List<ArrayEnumEnum>)\r\n) { }\r\n\r\npublic Pet(long? Id = default(long?), \r\n           Category Category = default(Category), \r\n           string Name = default(string), \r\n           List<string> PhotoUrls = default(List<string>), \r\n           List<Tag> Tags = default(List<Tag>), \r\n           StatusEnum? Status = default(StatusEnum?)\r\n) { }\r\n```\r\n","created_at":"2016-11-06T02:13:35Z","updated_at":"2016-11-06T02:13:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/4145/commits","review_comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/4145/comments","review_comment_url":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/comments{/number}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/4145/comments","statuses_url":"https://api.github.com/repos/swagger-api/swagger-codegen/statuses/5f98890e56ba274f76436610df96687fd32d75f0","head":{"label":"jimschubert:cs/3608","ref":"cs/3608","sha":"5f98890e56ba274f76436610df96687fd32d75f0","user":{"login":"jimschubert","id":109659,"avatar_url":"https://avatars.githubusercontent.com/u/109659?v=3","gravatar_id":"","url":"https://api.github.com/users/jimschubert","html_url":"https://github.com/jimschubert","followers_url":"https://api.github.com/users/jimschubert/followers","following_url":"https://api.github.com/users/jimschubert/following{/other_user}","gists_url":"https://api.github.com/users/jimschubert/gists{/gist_id}","starred_url":"https://api.github.com/users/jimschubert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimschubert/subscriptions","organizations_url":"https://api.github.com/users/jimschubert/orgs","repos_url":"https://api.github.com/users/jimschubert/repos","events_url":"https://api.github.com/users/jimschubert/events{/privacy}","received_events_url":"https://api.github.com/users/jimschubert/received_events","type":"User","site_admin":false},"repo":{"id":34024577,"name":"swagger-codegen","full_name":"jimschubert/swagger-codegen","owner":{"login":"jimschubert","id":109659,"avatar_url":"https://avatars.githubusercontent.com/u/109659?v=3","gravatar_id":"","url":"https://api.github.com/users/jimschubert","html_url":"https://github.com/jimschubert","followers_url":"https://api.github.com/users/jimschubert/followers","following_url":"https://api.github.com/users/jimschubert/following{/other_user}","gists_url":"https://api.github.com/users/jimschubert/gists{/gist_id}","starred_url":"https://api.github.com/users/jimschubert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimschubert/subscriptions","organizations_url":"https://api.github.com/users/jimschubert/orgs","repos_url":"https://api.github.com/users/jimschubert/repos","events_url":"https://api.github.com/users/jimschubert/events{/privacy}","received_events_url":"https://api.github.com/users/jimschubert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jimschubert/swagger-codegen","description":"swagger-codegen contains a template-driven engine to generate client code in different languages by parsing your Swagger Resource Declaration.","fork":true,"url":"https://api.github.com/repos/jimschubert/swagger-codegen","forks_url":"https://api.github.com/repos/jimschubert/swagger-codegen/forks","keys_url":"https://api.github.com/repos/jimschubert/swagger-codegen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jimschubert/swagger-codegen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jimschubert/swagger-codegen/teams","hooks_url":"https://api.github.com/repos/jimschubert/swagger-codegen/hooks","issue_events_url":"https://api.github.com/repos/jimschubert/swagger-codegen/issues/events{/number}","events_url":"https://api.github.com/repos/jimschubert/swagger-codegen/events","assignees_url":"https://api.github.com/repos/jimschubert/swagger-codegen/assignees{/user}","branches_url":"https://api.github.com/repos/jimschubert/swagger-codegen/branches{/branch}","tags_url":"https://api.github.com/repos/jimschubert/swagger-codegen/tags","blobs_url":"https://api.github.com/repos/jimschubert/swagger-codegen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jimschubert/swagger-codegen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jimschubert/swagger-codegen/git/refs{/sha}","trees_url":"https://api.github.com/repos/jimschubert/swagger-codegen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jimschubert/swagger-codegen/statuses/{sha}","languages_url":"https://api.github.com/repos/jimschubert/swagger-codegen/languages","stargazers_url":"https://api.github.com/repos/jimschubert/swagger-codegen/stargazers","contributors_url":"https://api.github.com/repos/jimschubert/swagger-codegen/contributors","subscribers_url":"https://api.github.com/repos/jimschubert/swagger-codegen/subscribers","subscription_url":"https://api.github.com/repos/jimschubert/swagger-codegen/subscription","commits_url":"https://api.github.com/repos/jimschubert/swagger-codegen/commits{/sha}","git_commits_url":"https://api.github.com/repos/jimschubert/swagger-codegen/git/commits{/sha}","comments_url":"https://api.github.com/repos/jimschubert/swagger-codegen/comments{/number}","issue_comment_url":"https://api.github.com/repos/jimschubert/swagger-codegen/issues/comments{/number}","contents_url":"https://api.github.com/repos/jimschubert/swagger-codegen/contents/{+path}","compare_url":"https://api.github.com/repos/jimschubert/swagger-codegen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jimschubert/swagger-codegen/merges","archive_url":"https://api.github.com/repos/jimschubert/swagger-codegen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jimschubert/swagger-codegen/downloads","issues_url":"https://api.github.com/repos/jimschubert/swagger-codegen/issues{/number}","pulls_url":"https://api.github.com/repos/jimschubert/swagger-codegen/pulls{/number}","milestones_url":"https://api.github.com/repos/jimschubert/swagger-codegen/milestones{/number}","notifications_url":"https://api.github.com/repos/jimschubert/swagger-codegen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jimschubert/swagger-codegen/labels{/name}","releases_url":"https://api.github.com/repos/jimschubert/swagger-codegen/releases{/id}","deployments_url":"https://api.github.com/repos/jimschubert/swagger-codegen/deployments","created_at":"2015-04-15T23:55:01Z","updated_at":"2016-11-02T02:18:17Z","pushed_at":"2016-11-06T02:01:16Z","git_url":"git://github.com/jimschubert/swagger-codegen.git","ssh_url":"git@github.com:jimschubert/swagger-codegen.git","clone_url":"https://github.com/jimschubert/swagger-codegen.git","svn_url":"https://github.com/jimschubert/swagger-codegen","homepage":"http://swagger.io","size":48513,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"swagger-api:master","ref":"master","sha":"ab9ea5b2c380498745fc1e5520396987b526a937","user":{"login":"swagger-api","id":7658037,"avatar_url":"https://avatars.githubusercontent.com/u/7658037?v=3","gravatar_id":"","url":"https://api.github.com/users/swagger-api","html_url":"https://github.com/swagger-api","followers_url":"https://api.github.com/users/swagger-api/followers","following_url":"https://api.github.com/users/swagger-api/following{/other_user}","gists_url":"https://api.github.com/users/swagger-api/gists{/gist_id}","starred_url":"https://api.github.com/users/swagger-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swagger-api/subscriptions","organizations_url":"https://api.github.com/users/swagger-api/orgs","repos_url":"https://api.github.com/users/swagger-api/repos","events_url":"https://api.github.com/users/swagger-api/events{/privacy}","received_events_url":"https://api.github.com/users/swagger-api/received_events","type":"Organization","site_admin":false},"repo":{"id":2006876,"name":"swagger-codegen","full_name":"swagger-api/swagger-codegen","owner":{"login":"swagger-api","id":7658037,"avatar_url":"https://avatars.githubusercontent.com/u/7658037?v=3","gravatar_id":"","url":"https://api.github.com/users/swagger-api","html_url":"https://github.com/swagger-api","followers_url":"https://api.github.com/users/swagger-api/followers","following_url":"https://api.github.com/users/swagger-api/following{/other_user}","gists_url":"https://api.github.com/users/swagger-api/gists{/gist_id}","starred_url":"https://api.github.com/users/swagger-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swagger-api/subscriptions","organizations_url":"https://api.github.com/users/swagger-api/orgs","repos_url":"https://api.github.com/users/swagger-api/repos","events_url":"https://api.github.com/users/swagger-api/events{/privacy}","received_events_url":"https://api.github.com/users/swagger-api/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/swagger-api/swagger-codegen","description":"swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.","fork":false,"url":"https://api.github.com/repos/swagger-api/swagger-codegen","forks_url":"https://api.github.com/repos/swagger-api/swagger-codegen/forks","keys_url":"https://api.github.com/repos/swagger-api/swagger-codegen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swagger-api/swagger-codegen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swagger-api/swagger-codegen/teams","hooks_url":"https://api.github.com/repos/swagger-api/swagger-codegen/hooks","issue_events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/events{/number}","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/events","assignees_url":"https://api.github.com/repos/swagger-api/swagger-codegen/assignees{/user}","branches_url":"https://api.github.com/repos/swagger-api/swagger-codegen/branches{/branch}","tags_url":"https://api.github.com/repos/swagger-api/swagger-codegen/tags","blobs_url":"https://api.github.com/repos/swagger-api/swagger-codegen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swagger-api/swagger-codegen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swagger-api/swagger-codegen/git/refs{/sha}","trees_url":"https://api.github.com/repos/swagger-api/swagger-codegen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swagger-api/swagger-codegen/statuses/{sha}","languages_url":"https://api.github.com/repos/swagger-api/swagger-codegen/languages","stargazers_url":"https://api.github.com/repos/swagger-api/swagger-codegen/stargazers","contributors_url":"https://api.github.com/repos/swagger-api/swagger-codegen/contributors","subscribers_url":"https://api.github.com/repos/swagger-api/swagger-codegen/subscribers","subscription_url":"https://api.github.com/repos/swagger-api/swagger-codegen/subscription","commits_url":"https://api.github.com/repos/swagger-api/swagger-codegen/commits{/sha}","git_commits_url":"https://api.github.com/repos/swagger-api/swagger-codegen/git/commits{/sha}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/comments{/number}","issue_comment_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/comments{/number}","contents_url":"https://api.github.com/repos/swagger-api/swagger-codegen/contents/{+path}","compare_url":"https://api.github.com/repos/swagger-api/swagger-codegen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swagger-api/swagger-codegen/merges","archive_url":"https://api.github.com/repos/swagger-api/swagger-codegen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swagger-api/swagger-codegen/downloads","issues_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues{/number}","pulls_url":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls{/number}","milestones_url":"https://api.github.com/repos/swagger-api/swagger-codegen/milestones{/number}","notifications_url":"https://api.github.com/repos/swagger-api/swagger-codegen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/labels{/name}","releases_url":"https://api.github.com/repos/swagger-api/swagger-codegen/releases{/id}","deployments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/deployments","created_at":"2011-07-06T14:26:48Z","updated_at":"2016-11-05T19:37:29Z","pushed_at":"2016-11-05T19:14:39Z","git_url":"git://github.com/swagger-api/swagger-codegen.git","ssh_url":"git@github.com:swagger-api/swagger-codegen.git","clone_url":"https://github.com/swagger-api/swagger-codegen.git","svn_url":"https://github.com/swagger-api/swagger-codegen","homepage":"http://swagger.io","size":61045,"stargazers_count":2967,"watchers_count":2967,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1697,"mirror_url":null,"open_issues_count":565,"forks":1697,"open_issues":565,"watchers":2967,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/4145"},"html":{"href":"https://github.com/swagger-api/swagger-codegen/pull/4145"},"issue":{"href":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/4145"},"comments":{"href":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/4145/comments"},"review_comments":{"href":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/4145/comments"},"review_comment":{"href":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/swagger-api/swagger-codegen/pulls/4145/commits"},"statuses":{"href":"https://api.github.com/repos/swagger-api/swagger-codegen/statuses/5f98890e56ba274f76436610df96687fd32d75f0"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":3,"deletions":3,"changed_files":2}}
{"actor":{"display_login":"jimschubert"}}