{"action":"opened","issue":{"url":"https://api.github.com/repos/SonarSource/sonarlint-vs/issues/66","labels_url":"https://api.github.com/repos/SonarSource/sonarlint-vs/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/SonarSource/sonarlint-vs/issues/66/comments","events_url":"https://api.github.com/repos/SonarSource/sonarlint-vs/issues/66/events","html_url":"https://github.com/SonarSource/sonarlint-vs/issues/66","id":96320952,"number":66,"title":"Rule: Method overload with optional parameter","user":{"login":"dbolkensteyn","id":1132601,"avatar_url":"https://avatars.githubusercontent.com/u/1132601?v=3","gravatar_id":"","url":"https://api.github.com/users/dbolkensteyn","html_url":"https://github.com/dbolkensteyn","followers_url":"https://api.github.com/users/dbolkensteyn/followers","following_url":"https://api.github.com/users/dbolkensteyn/following{/other_user}","gists_url":"https://api.github.com/users/dbolkensteyn/gists{/gist_id}","starred_url":"https://api.github.com/users/dbolkensteyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbolkensteyn/subscriptions","organizations_url":"https://api.github.com/users/dbolkensteyn/orgs","repos_url":"https://api.github.com/users/dbolkensteyn/repos","events_url":"https://api.github.com/users/dbolkensteyn/events{/privacy}","received_events_url":"https://api.github.com/users/dbolkensteyn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-21T13:54:46Z","updated_at":"2015-07-21T13:54:46Z","closed_at":null,"body":"Replaces http://jira.sonarsource.com/browse/LINTVS-180\r\n\r\n```\r\nvoid Print(string[] messages) {...}  // Noncompliant\r\nvoid Print(string[] messages, string delimiter = \"n\") {...}\r\n```\r\n\r\nWhen you call `Print(new []\\{\"abc\"\\});` which method will be called? The first one, but it is not obvious. So we should avoid these overloads with default parameter values. \r\n\r\nNote there is this rule: https://msdn.microsoft.com/en-us/library/ms182135.aspx, CA1026, saying that optional parameters should be avoided altogether because of CLS (non-)compliance. But I wouldn't go this far as optional parameters are really useful if you use named parameters in the calls: http://codeblog.jonskeet.uk/2015/06/03/backwards-compatibility-is-still-hard/\r\n\r\nR# ID: *MethodOverloadWithOptionalParameter*\r\n\r\nThis rule could be covered by the http://jira.sonarsource.com/browse/RSPEC-3220, which covers overloads with `params` argument.\r\n\r\nImplements http://jira.sonarsource.com/browse/RSPEC-3220"}}