{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/8074","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/8074/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/8074/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/8074/events","html_url":"https://github.com/dotnet/roslyn/issues/8074","id":127916323,"number":8074,"title":"Proposal: Allow using wildcard for throwaway variables","user":{"login":"dsaf","id":3845650,"avatar_url":"https://avatars.githubusercontent.com/u/3845650?v=3","gravatar_id":"","url":"https://api.github.com/users/dsaf","html_url":"https://github.com/dsaf","followers_url":"https://api.github.com/users/dsaf/followers","following_url":"https://api.github.com/users/dsaf/following{/other_user}","gists_url":"https://api.github.com/users/dsaf/gists{/gist_id}","starred_url":"https://api.github.com/users/dsaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsaf/subscriptions","organizations_url":"https://api.github.com/users/dsaf/orgs","repos_url":"https://api.github.com/users/dsaf/repos","events_url":"https://api.github.com/users/dsaf/events{/privacy}","received_events_url":"https://api.github.com/users/dsaf/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"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Discussion","name":"Discussion","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2016-01-21T12:41:56Z","updated_at":"2016-01-30T22:15:52Z","closed_at":null,"body":"Related to https://github.com/dotnet/roslyn/issues/20#issuecomment-70366000 and #8049.\r\n\r\nPractical use cases:\r\n\r\nhttp://nsubstitute.github.io/help/received-calls   (*Checking calls to properties*)\r\n\r\nhttps://confluence.jetbrains.com/display/ReSharper/Return+value+of+pure+method+is+not+used\r\n\r\nBefore:\r\n```csharp\r\nvar mode = calculator.Mode;\r\ncalculator.Mode = \"TEST\";\r\n \r\n//Check received call to property getter. We need to assign the result to a variable to keep the compiler happy: \"Only assignment, call, increment, decrement, and new object expressions can be used as a statement\".\r\nvar temp1 = calculator.Received().Mode;\r\nvar temp2 = calculator.Received().Mode;\r\nvar temp3 = calculator.Received().Mode;\r\n```\r\n\r\nAfter:\r\n```csharp\r\nvar mode = calculator.Mode;\r\ncalculator.Mode = \"TEST\";\r\n \r\n//Check received call to property getter\r\nvar * = calculator.Received().Mode;\r\nvar * = calculator.Received().Mode;\r\nvar * = calculator.Received().Mode;\r\n```"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/177318435","html_url":"https://github.com/dotnet/roslyn/issues/8074#issuecomment-177318435","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/8074","id":177318435,"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-01-30T22:15:52Z","updated_at":"2016-01-30T22:15:52Z","body":"@HaloFour,\r\n\r\nI'm really not following the thinking behind your position here. \r\n\r\n* You rightly say that \"I don't think language features should be designed around how testing libraries happen to function\". I fully agree. If the proposal were for `*` to be made available simply to assist with writing tests, then it would be a questionable feature indeed. It isn't; I simply use it as yet another example of where it could be of use.\r\n* You argue that just because C-style languages traditionally allow the return value to be implicitly ignored, there's no reason to change that. C-style languages also, for example, require the body of a function be wrapped in `{}`. Lambdas and expression-bodied methods do not follow this convention. Clearly \"we don't current do that\" is no argument against change.\r\n\r\nWhat I'm arguing for is consistency across the language for any new feature. So, for example, you suggest that `*` will be able to be used in lambdas:\r\n\r\n    button.Click += (*, *) => { Console.WriteLine(\"Clicked!\"); };\r\n\r\nThat begs the question, will I be able to declare an event handler like this:\r\n\r\n    private void ListChanged(object *, EventArgs *) \r\n    {\r\n        ...\r\n    }\r\n\r\nwhen I don't use either parameter? I suspect the answer is \"no\", which will mean yet another inconsistency.\r\n\r\nCurrently, my use of `_` is far from idiomatic and most certainly isn't perfect. It's actually a fragile feature, for the moment I need to use `_` more than once in a single scope, I either need to declare it with `object` or `dynamic`, rather than `var` and then re-use it, or I can ditch `_` and switch back to `junk1`, `junk2` etc. By making `*` consistent across the whole language, this problem would be addressed."}}