{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/csharplang/issues/1590","repository_url":"https://api.github.com/repos/dotnet/csharplang","labels_url":"https://api.github.com/repos/dotnet/csharplang/issues/1590/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/csharplang/issues/1590/comments","events_url":"https://api.github.com/repos/dotnet/csharplang/issues/1590/events","html_url":"https://github.com/dotnet/csharplang/issues/1590","id":328521372,"node_id":"MDU6SXNzdWUzMjg1MjEzNzI=","number":1590,"title":"Allow inner struct/class/enum names intersect with member variable names","user":{"login":"rndfax","id":8142124,"node_id":"MDQ6VXNlcjgxNDIxMjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/8142124?v=4","gravatar_id":"","url":"https://api.github.com/users/rndfax","html_url":"https://github.com/rndfax","followers_url":"https://api.github.com/users/rndfax/followers","following_url":"https://api.github.com/users/rndfax/following{/other_user}","gists_url":"https://api.github.com/users/rndfax/gists{/gist_id}","starred_url":"https://api.github.com/users/rndfax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rndfax/subscriptions","organizations_url":"https://api.github.com/users/rndfax/orgs","repos_url":"https://api.github.com/users/rndfax/repos","events_url":"https://api.github.com/users/rndfax/events{/privacy}","received_events_url":"https://api.github.com/users/rndfax/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":26,"created_at":"2018-06-01T13:32:52Z","updated_at":"2018-06-02T20:27:37Z","closed_at":null,"author_association":"NONE","body":"C++ allows this, but C# doesn't. Here is some C# example:\r\n```c#\r\nclass A {\r\n    public enum Mode {\r\n        Read,\r\n        Write,\r\n    }\r\n\r\n    public Mode Mode { get; private set; }\r\n\r\n    void M(Mode mode) {\r\n        Mode = Mode.Write;\r\n    }\r\n}\r\n\r\nclass B {\r\n    A A = new A();\r\n\r\n    void M2() {\r\n        if (A.Mode == A.Mode.Read) {\r\n            A.M(A.Mode.Write);\r\n        }\r\n    }\r\n}\r\n```\r\nIt gives error:\r\n```\r\nerror CS0102: The type 'A' already contains a definition for 'Mode'\r\n```\r\n\r\nI must change either\r\n* variable name or enum name and get special, kinda overkilled, naming in M2 method of B class (sometimes Mode is just a Mode, not m_mode, not GetMode, not ModeEnum, not ModeMode etc...),\r\n* or I must take out enum definition out of the A class and increase namespace pollution (sometimes Mode is related only to the A class and nothing else)\r\n\r\nin both cases this complicates things which could just work out of the box (like in C++), isnt'it?"},"comment":{"url":"https://api.github.com/repos/dotnet/csharplang/issues/comments/394114876","html_url":"https://github.com/dotnet/csharplang/issues/1590#issuecomment-394114876","issue_url":"https://api.github.com/repos/dotnet/csharplang/issues/1590","id":394114876,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDExNDg3Ng==","user":{"login":"eyalsk","id":3756641,"node_id":"MDQ6VXNlcjM3NTY2NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3756641?v=4","gravatar_id":"","url":"https://api.github.com/users/eyalsk","html_url":"https://github.com/eyalsk","followers_url":"https://api.github.com/users/eyalsk/followers","following_url":"https://api.github.com/users/eyalsk/following{/other_user}","gists_url":"https://api.github.com/users/eyalsk/gists{/gist_id}","starred_url":"https://api.github.com/users/eyalsk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eyalsk/subscriptions","organizations_url":"https://api.github.com/users/eyalsk/orgs","repos_url":"https://api.github.com/users/eyalsk/repos","events_url":"https://api.github.com/users/eyalsk/events{/privacy}","received_events_url":"https://api.github.com/users/eyalsk/received_events","type":"User","site_admin":false},"created_at":"2018-06-02T20:27:36Z","updated_at":"2018-06-02T20:27:36Z","author_association":"CONTRIBUTOR","body":"@masonwheeler Just to add to the examples made by @rndfax:\r\n\r\nThis works too:\r\n```\r\nclass B\r\n{\r\n\tpublic enum Mode\r\n\t{\r\n\t\tRead,\r\n\t\tWrite,\r\n\t}\r\n}\r\n\r\nclass A : B\r\n{\r\n\tpublic Mode Mode { get; private set; }\r\n\r\n\tvoid M(Mode mode)\r\n\t{\r\n\t\tMode = Mode.Write;\r\n\t}\r\n}\r\n```"}}
{"actor":{"display_login":"eyalsk"}}