{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/clrmd/pulls/comments/43560316","id":43560316,"diff_hunk":"@@ -0,0 +1,1077 @@\n+﻿using System;\n+using System.Diagnostics;\n+using System.Linq;\n+\n+namespace Microsoft.Diagnostics.Runtime\n+{\n+    /// <summary>\n+    /// A ClrValue represents the value of a field or variable.  This value may be of any type (or null).\n+    /// </summary>\n+    public abstract class ClrValue\n+    {\n+        private readonly RuntimeBase _runtime;\n+\n+        internal ClrValue(ClrRuntime runtime)\n+        {\n+            _runtime = (RuntimeBase)runtime;\n+        }\n+\n+        internal ClrValue(RuntimeBase runtime)\n+        {\n+            _runtime = runtime;\n+        }\n+\n+        /// <summary>\n+        /// Returns the size of the value.\n+        /// </summary>\n+        public abstract int Size { get; }\n+\n+        /// <summary>\n+        /// Returns the address of the value.\n+        /// </summary>\n+        public abstract ulong Address { get; }\n+\n+        /// <summary>\n+        /// Returns the result of ReadPointer(Address) if this value is an object.\n+        /// </summary>\n+        protected abstract ulong Object { get; }\n+\n+        /// <summary>\n+        /// Returns whether Address is an interior value.\n+        /// </summary>\n+        public abstract bool Interior { get; }\n+\n+        /// <summary>\n+        /// Returns whether this value is null (or otherwise cannot be accessed).\n+        /// </summary>\n+        public virtual bool IsNull { get { return Address == 0 || (ClrRuntime.IsObjectReference(ElementType) && Object == 0); } }\n+\n+        /// <summary>\n+        /// Returns the element type of this value.\n+        /// </summary>\n+        public abstract ClrElementType ElementType { get; }\n+        \n+        /// <summary>\n+        /// The runtime associated with this value.\n+        /// </summary>\n+        public virtual ClrRuntime Runtime { get { return _runtime; } }\n+\n+        /// <summary>\n+        /// Returns the type of this value.\n+        /// </summary>\n+        public virtual ClrType Type\n+        {\n+            get\n+            {\n+                HeapBase heap = _runtime.HeapBase;\n+                ClrElementType el = ElementType;\n+\n+                if (ClrRuntime.IsPrimitive(el))\n+                    return heap.GetBasicType(el);\n+\n+                if (ClrRuntime.IsObjectReference(el))\n+                    return AsObject().Type;\n+\n+                return GetStructElementType();\n+            }\n+        }\n+\n+        /// <summary>\n+        /// Obtains the element type when ElementType is a struct.\n+        /// </summary>\n+        /// <returns>The ClrType of this value, or ClrHeap.ErrorType if it could not be obtained.</returns>\n+        protected abstract ClrType GetStructElementType();\n+\n+        #region Converters\n+\n+        /// <summary>\n+        /// Returns a ClrObject for this value.\n+        /// </summary>\n+        /// <returns>A ClrObject for this value.  If the value is null, then ClrObject.IsNull will the true and ClrObject.Type\n+        /// will equal ClrHeap.ErrorType.</returns>\n+        public virtual ClrObject AsObject()\n+        {\n+            if (!ClrRuntime.IsObjectReference(ElementType))\n+                throw new InvalidOperationException(\"Value is not an object.\");\n+\n+            if (IsNull)\n+                throw new NullReferenceException();\n+\n+            ClrHeap heap = Runtime.GetHeap();\n+\n+            ulong obj = Object;\n+            return new ClrObject(obj, obj != 0 ? heap.GetObjectType(obj) : heap.NullType);\n+        }\n+\n+        /// <summary>\n+        /// Converts the value to a boolean.  Note that this method is a conversion, not a cast.  Similarly sized data will be converted.\n+        /// </summary>\n+        /// <returns>This value as a boolean.</returns>\n+        public virtual bool AsBoolean()\n+        {","path":"src/Microsoft.Diagnostics.Runtime/ClrValue.cs","position":111,"original_position":111,"commit_id":"aeae35b43798030ed636202463fa86a0c27693a2","original_commit_id":"aeae35b43798030ed636202463fa86a0c27693a2","user":{"login":"noahfalk","id":6243776,"avatar_url":"https://avatars.githubusercontent.com/u/6243776?v=3","gravatar_id":"","url":"https://api.github.com/users/noahfalk","html_url":"https://github.com/noahfalk","followers_url":"https://api.github.com/users/noahfalk/followers","following_url":"https://api.github.com/users/noahfalk/following{/other_user}","gists_url":"https://api.github.com/users/noahfalk/gists{/gist_id}","starred_url":"https://api.github.com/users/noahfalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahfalk/subscriptions","organizations_url":"https://api.github.com/users/noahfalk/orgs","repos_url":"https://api.github.com/users/noahfalk/repos","events_url":"https://api.github.com/users/noahfalk/events{/privacy}","received_events_url":"https://api.github.com/users/noahfalk/received_events","type":"User","site_admin":false},"body":"C# does support overloading the implicit or explicit casting operators. Rather writing:\r\nbool b = value.AsBoolean()\r\n\r\nCustomers could write:\r\nbool b = (bool)value;\r\nOR:\r\nbool b = value;","created_at":"2015-10-30T22:50:55Z","updated_at":"2015-10-30T22:50:55Z","html_url":"https://github.com/Microsoft/clrmd/pull/30#discussion_r43560316","pull_request_url":"https://api.github.com/repos/Microsoft/clrmd/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/clrmd/pulls/comments/43560316"},"html":{"href":"https://github.com/Microsoft/clrmd/pull/30#discussion_r43560316"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/clrmd/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/clrmd/pulls/30","id":49310327,"html_url":"https://github.com/Microsoft/clrmd/pull/30","diff_url":"https://github.com/Microsoft/clrmd/pull/30.diff","patch_url":"https://github.com/Microsoft/clrmd/pull/30.patch","issue_url":"https://api.github.com/repos/Microsoft/clrmd/issues/30","number":30,"state":"open","locked":false,"title":"Implement an object model for ClrMD","user":{"login":"leculver","id":8496639,"avatar_url":"https://avatars.githubusercontent.com/u/8496639?v=3","gravatar_id":"","url":"https://api.github.com/users/leculver","html_url":"https://github.com/leculver","followers_url":"https://api.github.com/users/leculver/followers","following_url":"https://api.github.com/users/leculver/following{/other_user}","gists_url":"https://api.github.com/users/leculver/gists{/gist_id}","starred_url":"https://api.github.com/users/leculver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leculver/subscriptions","organizations_url":"https://api.github.com/users/leculver/orgs","repos_url":"https://api.github.com/users/leculver/repos","events_url":"https://api.github.com/users/leculver/events{/privacy}","received_events_url":"https://api.github.com/users/leculver/received_events","type":"User","site_admin":false},"body":"This change implements an object model for ClrMD.  Additionally we now support enumerating arguments and local variables for v4 runtimes and beyond.","created_at":"2015-10-30T19:08:12Z","updated_at":"2015-10-30T22:50:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c461a60af0396d56acaf9129168ec3fd1b0bce0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/clrmd/pulls/30/commits","review_comments_url":"https://api.github.com/repos/Microsoft/clrmd/pulls/30/comments","review_comment_url":"https://api.github.com/repos/Microsoft/clrmd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/clrmd/issues/30/comments","statuses_url":"https://api.github.com/repos/Microsoft/clrmd/statuses/aeae35b43798030ed636202463fa86a0c27693a2","head":{"label":"Microsoft:clrobject","ref":"clrobject","sha":"aeae35b43798030ed636202463fa86a0c27693a2","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":42606220,"name":"clrmd","full_name":"Microsoft/clrmd","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/clrmd","description":"Microsoft.Diagnostics.Runtime is a set of APIs for introspecting processes and dumps.","fork":false,"url":"https://api.github.com/repos/Microsoft/clrmd","forks_url":"https://api.github.com/repos/Microsoft/clrmd/forks","keys_url":"https://api.github.com/repos/Microsoft/clrmd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/clrmd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/clrmd/teams","hooks_url":"https://api.github.com/repos/Microsoft/clrmd/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/clrmd/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/clrmd/events","assignees_url":"https://api.github.com/repos/Microsoft/clrmd/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/clrmd/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/clrmd/tags","blobs_url":"https://api.github.com/repos/Microsoft/clrmd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/clrmd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/clrmd/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/clrmd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/clrmd/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/clrmd/languages","stargazers_url":"https://api.github.com/repos/Microsoft/clrmd/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/clrmd/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/clrmd/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/clrmd/subscription","commits_url":"https://api.github.com/repos/Microsoft/clrmd/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/clrmd/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/clrmd/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/clrmd/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/clrmd/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/clrmd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/clrmd/merges","archive_url":"https://api.github.com/repos/Microsoft/clrmd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/clrmd/downloads","issues_url":"https://api.github.com/repos/Microsoft/clrmd/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/clrmd/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/clrmd/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/clrmd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/clrmd/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/clrmd/releases{/id}","created_at":"2015-09-16T18:37:49Z","updated_at":"2015-10-25T19:18:55Z","pushed_at":"2015-10-30T19:08:13Z","git_url":"git://github.com/Microsoft/clrmd.git","ssh_url":"git@github.com:Microsoft/clrmd.git","clone_url":"https://github.com/Microsoft/clrmd.git","svn_url":"https://github.com/Microsoft/clrmd","homepage":"https://github.com/Microsoft/clrmd/blob/master/Documentation/ClrRuntime.md","size":2192,"stargazers_count":36,"watchers_count":36,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":9,"forks":10,"open_issues":9,"watchers":36,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"f01df68eb86dc7f530e24afa2b2e36411f19d20d","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":42606220,"name":"clrmd","full_name":"Microsoft/clrmd","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/clrmd","description":"Microsoft.Diagnostics.Runtime is a set of APIs for introspecting processes and dumps.","fork":false,"url":"https://api.github.com/repos/Microsoft/clrmd","forks_url":"https://api.github.com/repos/Microsoft/clrmd/forks","keys_url":"https://api.github.com/repos/Microsoft/clrmd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/clrmd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/clrmd/teams","hooks_url":"https://api.github.com/repos/Microsoft/clrmd/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/clrmd/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/clrmd/events","assignees_url":"https://api.github.com/repos/Microsoft/clrmd/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/clrmd/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/clrmd/tags","blobs_url":"https://api.github.com/repos/Microsoft/clrmd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/clrmd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/clrmd/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/clrmd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/clrmd/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/clrmd/languages","stargazers_url":"https://api.github.com/repos/Microsoft/clrmd/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/clrmd/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/clrmd/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/clrmd/subscription","commits_url":"https://api.github.com/repos/Microsoft/clrmd/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/clrmd/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/clrmd/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/clrmd/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/clrmd/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/clrmd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/clrmd/merges","archive_url":"https://api.github.com/repos/Microsoft/clrmd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/clrmd/downloads","issues_url":"https://api.github.com/repos/Microsoft/clrmd/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/clrmd/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/clrmd/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/clrmd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/clrmd/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/clrmd/releases{/id}","created_at":"2015-09-16T18:37:49Z","updated_at":"2015-10-25T19:18:55Z","pushed_at":"2015-10-30T19:08:13Z","git_url":"git://github.com/Microsoft/clrmd.git","ssh_url":"git@github.com:Microsoft/clrmd.git","clone_url":"https://github.com/Microsoft/clrmd.git","svn_url":"https://github.com/Microsoft/clrmd","homepage":"https://github.com/Microsoft/clrmd/blob/master/Documentation/ClrRuntime.md","size":2192,"stargazers_count":36,"watchers_count":36,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":9,"forks":10,"open_issues":9,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/clrmd/pulls/30"},"html":{"href":"https://github.com/Microsoft/clrmd/pull/30"},"issue":{"href":"https://api.github.com/repos/Microsoft/clrmd/issues/30"},"comments":{"href":"https://api.github.com/repos/Microsoft/clrmd/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/clrmd/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/clrmd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/clrmd/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/clrmd/statuses/aeae35b43798030ed636202463fa86a0c27693a2"}}}}