{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/8798","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/8798/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/8798/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/8798/events","html_url":"https://github.com/dotnet/roslyn/issues/8798","id":134285547,"number":8798,"title":"Proposal: Allow record constructors and properties to different have different access modifiers to that of the record itself","user":{"login":"DavidArno","id":196899,"avatar_url":"https://avatars.githubusercontent.com/u/196899?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidArno","html_url":"https://github.com/DavidArno","followers_url":"https://api.github.com/users/DavidArno/followers","following_url":"https://api.github.com/users/DavidArno/following{/other_user}","gists_url":"https://api.github.com/users/DavidArno/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidArno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidArno/subscriptions","organizations_url":"https://api.github.com/users/DavidArno/orgs","repos_url":"https://api.github.com/users/DavidArno/repos","events_url":"https://api.github.com/users/DavidArno/events{/privacy}","received_events_url":"https://api.github.com/users/DavidArno/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Language%20Design","name":"Area-Language Design","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2016-02-17T13:54:09Z","updated_at":"2016-02-17T17:11:08Z","closed_at":null,"body":"Consider the following real-world piece of code:\r\n\r\n``` cs\r\npublic sealed class WhereForFuncHandler<TMatcher, T1, TResult>\r\n{\r\n\tprivate readonly Func<T1, bool> _expression;\r\n\tprivate readonly Action<Func<T1, bool>, Func<T1, TResult>> _recorder;\r\n\tprivate readonly TMatcher _matcher;\r\n\r\n\tinternal WhereForFuncHandler(Func<T1, bool> expression,\r\n\t\t\t\t\t\t\t\t Action<Func<T1, bool>, Func<T1, TResult>> recorder,\r\n\t\t\t\t\t\t\t\t TMatcher matcher)\r\n\t{\r\n\t\t_expression = expression;\r\n\t\t_recorder = recorder;\r\n\t\t_matcher = matcher;\r\n\t}\r\n\r\n\tpublic TMatcher Do(Func<T1, TResult> action)\r\n    {\r\n        _recorder(_expression, action);\r\n        return _matcher;\r\n    }\r\n\r\n    public TMatcher Do(TResult value)\r\n    {\r\n        _recorder(_expression, x => value);\r\n        return _matcher;\r\n    }\r\n}\r\n```\r\n\r\nWith records, I'd be able to *almost* replace the above with:\r\n\r\n``` cs\r\npublic class WhereForFuncHandler<TMatcher, T1, TResult>(\r\n    Func<T1, bool> expression,\r\n    Action<Func<T1, bool>, Func<T1, TResult>> recorder,\r\n    TMatcher matcher)\r\n{\r\n    public TMatcher Do(Func<T1, TResult> action)\r\n    {\r\n        recorder(expression, action);\r\n        return matcher;\r\n    }\r\n\r\n    public TMatcher Do(TResult value)\r\n    {\r\n        recorder(expression, x => value);\r\n        return matcher;\r\n    }\r\n}\r\n```\r\n\r\nThere would be one, very important, difference though: the constructor would now be public. It would therefore be useful if the accessibility of the constructor could be specified for a record, if it needs to be different to the record itself. Possibly something like:\r\n\r\n``` cs\r\npublic class WhereForFuncHandler<TMatcher, T1, TResult>(\r\n    Func<T1, bool> expression,\r\n    Action<Func<T1, bool>, Func<T1, TResult>> recorder,\r\n    TMatcher matcher)\r\n{\r\n    internal WhereForFuncHandler();  // tells the compiler to generate an internal constructor\r\n\r\n    public TMatcher Do(Func<T1, TResult> action)\r\n    {\r\n        recorder(expression, action);\r\n        return matcher;\r\n    }\r\n\r\n    public TMatcher Do(TResult value)\r\n    {\r\n        recorder(expression, x => value);\r\n        return matcher;\r\n    }\r\n}\r\n```\r\nThis would allow the boilerplate-avoidance features of records to be utilised, without compromising the ability to specify the accessibility of the constructor."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/185304705","html_url":"https://github.com/dotnet/roslyn/issues/8798#issuecomment-185304705","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/8798","id":185304705,"user":{"login":"DavidArno","id":196899,"avatar_url":"https://avatars.githubusercontent.com/u/196899?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidArno","html_url":"https://github.com/DavidArno","followers_url":"https://api.github.com/users/DavidArno/followers","following_url":"https://api.github.com/users/DavidArno/following{/other_user}","gists_url":"https://api.github.com/users/DavidArno/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidArno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidArno/subscriptions","organizations_url":"https://api.github.com/users/DavidArno/orgs","repos_url":"https://api.github.com/users/DavidArno/repos","events_url":"https://api.github.com/users/DavidArno/events{/privacy}","received_events_url":"https://api.github.com/users/DavidArno/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T17:11:08Z","updated_at":"2016-02-17T17:11:08Z","body":"@alrz,\r\n\r\nI've updated the title as suggested. I'm still a little unsure whether I should close this proposal though as my initial use case doesn't really fit the new title so well. "}}