{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/9599","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/9599/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/9599/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/9599/events","html_url":"https://github.com/dotnet/roslyn/issues/9599","id":139548246,"number":9599,"title":"[Proposal] Extend nameof to handle non visible members too","user":{"login":"tvsonar","id":11485373,"avatar_url":"https://avatars.githubusercontent.com/u/11485373?v=3","gravatar_id":"","url":"https://api.github.com/users/tvsonar","html_url":"https://github.com/tvsonar","followers_url":"https://api.github.com/users/tvsonar/followers","following_url":"https://api.github.com/users/tvsonar/following{/other_user}","gists_url":"https://api.github.com/users/tvsonar/gists{/gist_id}","starred_url":"https://api.github.com/users/tvsonar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvsonar/subscriptions","organizations_url":"https://api.github.com/users/tvsonar/orgs","repos_url":"https://api.github.com/users/tvsonar/repos","events_url":"https://api.github.com/users/tvsonar/events{/privacy}","received_events_url":"https://api.github.com/users/tvsonar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-09T11:17:36Z","updated_at":"2016-03-09T11:49:47Z","closed_at":null,"body":"This is a proposal to extend `nameof` to handle inaccessible members. There are similar proposals to include the full name of the referenced construct with namespaces, so ideally the syntax should support all these extensions.\r\n\r\nGiven the following code, the test is not resilient to changes to the private member name.\r\n```C#\r\npublic class MySubject\r\n{\r\n    private int SomeVeryComplexLogic()\r\n    {\r\n        return 42;\r\n    }\r\n}\r\n\r\n[TestClass]\r\npublic class Test\r\n{\r\n    [TestMethod]\r\n    public MySubject_SomeVeryComplexLogic()\r\n    {\r\n        var subject = new MySubject();\r\n        PrivateObject accessor = new PrivateObject(subject);\r\n        var res = accessor.Invoke(\"SomeVeryComplexLogic\");\r\n    }\r\n}\r\n```\r\n\r\nHowever, with minimal changes to `nameof`, we could write something like this:\r\n```C#\r\nvar res = accessor.Invoke(nameof(MySubject.SomeVeryComplexLogic, private));\r\n```"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/194260280","html_url":"https://github.com/dotnet/roslyn/issues/9599#issuecomment-194260280","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/9599","id":194260280,"user":{"login":"svick","id":287848,"avatar_url":"https://avatars.githubusercontent.com/u/287848?v=3","gravatar_id":"","url":"https://api.github.com/users/svick","html_url":"https://github.com/svick","followers_url":"https://api.github.com/users/svick/followers","following_url":"https://api.github.com/users/svick/following{/other_user}","gists_url":"https://api.github.com/users/svick/gists{/gist_id}","starred_url":"https://api.github.com/users/svick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svick/subscriptions","organizations_url":"https://api.github.com/users/svick/orgs","repos_url":"https://api.github.com/users/svick/repos","events_url":"https://api.github.com/users/svick/events{/privacy}","received_events_url":"https://api.github.com/users/svick/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T11:49:47Z","updated_at":"2016-03-09T11:49:47Z","body":"The problem I have with this is that it effectively makes names of *private* members part of the *public* contract.\r\n\r\nAnother problem is that it would mean that referencing a reference assembly and referencing an implementation assembly suddenly start behaving differently.\r\n\r\nAlso, I don't think the language should make unsupported operations easier (even if they are sometimes necessary)."}}