{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/7322","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/7322/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/7322/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/7322/events","html_url":"https://github.com/dotnet/roslyn/issues/7322","id":120974934,"number":7322,"title":"with statement","user":{"login":"krwq","id":660048,"avatar_url":"https://avatars.githubusercontent.com/u/660048?v=3","gravatar_id":"","url":"https://api.github.com/users/krwq","html_url":"https://github.com/krwq","followers_url":"https://api.github.com/users/krwq/followers","following_url":"https://api.github.com/users/krwq/following{/other_user}","gists_url":"https://api.github.com/users/krwq/gists{/gist_id}","starred_url":"https://api.github.com/users/krwq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krwq/subscriptions","organizations_url":"https://api.github.com/users/krwq/orgs","repos_url":"https://api.github.com/users/krwq/repos","events_url":"https://api.github.com/users/krwq/events{/privacy}","received_events_url":"https://api.github.com/users/krwq/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-08T10:05:28Z","updated_at":"2015-12-08T12:15:47Z","closed_at":null,"body":"Recently I pretty often start seeing patterns like:\r\n```csharp\r\nclass MyClass\r\n{\r\n  public Type1 Field1 { get; set; }\r\n  public Type2 Field2 { get; set; }\r\n  // ...\r\n  public MyClass WithField1(Type1 field1)\r\n  {\r\n    Field1 = field1;\r\n    return this;\r\n  }\r\n  // ...\r\n}\r\n```\r\n\r\nThis seems pretty weird to repeat yourself million times\r\n\r\nShould we provide pascal like operator for this?\r\n```csharp\r\nclass MyClass\r\n{\r\n  public Type1 Field1 { get; set; }\r\n  public Type2 Field2 { get; set; }\r\n}\r\n\r\n// somewhere in the code (we do have initializer for the constructor but what later?):\r\nMyClass c = new MyClass();\r\nwith (c)\r\n{\r\n   .Field1 = something1;\r\n   .Field2 = something2;\r\n   // ...\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/162863978","html_url":"https://github.com/dotnet/roslyn/issues/7322#issuecomment-162863978","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/7322","id":162863978,"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},"created_at":"2015-12-08T12:15:47Z","updated_at":"2015-12-08T12:15:47Z","body":"Dupe of #133, #951 and #6553 to varying degrees.\r\n\r\nThe `With*` property pattern is a different beast, though, particularly since it returns a reference to the class to facilitate chaining but it doesn't necessarily return the reference to the current instance, which facilitates incremental building of immutable objects."}}