{"action":"created","comment":{"url":"https://api.github.com/repos/gluck/il-repack/pulls/comments/30398036","id":30398036,"diff_hunk":"@@ -0,0 +1,154 @@\n+using Confuser.Renamer.BAML;\n+using Fasterflect;\n+using NUnit.Framework.Constraints;\n+using System;\n+using System.Collections;\n+using System.Collections.Generic;\n+using System.Linq;\n+\n+namespace ILRepack.Tests.Utils\n+{\n+    /// <summary>\n+    /// An ad-hoc matcher for the BamlDocument. If it's ugly, then one reason is\n+    /// that the Constraint architecture is pretty weird :)\n+    ///\n+    /// We need it in order to check just the required information from a BAML stream,\n+    /// since we don't care about things like line information (at least for the\n+    /// current usage which generates a known set of records).\n+    /// </summary>\n+    internal class BamlDocumentMatcher : Constraint\n+    {\n+        private readonly BamlDocument _expectedDocument;\n+        private object _actualValue, _expectedValue, _context;\n+\n+        private readonly Dictionary<Type, List<string>> _propertiesToCheck = new Dictionary<Type, List<string>>\n+        {\n+            { typeof(AssemblyInfoRecord), new List<string> { \"AssemblyFullName\", \"AssemblyId\" } },\n+            { typeof(AttributeInfoRecord), new List<string> { \"AttributeId\", \"Name\", \"AttributeUsage\", \"OwnerTypeId\" } },\n+            { typeof(ElementStartRecord), new List<string> { \"Flags\", \"TypeId\" } },\n+            { typeof(XmlnsPropertyRecord), new List<string> { \"Prefix\", \"XmlNamespace\", \"AssemblyIds\" } },\n+            { typeof(PropertyListStartRecord), new List<string> { \"AttributeId\" } },\n+            { typeof(PropertyWithConverterRecord), new List<string> { \"AttributeId\", \"ConverterTypeId\", \"Value\" } },\n+            //TODO: Too lazy to do reference-only check for this.\n+            //   { typeof(DeferableContentStartRecord), new List<string> { \"Record\" } }\n+        };\n+\n+        public BamlDocumentMatcher(BamlDocument expectedDocument)\n+        {\n+            _expectedDocument = expectedDocument;\n+        }\n+\n+        public override bool Matches(object actual)\n+        {\n+            var bamlDocument = (BamlDocument)actual;\n+\n+            if (!AreEqual(bamlDocument.Signature, _expectedDocument.Signature))\n+            {\n+                _context = \"Document Signature\";\n+                return false;\n+            }\n+\n+            if (!HaveSameVersion(\"ReaderVersion\", bamlDocument, _expectedDocument) ||\n+                !HaveSameVersion(\"WriterVersion\", bamlDocument, _expectedDocument) ||\n+                !HaveSameVersion(\"UpdaterVersion\", bamlDocument, _expectedDocument))\n+            {\n+                return false;\n+            }\n+\n+            return AreRecordsEquivalent(\n+                GetRelevantRecords(_expectedDocument),\n+                GetRelevantRecords(bamlDocument));\n+        }\n+\n+        private bool HaveSameVersion(\n+            string versionProperty, BamlDocument actualDocument, BamlDocument expectedDocument)\n+        {\n+            var actualVersion = (BamlDocument.BamlVersion)actualDocument.GetPropertyValue(versionProperty);\n+            var expectedVersion = (BamlDocument.BamlVersion)expectedDocument.GetPropertyValue(versionProperty);\n+\n+            _context = versionProperty + \".Major\";\n+            if (!AreEqual(actualVersion.Major, actualVersion.Major))\n+                return false;\n+\n+            _context = versionProperty + \".Minor\";\n+            return AreEqual(actualVersion.Minor, expectedVersion.Minor);\n+        }\n+\n+        private bool AreEqual(object expected, object actual)\n+        {\n+            _expectedValue = expected;\n+            _actualValue = actual;\n+\n+            return Equals(_expectedValue, _actualValue);","path":"ILRepack.Tests/Utils/BamlDocumentMatcher.cs","position":82,"original_position":82,"commit_id":"15fa64ad0bdbca171c05ffba9f7f73b6c6f81dc2","original_commit_id":"15fa64ad0bdbca171c05ffba9f7f73b6c6f81dc2","user":{"login":"timotei","id":428492,"avatar_url":"https://avatars.githubusercontent.com/u/428492?v=3","gravatar_id":"","url":"https://api.github.com/users/timotei","html_url":"https://github.com/timotei","followers_url":"https://api.github.com/users/timotei/followers","following_url":"https://api.github.com/users/timotei/following{/other_user}","gists_url":"https://api.github.com/users/timotei/gists{/gist_id}","starred_url":"https://api.github.com/users/timotei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timotei/subscriptions","organizations_url":"https://api.github.com/users/timotei/orgs","repos_url":"https://api.github.com/users/timotei/repos","events_url":"https://api.github.com/users/timotei/events{/privacy}","received_events_url":"https://api.github.com/users/timotei/received_events","type":"User","site_admin":false},"body":"The initial way I did this was with the nice *dynamic* keyword, but we don't get proper error results (e.g.: which property failed).","created_at":"2015-05-15T10:12:09Z","updated_at":"2015-05-15T10:12:09Z","html_url":"https://github.com/gluck/il-repack/pull/86#discussion_r30398036","pull_request_url":"https://api.github.com/repos/gluck/il-repack/pulls/86","_links":{"self":{"href":"https://api.github.com/repos/gluck/il-repack/pulls/comments/30398036"},"html":{"href":"https://github.com/gluck/il-repack/pull/86#discussion_r30398036"},"pull_request":{"href":"https://api.github.com/repos/gluck/il-repack/pulls/86"}}},"pull_request":{"url":"https://api.github.com/repos/gluck/il-repack/pulls/86","id":35123894,"html_url":"https://github.com/gluck/il-repack/pull/86","diff_url":"https://github.com/gluck/il-repack/pull/86.diff","patch_url":"https://github.com/gluck/il-repack/pull/86.patch","issue_url":"https://api.github.com/repos/gluck/il-repack/issues/86","number":86,"state":"open","locked":false,"title":"Support more WPF usecases (nested libraries user controls, basic themes)","user":{"login":"timotei","id":428492,"avatar_url":"https://avatars.githubusercontent.com/u/428492?v=3","gravatar_id":"","url":"https://api.github.com/users/timotei","html_url":"https://github.com/timotei","followers_url":"https://api.github.com/users/timotei/followers","following_url":"https://api.github.com/users/timotei/following{/other_user}","gists_url":"https://api.github.com/users/timotei/gists{/gist_id}","starred_url":"https://api.github.com/users/timotei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timotei/subscriptions","organizations_url":"https://api.github.com/users/timotei/orgs","repos_url":"https://api.github.com/users/timotei/repos","events_url":"https://api.github.com/users/timotei/events{/privacy}","received_events_url":"https://api.github.com/users/timotei/received_events","type":"User","site_admin":false},"body":"Add almost full? support for WPF by adding support for nested libraries User Control and classes usage in XAML\r\n\r\nIf there's anything to be said is that I had to make the Res.data field mutable in order for the chain of res processors to work properly.\r\n\r\n ","created_at":"2015-05-11T12:50:16Z","updated_at":"2015-05-15T10:12:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1984f223153d120dce6116c4b4e785f54cb5c5d5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gluck/il-repack/pulls/86/commits","review_comments_url":"https://api.github.com/repos/gluck/il-repack/pulls/86/comments","review_comment_url":"https://api.github.com/repos/gluck/il-repack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gluck/il-repack/issues/86/comments","statuses_url":"https://api.github.com/repos/gluck/il-repack/statuses/15fa64ad0bdbca171c05ffba9f7f73b6c6f81dc2","head":{"label":"timotei:wpf","ref":"wpf","sha":"15fa64ad0bdbca171c05ffba9f7f73b6c6f81dc2","user":{"login":"timotei","id":428492,"avatar_url":"https://avatars.githubusercontent.com/u/428492?v=3","gravatar_id":"","url":"https://api.github.com/users/timotei","html_url":"https://github.com/timotei","followers_url":"https://api.github.com/users/timotei/followers","following_url":"https://api.github.com/users/timotei/following{/other_user}","gists_url":"https://api.github.com/users/timotei/gists{/gist_id}","starred_url":"https://api.github.com/users/timotei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timotei/subscriptions","organizations_url":"https://api.github.com/users/timotei/orgs","repos_url":"https://api.github.com/users/timotei/repos","events_url":"https://api.github.com/users/timotei/events{/privacy}","received_events_url":"https://api.github.com/users/timotei/received_events","type":"User","site_admin":false},"repo":{"id":32861233,"name":"il-repack","full_name":"timotei/il-repack","owner":{"login":"timotei","id":428492,"avatar_url":"https://avatars.githubusercontent.com/u/428492?v=3","gravatar_id":"","url":"https://api.github.com/users/timotei","html_url":"https://github.com/timotei","followers_url":"https://api.github.com/users/timotei/followers","following_url":"https://api.github.com/users/timotei/following{/other_user}","gists_url":"https://api.github.com/users/timotei/gists{/gist_id}","starred_url":"https://api.github.com/users/timotei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timotei/subscriptions","organizations_url":"https://api.github.com/users/timotei/orgs","repos_url":"https://api.github.com/users/timotei/repos","events_url":"https://api.github.com/users/timotei/events{/privacy}","received_events_url":"https://api.github.com/users/timotei/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/timotei/il-repack","description":"Open-source alternative to ILMerge","fork":true,"url":"https://api.github.com/repos/timotei/il-repack","forks_url":"https://api.github.com/repos/timotei/il-repack/forks","keys_url":"https://api.github.com/repos/timotei/il-repack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/timotei/il-repack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/timotei/il-repack/teams","hooks_url":"https://api.github.com/repos/timotei/il-repack/hooks","issue_events_url":"https://api.github.com/repos/timotei/il-repack/issues/events{/number}","events_url":"https://api.github.com/repos/timotei/il-repack/events","assignees_url":"https://api.github.com/repos/timotei/il-repack/assignees{/user}","branches_url":"https://api.github.com/repos/timotei/il-repack/branches{/branch}","tags_url":"https://api.github.com/repos/timotei/il-repack/tags","blobs_url":"https://api.github.com/repos/timotei/il-repack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/timotei/il-repack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/timotei/il-repack/git/refs{/sha}","trees_url":"https://api.github.com/repos/timotei/il-repack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/timotei/il-repack/statuses/{sha}","languages_url":"https://api.github.com/repos/timotei/il-repack/languages","stargazers_url":"https://api.github.com/repos/timotei/il-repack/stargazers","contributors_url":"https://api.github.com/repos/timotei/il-repack/contributors","subscribers_url":"https://api.github.com/repos/timotei/il-repack/subscribers","subscription_url":"https://api.github.com/repos/timotei/il-repack/subscription","commits_url":"https://api.github.com/repos/timotei/il-repack/commits{/sha}","git_commits_url":"https://api.github.com/repos/timotei/il-repack/git/commits{/sha}","comments_url":"https://api.github.com/repos/timotei/il-repack/comments{/number}","issue_comment_url":"https://api.github.com/repos/timotei/il-repack/issues/comments{/number}","contents_url":"https://api.github.com/repos/timotei/il-repack/contents/{+path}","compare_url":"https://api.github.com/repos/timotei/il-repack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/timotei/il-repack/merges","archive_url":"https://api.github.com/repos/timotei/il-repack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/timotei/il-repack/downloads","issues_url":"https://api.github.com/repos/timotei/il-repack/issues{/number}","pulls_url":"https://api.github.com/repos/timotei/il-repack/pulls{/number}","milestones_url":"https://api.github.com/repos/timotei/il-repack/milestones{/number}","notifications_url":"https://api.github.com/repos/timotei/il-repack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/timotei/il-repack/labels{/name}","releases_url":"https://api.github.com/repos/timotei/il-repack/releases{/id}","created_at":"2015-03-25T11:48:51Z","updated_at":"2015-05-08T13:54:14Z","pushed_at":"2015-05-15T10:02:13Z","git_url":"git://github.com/timotei/il-repack.git","ssh_url":"git@github.com:timotei/il-repack.git","clone_url":"https://github.com/timotei/il-repack.git","svn_url":"https://github.com/timotei/il-repack","homepage":"","size":1104,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gluck:wpf","ref":"wpf","sha":"e3e1297e61beb09390270d8c49369aea4d2ba3f4","user":{"login":"gluck","id":604263,"avatar_url":"https://avatars.githubusercontent.com/u/604263?v=3","gravatar_id":"","url":"https://api.github.com/users/gluck","html_url":"https://github.com/gluck","followers_url":"https://api.github.com/users/gluck/followers","following_url":"https://api.github.com/users/gluck/following{/other_user}","gists_url":"https://api.github.com/users/gluck/gists{/gist_id}","starred_url":"https://api.github.com/users/gluck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gluck/subscriptions","organizations_url":"https://api.github.com/users/gluck/orgs","repos_url":"https://api.github.com/users/gluck/repos","events_url":"https://api.github.com/users/gluck/events{/privacy}","received_events_url":"https://api.github.com/users/gluck/received_events","type":"User","site_admin":false},"repo":{"id":2613965,"name":"il-repack","full_name":"gluck/il-repack","owner":{"login":"gluck","id":604263,"avatar_url":"https://avatars.githubusercontent.com/u/604263?v=3","gravatar_id":"","url":"https://api.github.com/users/gluck","html_url":"https://github.com/gluck","followers_url":"https://api.github.com/users/gluck/followers","following_url":"https://api.github.com/users/gluck/following{/other_user}","gists_url":"https://api.github.com/users/gluck/gists{/gist_id}","starred_url":"https://api.github.com/users/gluck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gluck/subscriptions","organizations_url":"https://api.github.com/users/gluck/orgs","repos_url":"https://api.github.com/users/gluck/repos","events_url":"https://api.github.com/users/gluck/events{/privacy}","received_events_url":"https://api.github.com/users/gluck/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gluck/il-repack","description":"Open-source alternative to ILMerge","fork":false,"url":"https://api.github.com/repos/gluck/il-repack","forks_url":"https://api.github.com/repos/gluck/il-repack/forks","keys_url":"https://api.github.com/repos/gluck/il-repack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gluck/il-repack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gluck/il-repack/teams","hooks_url":"https://api.github.com/repos/gluck/il-repack/hooks","issue_events_url":"https://api.github.com/repos/gluck/il-repack/issues/events{/number}","events_url":"https://api.github.com/repos/gluck/il-repack/events","assignees_url":"https://api.github.com/repos/gluck/il-repack/assignees{/user}","branches_url":"https://api.github.com/repos/gluck/il-repack/branches{/branch}","tags_url":"https://api.github.com/repos/gluck/il-repack/tags","blobs_url":"https://api.github.com/repos/gluck/il-repack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gluck/il-repack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gluck/il-repack/git/refs{/sha}","trees_url":"https://api.github.com/repos/gluck/il-repack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gluck/il-repack/statuses/{sha}","languages_url":"https://api.github.com/repos/gluck/il-repack/languages","stargazers_url":"https://api.github.com/repos/gluck/il-repack/stargazers","contributors_url":"https://api.github.com/repos/gluck/il-repack/contributors","subscribers_url":"https://api.github.com/repos/gluck/il-repack/subscribers","subscription_url":"https://api.github.com/repos/gluck/il-repack/subscription","commits_url":"https://api.github.com/repos/gluck/il-repack/commits{/sha}","git_commits_url":"https://api.github.com/repos/gluck/il-repack/git/commits{/sha}","comments_url":"https://api.github.com/repos/gluck/il-repack/comments{/number}","issue_comment_url":"https://api.github.com/repos/gluck/il-repack/issues/comments{/number}","contents_url":"https://api.github.com/repos/gluck/il-repack/contents/{+path}","compare_url":"https://api.github.com/repos/gluck/il-repack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gluck/il-repack/merges","archive_url":"https://api.github.com/repos/gluck/il-repack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gluck/il-repack/downloads","issues_url":"https://api.github.com/repos/gluck/il-repack/issues{/number}","pulls_url":"https://api.github.com/repos/gluck/il-repack/pulls{/number}","milestones_url":"https://api.github.com/repos/gluck/il-repack/milestones{/number}","notifications_url":"https://api.github.com/repos/gluck/il-repack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gluck/il-repack/labels{/name}","releases_url":"https://api.github.com/repos/gluck/il-repack/releases{/id}","created_at":"2011-10-20T15:16:20Z","updated_at":"2015-05-13T20:13:23Z","pushed_at":"2015-05-15T10:02:14Z","git_url":"git://github.com/gluck/il-repack.git","ssh_url":"git@github.com:gluck/il-repack.git","clone_url":"https://github.com/gluck/il-repack.git","svn_url":"https://github.com/gluck/il-repack","homepage":"","size":2031,"stargazers_count":186,"watchers_count":186,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":22,"forks":38,"open_issues":22,"watchers":186,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gluck/il-repack/pulls/86"},"html":{"href":"https://github.com/gluck/il-repack/pull/86"},"issue":{"href":"https://api.github.com/repos/gluck/il-repack/issues/86"},"comments":{"href":"https://api.github.com/repos/gluck/il-repack/issues/86/comments"},"review_comments":{"href":"https://api.github.com/repos/gluck/il-repack/pulls/86/comments"},"review_comment":{"href":"https://api.github.com/repos/gluck/il-repack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gluck/il-repack/pulls/86/commits"},"statuses":{"href":"https://api.github.com/repos/gluck/il-repack/statuses/15fa64ad0bdbca171c05ffba9f7f73b6c6f81dc2"}}}}