{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/3561","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/3561/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/3561/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/3561/events","html_url":"https://github.com/dotnet/roslyn/issues/3561","id":89044207,"number":3561,"title":"Proposal:  Shorthand for simple expression lambdas","user":{"login":"HaloFour","id":10102290,"avatar_url":"https://avatars.githubusercontent.com/u/10102290?v=3","gravatar_id":"","url":"https://api.github.com/users/HaloFour","html_url":"https://github.com/HaloFour","followers_url":"https://api.github.com/users/HaloFour/followers","following_url":"https://api.github.com/users/HaloFour/following{/other_user}","gists_url":"https://api.github.com/users/HaloFour/gists{/gist_id}","starred_url":"https://api.github.com/users/HaloFour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HaloFour/subscriptions","organizations_url":"https://api.github.com/users/HaloFour/orgs","repos_url":"https://api.github.com/users/HaloFour/repos","events_url":"https://api.github.com/users/HaloFour/events{/privacy}","received_events_url":"https://api.github.com/users/HaloFour/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-17T15:10:04Z","updated_at":"2015-06-17T16:59:53Z","closed_at":null,"body":"This has come up a few times on CodePlex as well as here but I've not seen any formal proposal for it so I thought I'd post one just to track it and get some conversation going about it.\r\n\r\nMany of the LINQ extension methods accept a single argument and return a value, most often the result of a simple expression stemming from that argument.  In those simple cases the developer is still required to assign the parameter value to a name that cannot shadow a name used in the current scope and then immediately reference that name in the body of the closure.\r\n\r\n```cs\r\nvar query = db.Orders\r\n    .Where(order => order.Value > 50.0m)\r\n    .Select(order => order.Employee)\r\n    .OrderBy(employee => employee.Name);\r\n```\r\n\r\nI propose that a short-hand version of this common pattern where the value of the argument can be accessed through a specific sigil which must be referenced in the method body.  The following uses the sigil `@` and is the same as the query above:\r\n\r\n```cs\r\nvar query = db.Orders\r\n    .Where(@.Value > 50.0m)\r\n    .Select(@.Employee)\r\n    .OrderBy(@.Name);\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/112877245","html_url":"https://github.com/dotnet/roslyn/issues/3561#issuecomment-112877245","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/3561","id":112877245,"user":{"login":"Suchiman","id":7110884,"avatar_url":"https://avatars.githubusercontent.com/u/7110884?v=3","gravatar_id":"","url":"https://api.github.com/users/Suchiman","html_url":"https://github.com/Suchiman","followers_url":"https://api.github.com/users/Suchiman/followers","following_url":"https://api.github.com/users/Suchiman/following{/other_user}","gists_url":"https://api.github.com/users/Suchiman/gists{/gist_id}","starred_url":"https://api.github.com/users/Suchiman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suchiman/subscriptions","organizations_url":"https://api.github.com/users/Suchiman/orgs","repos_url":"https://api.github.com/users/Suchiman/repos","events_url":"https://api.github.com/users/Suchiman/events{/privacy}","received_events_url":"https://api.github.com/users/Suchiman/received_events","type":"User","site_admin":false},"created_at":"2015-06-17T16:59:53Z","updated_at":"2015-06-17T16:59:53Z","body":"While my mind is not settled about wether this syntax is cool or ugly, let's think about these problems first:\r\n### Nesting\r\n```csharp\r\nvar query = db.Orders\r\n    .Where(@.Items.Any(@.Weight > 20));\r\n```\r\n### Overload resolution when passing Lambdas\r\n```csharp\r\ninstance.Do(@.SomeMethod(() => @.SomeProperty));\r\n```\r\nIs `() => @.SomeProperty` now passed as argument-less lambda or is it a lambda with one anonymous @ argument that returns lambda with a closure on @, e.g.:\r\n```csharp\r\ninstance.Do(@.SomeMethod(@ => () => @.SomeProperty));\r\n```\r\n\r\n### Constant values / throwing away the argument?\r\n```csharp\r\nvar query = db.Orders\r\n    .Where(@.true); //? member access, no\r\n    .Where(@true); //? rather like this, though **extremely** small difference to verbatim identifier / strings\r\n    .Where(true); //? not unique enough, overload resolution problems\r\n```\r\n### Also is this allowed?\r\n```csharp\r\nvar query = db.Orders\r\n    .Where({\r\n        return @.Items.Any(x => true);\r\n    });\r\n```"}}