{"action":"created","issue":{"url":"https://api.github.com/repos/mono/monodevelop/issues/4849","repository_url":"https://api.github.com/repos/mono/monodevelop","labels_url":"https://api.github.com/repos/mono/monodevelop/issues/4849/labels{/name}","comments_url":"https://api.github.com/repos/mono/monodevelop/issues/4849/comments","events_url":"https://api.github.com/repos/mono/monodevelop/issues/4849/events","html_url":"https://github.com/mono/monodevelop/issues/4849","id":324557258,"number":4849,"title":"SolutionFolder Items AddRange doesn't properly update Items","user":{"login":"dansiegel","id":3860573,"avatar_url":"https://avatars3.githubusercontent.com/u/3860573?v=4","gravatar_id":"","url":"https://api.github.com/users/dansiegel","html_url":"https://github.com/dansiegel","followers_url":"https://api.github.com/users/dansiegel/followers","following_url":"https://api.github.com/users/dansiegel/following{/other_user}","gists_url":"https://api.github.com/users/dansiegel/gists{/gist_id}","starred_url":"https://api.github.com/users/dansiegel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dansiegel/subscriptions","organizations_url":"https://api.github.com/users/dansiegel/orgs","repos_url":"https://api.github.com/users/dansiegel/repos","events_url":"https://api.github.com/users/dansiegel/events{/privacy}","received_events_url":"https://api.github.com/users/dansiegel/received_events","type":"User","site_admin":false},"labels":[{"id":835592406,"url":"https://api.github.com/repos/mono/monodevelop/labels/need-info","name":"need-info","color":"ff5d00","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-18T21:27:18Z","updated_at":"2018-05-21T04:17:11Z","closed_at":null,"author_association":"NONE","body":"## Description\r\n\r\nThere were actually a few breaking changes from 7.4 to 7.5/7.6\r\n\r\n### Order of operations Behavior Change\r\nIn 7.4 items could be added to the folder before the folder was added to the solution's RootFolder. This now throws an ArgumentException that the folder is not part of the Workspace.\r\n\r\n### Add Range\r\n\r\nUsing the snippet below when the items are added to the SolutionFolder.Items using the AddRange, the result is that the first item is moved from it's current position in the Solution to the folder, while the other items show up as duplicates in the Workspace in the RootFolder and the new SolutionFolder.\r\n\r\n```cs\r\npublic SolutionFolder AddSolutionFolder(Solution solution, string name, params SolutionFolderItem[] items)\r\n{\r\n    var solutionFolder = new SolutionFolder\r\n    {\r\n        Name = name\r\n    };\r\n    solution.RootFolder.AddItem(solutionFolder);\r\n    solutionFolder.Items.AddRange(items);\r\n    return solutionFolder;\r\n}\r\n```\r\n\r\nReplacing `AddRange` with a foreach / Add resolves the issue where each item shows up in the new Folder."},"comment":{"url":"https://api.github.com/repos/mono/monodevelop/issues/comments/390548896","html_url":"https://github.com/mono/monodevelop/issues/4849#issuecomment-390548896","issue_url":"https://api.github.com/repos/mono/monodevelop/issues/4849","id":390548896,"user":{"login":"DavidKarlas","id":774791,"avatar_url":"https://avatars3.githubusercontent.com/u/774791?v=4","gravatar_id":"","url":"https://api.github.com/users/DavidKarlas","html_url":"https://github.com/DavidKarlas","followers_url":"https://api.github.com/users/DavidKarlas/followers","following_url":"https://api.github.com/users/DavidKarlas/following{/other_user}","gists_url":"https://api.github.com/users/DavidKarlas/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidKarlas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidKarlas/subscriptions","organizations_url":"https://api.github.com/users/DavidKarlas/orgs","repos_url":"https://api.github.com/users/DavidKarlas/repos","events_url":"https://api.github.com/users/DavidKarlas/events{/privacy}","received_events_url":"https://api.github.com/users/DavidKarlas/received_events","type":"User","site_admin":false},"created_at":"2018-05-21T04:17:11Z","updated_at":"2018-05-21T04:17:11Z","author_association":"MEMBER","body":"Can you give stacktrace of `ArgumentException`?"}}
{"actor":{"display_login":"DavidKarlas"}}