{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/comments/229125092","pull_request_review_id":169550553,"id":229125092,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTEyNTA5Mg==","diff_hunk":"@@ -0,0 +1,293 @@\n+﻿// Copyright (c) Microsoft. All rights reserved.\n+// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Reflection;\n+using Microsoft.CodeAnalysis.Sarif.Readers;\n+using Microsoft.Json.Schema;\n+\n+namespace Microsoft.CodeAnalysis.Sarif\n+{\n+    /// <summary>\n+    /// This visitor will exhaustively populate a SARIF log with default values, starting at \n+    /// whatever level in the tree is visited. This has the effect of comprehehsively \n+    /// 'hydrating' all possible SARIF constructs as defined by the C# OM.\n+    /// </summary>\n+    public class DefaultObjectPopulatingVisitor : SarifRewritingVisitor\n+    {\n+        public delegate object PrimitiveValueBuilder(bool isRequired);\n+\n+        // The default builders create a placeholder value for all required property primitives\n+        // and emits default (null, 0, false, etc.) values for the remainder. As a result, a\n+        // default hydration of this class should contain no non-default values for \n+        // JSON primitive-valued properties that aren't required\n+        public static IDictionary<Type, PrimitiveValueBuilder> PopulateRequiredPrimitives()\n+        {\n+            return new Dictionary<Type, PrimitiveValueBuilder>()\n+            {\n+                { typeof(bool),    (isRequired) => { return isRequired; } },\n+                { typeof(int),     (isRequired) => { return isRequired ? int.MaxValue : 0; } },\n+                { typeof(double),  (isRequired) => { return isRequired ? double.MaxValue : 0; } },\n+                { typeof(string),  (isRequired) => { return isRequired ? \"Required string value.\" : null; } },\n+                { typeof(DateTime),(isRequired) => { return isRequired ? DateTime.UtcNow : new DateTime(); } },\n+                { typeof(Uri),     (isRequired) => { return isRequired ? new Uri(\"https://required.uri.contoso.com\") : null; } }\n+            };\n+        }\n+\n+        // These builders exhaustively populate the generated SARIF file, including non-required JSON primitives\n+        public static IDictionary<Type, PrimitiveValueBuilder> PopulateAllPrimitives()\n+        {\n+            // The values in this output are designed to allow conformance to the schema. In our schema,.\n+            // for example, some integer values must be > 0. And so, out optional integer value is \n+            // written as 1.\n+            return new Dictionary<Type, PrimitiveValueBuilder>()\n+            {\n+                { typeof(bool),    (isRequired) => { return true; } },\n+                { typeof(int),     (isRequired) => { return isRequired ? int.MaxValue : 1; } },\n+                { typeof(double),  (isRequired) => { return isRequired ? double.MaxValue : 1; } },\n+                { typeof(string),  (isRequired) => { return isRequired ? \"[Required string value]\" : \"[Optional string value]\"; } },\n+                { typeof(DateTime),(isRequired) => { return isRequired ? DateTime.UtcNow : new DateTime(1776, 7, 4).ToUniversalTime(); } },","path":"src/Sarif.ValidationTests/DefaultObjectPopulatingVisitor.cs","position":50,"original_position":50,"commit_id":"b471ebdd145ba0f4c0eb27a88b205e11a1c1bc29","original_commit_id":"c0c26a5b06d28851ef5c318fa969a5afb46c6fcc","user":{"login":"lgolding","id":11762653,"node_id":"MDQ6VXNlcjExNzYyNjUz","avatar_url":"https://avatars0.githubusercontent.com/u/11762653?v=4","gravatar_id":"","url":"https://api.github.com/users/lgolding","html_url":"https://github.com/lgolding","followers_url":"https://api.github.com/users/lgolding/followers","following_url":"https://api.github.com/users/lgolding/following{/other_user}","gists_url":"https://api.github.com/users/lgolding/gists{/gist_id}","starred_url":"https://api.github.com/users/lgolding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lgolding/subscriptions","organizations_url":"https://api.github.com/users/lgolding/orgs","repos_url":"https://api.github.com/users/lgolding/repos","events_url":"https://api.github.com/users/lgolding/events{/privacy}","received_events_url":"https://api.github.com/users/lgolding/received_events","type":"User","site_admin":false},"body":"This is not fixed in Iteration 3 (the latest iteration I have). Do you have more changes to push?\r\n\r\n---\r\nIn reply to: [229106315](https://github.com/Microsoft/sarif-sdk/pull/1121#discussion_r229106315) [](ancestors = 229106315)","created_at":"2018-10-29T22:47:00Z","updated_at":"2018-10-29T22:47:00Z","html_url":"https://github.com/Microsoft/sarif-sdk/pull/1121#discussion_r229125092","pull_request_url":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/1121","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/comments/229125092"},"html":{"href":"https://github.com/Microsoft/sarif-sdk/pull/1121#discussion_r229125092"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/1121"}},"in_reply_to_id":229106315},"pull_request":{"url":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/1121","id":226623843,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2NjIzODQz","html_url":"https://github.com/Microsoft/sarif-sdk/pull/1121","diff_url":"https://github.com/Microsoft/sarif-sdk/pull/1121.diff","patch_url":"https://github.com/Microsoft/sarif-sdk/pull/1121.patch","issue_url":"https://api.github.com/repos/Microsoft/sarif-sdk/issues/1121","number":1121,"state":"open","locked":false,"title":"Work to enable better serialization behaviors for empty arrays. Various schema fixes.","user":{"login":"michaelcfanning","id":13526455,"node_id":"MDQ6VXNlcjEzNTI2NDU1","avatar_url":"https://avatars3.githubusercontent.com/u/13526455?v=4","gravatar_id":"","url":"https://api.github.com/users/michaelcfanning","html_url":"https://github.com/michaelcfanning","followers_url":"https://api.github.com/users/michaelcfanning/followers","following_url":"https://api.github.com/users/michaelcfanning/following{/other_user}","gists_url":"https://api.github.com/users/michaelcfanning/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelcfanning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelcfanning/subscriptions","organizations_url":"https://api.github.com/users/michaelcfanning/orgs","repos_url":"https://api.github.com/users/michaelcfanning/repos","events_url":"https://api.github.com/users/michaelcfanning/events{/privacy}","received_events_url":"https://api.github.com/users/michaelcfanning/received_events","type":"User","site_admin":false},"body":"This PR has three substantive changes:\r\n\r\n1) Adds some test infrastructure that creates test content exhaustively directly from the object model.\r\n2) Fixes two types in schema that did not include a property bag (revealed by test data above)\r\n3) Provides better serialization behavior, whereby non-populated collections are not persisted to JSON. Without this functionality, it is easier for users to create JSON that doesn't actually validate. Ideally, default serialization would not put users in this condition.\r\n\r\n@lgolding @rtaket ","created_at":"2018-10-29T16:16:48Z","updated_at":"2018-10-29T22:47:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e973f299355ae65b8b047cad2e3cccce5316b9b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/1121/commits","review_comments_url":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/1121/comments","review_comment_url":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/sarif-sdk/issues/1121/comments","statuses_url":"https://api.github.com/repos/Microsoft/sarif-sdk/statuses/b471ebdd145ba0f4c0eb27a88b205e11a1c1bc29","head":{"label":"Microsoft:empty-arrays","ref":"empty-arrays","sha":"b471ebdd145ba0f4c0eb27a88b205e11a1c1bc29","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","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":45640472,"node_id":"MDEwOlJlcG9zaXRvcnk0NTY0MDQ3Mg==","name":"sarif-sdk","full_name":"Microsoft/sarif-sdk","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","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},"html_url":"https://github.com/Microsoft/sarif-sdk","description":".NET code and supporting files for working with the 'Static Analysis Results Interchange Format' (SARIF, see https://github.com/sarif-standard/sarif-spec)","fork":false,"url":"https://api.github.com/repos/Microsoft/sarif-sdk","forks_url":"https://api.github.com/repos/Microsoft/sarif-sdk/forks","keys_url":"https://api.github.com/repos/Microsoft/sarif-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/sarif-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/sarif-sdk/teams","hooks_url":"https://api.github.com/repos/Microsoft/sarif-sdk/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/sarif-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/sarif-sdk/events","assignees_url":"https://api.github.com/repos/Microsoft/sarif-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/sarif-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/sarif-sdk/tags","blobs_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/sarif-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/sarif-sdk/languages","stargazers_url":"https://api.github.com/repos/Microsoft/sarif-sdk/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/sarif-sdk/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/sarif-sdk/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/sarif-sdk/subscription","commits_url":"https://api.github.com/repos/Microsoft/sarif-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/sarif-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/sarif-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/sarif-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/sarif-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/sarif-sdk/merges","archive_url":"https://api.github.com/repos/Microsoft/sarif-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/sarif-sdk/downloads","issues_url":"https://api.github.com/repos/Microsoft/sarif-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/sarif-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/sarif-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/sarif-sdk/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/sarif-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/sarif-sdk/deployments","created_at":"2015-11-05T21:26:46Z","updated_at":"2018-10-29T20:50:11Z","pushed_at":"2018-10-29T21:35:16Z","git_url":"git://github.com/Microsoft/sarif-sdk.git","ssh_url":"git@github.com:Microsoft/sarif-sdk.git","clone_url":"https://github.com/Microsoft/sarif-sdk.git","svn_url":"https://github.com/Microsoft/sarif-sdk","homepage":"","size":83519,"stargazers_count":30,"watchers_count":30,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"archived":false,"open_issues_count":154,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":25,"open_issues":154,"watchers":30,"default_branch":"develop"}},"base":{"label":"Microsoft:develop","ref":"develop","sha":"13895e1e66aab87a64d43540ef9727257ed6ed52","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","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":45640472,"node_id":"MDEwOlJlcG9zaXRvcnk0NTY0MDQ3Mg==","name":"sarif-sdk","full_name":"Microsoft/sarif-sdk","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","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},"html_url":"https://github.com/Microsoft/sarif-sdk","description":".NET code and supporting files for working with the 'Static Analysis Results Interchange Format' (SARIF, see https://github.com/sarif-standard/sarif-spec)","fork":false,"url":"https://api.github.com/repos/Microsoft/sarif-sdk","forks_url":"https://api.github.com/repos/Microsoft/sarif-sdk/forks","keys_url":"https://api.github.com/repos/Microsoft/sarif-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/sarif-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/sarif-sdk/teams","hooks_url":"https://api.github.com/repos/Microsoft/sarif-sdk/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/sarif-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/sarif-sdk/events","assignees_url":"https://api.github.com/repos/Microsoft/sarif-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/sarif-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/sarif-sdk/tags","blobs_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/sarif-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/sarif-sdk/languages","stargazers_url":"https://api.github.com/repos/Microsoft/sarif-sdk/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/sarif-sdk/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/sarif-sdk/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/sarif-sdk/subscription","commits_url":"https://api.github.com/repos/Microsoft/sarif-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/sarif-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/sarif-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/sarif-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/sarif-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/sarif-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/sarif-sdk/merges","archive_url":"https://api.github.com/repos/Microsoft/sarif-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/sarif-sdk/downloads","issues_url":"https://api.github.com/repos/Microsoft/sarif-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/sarif-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/sarif-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/sarif-sdk/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/sarif-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/sarif-sdk/deployments","created_at":"2015-11-05T21:26:46Z","updated_at":"2018-10-29T20:50:11Z","pushed_at":"2018-10-29T21:35:16Z","git_url":"git://github.com/Microsoft/sarif-sdk.git","ssh_url":"git@github.com:Microsoft/sarif-sdk.git","clone_url":"https://github.com/Microsoft/sarif-sdk.git","svn_url":"https://github.com/Microsoft/sarif-sdk","homepage":"","size":83519,"stargazers_count":30,"watchers_count":30,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"archived":false,"open_issues_count":154,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":25,"open_issues":154,"watchers":30,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/1121"},"html":{"href":"https://github.com/Microsoft/sarif-sdk/pull/1121"},"issue":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/issues/1121"},"comments":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/issues/1121/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/1121/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/pulls/1121/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/sarif-sdk/statuses/b471ebdd145ba0f4c0eb27a88b205e11a1c1bc29"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"lgolding"}}