diff --git a/src/ReleaseHistory.md b/src/ReleaseHistory.md index 1a4ff1683..6399f065c 100644 --- a/src/ReleaseHistory.md +++ b/src/ReleaseHistory.md @@ -220,11 +220,16 @@ * API BREAKING: 'invocation.workingDirectory' is now a FileLocation object (and not a URI expressed as a string) ## **v2.0.0-csd.2.beta.2018.11.28** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/2.0.0-csd.2.beta.2018.11.28) | [Driver](https://www.nuget.org/packages/Sarif.Driver/2.0.0-csd.2.beta.2018.11.28) | [Converters](https://www.nuget.org/packages/Sarif.Converters/2.0.0-csd.2.beta.2018.11.28)) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/2.0.0-csd.2.beta.2018.11.28)) -* BUGFIX: Result matching improvements in properties persistence -* FEATURE: Fortify FPR converter improvements +* BUGFIX: Result matching improvements in properties persistence. +* FEATURE: Fortify FPR converter improvements. +* API Non-BREAKING: Remove uniqueness requirement from 'result.locations'. * API NON-BREAKING: Add 'run.newlineSequences' to schema. https://github.com/oasis-tcs/sarif-spec/issues/169 -* API BREAKING: remove 'run.architecture' https://github.com/oasis-tcs/sarif-spec/issues/262 +* API NON-BREAKING: Add result.rank'. Add 'ruleConfiguration.defaultRank'. +* API BREAKING: Remove 'run.architecture' https://github.com/oasis-tcs/sarif-spec/issues/262 * API BREAKING: 'result.message' is now a required property https://github.com/oasis-tcs/sarif-spec/issues/283 -* API BREAKING: rename 'tool.fileVersion' to 'tool.dottedQuadFileVersion' https://github.com/oasis-tcs/sarif-spec/issues/274 -* API BREAKING: remove 'open' from valid rule default configuration levels. https://github.com/oasis-tcs/sarif-spec/issues/288. The transformer remaps this value to 'note'. -* API BREAKING: 'run.columnKind' default value is now 'unicodeCodePoints'. https://github.com/Microsoft/sarif-sdk/pull/1160. The transformer will inject 'utf16CodeUnits', however, when this property is absent, as this value is a more appropriate default for the Windows platform. \ No newline at end of file +* API BREAKING: Rename 'tool.fileVersion' to 'tool.dottedQuadFileVersion' https://github.com/oasis-tcs/sarif-spec/issues/274 +* API BREAKING: Remove 'open' from valid rule default configuration levels. https://github.com/oasis-tcs/sarif-spec/issues/288. The transformer remaps this value to 'note'. +* API BREAKING: 'run.columnKind' default value is now 'unicodeCodePoints'. https://github.com/Microsoft/sarif-sdk/pull/1160. The transformer will inject 'utf16CodeUnits', however, when this property is absent, as this value is a more appropriate default for the Windows platform. +* API BREAKING: Make 'run.logicalLocations' an array, not a dictionary. Add result.logicalLocationIndex to point to associated logical location. +* API BREAKING: 'run.externalFiles' renamed to 'run.externalPropertyFiles', which is not a bundle of external property file objects. NOTE: no transformation will be provided for legacy versions of the external property files API. +* API BREAKING: rework 'result.provenance' object, including moving result.conversionProvenance to 'result.provenance.conversionSources'. NOTE: no transformation currently exists for this update. \ No newline at end of file diff --git a/src/Sarif/Autogenerated/ExternalPropertyFile.cs b/src/Sarif/Autogenerated/ExternalPropertyFile.cs new file mode 100644 index 000000000..02d483c9b --- /dev/null +++ b/src/Sarif/Autogenerated/ExternalPropertyFile.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft. All Rights Reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Microsoft.CodeAnalysis.Sarif.Readers; + +namespace Microsoft.CodeAnalysis.Sarif +{ + [DataContract] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")] + public partial class ExternalPropertyFile : PropertyBagHolder, ISarifNode + { + public static IEqualityComparer ValueComparer => ExternalPropertyFileEqualityComparer.Instance; + + public bool ValueEquals(ExternalPropertyFile other) => ValueComparer.Equals(this, other); + public int ValueGetHashCode() => ValueComparer.GetHashCode(this); + + /// + /// Gets a value indicating the type of object implementing . + /// + public SarifNodeKind SarifNodeKind + { + get + { + return SarifNodeKind.ExternalPropertyFile; + } + } + + /// + /// The location of the external property file. + /// + [DataMember(Name = "fileLocation", IsRequired = false, EmitDefaultValue = false)] + public FileLocation FileLocation { get; set; } + + /// + /// A stable, unique identifer for the external property file in the form of a GUID. + /// + [DataMember(Name = "instanceGuid", IsRequired = false, EmitDefaultValue = false)] + public string InstanceGuid { get; set; } + + /// + /// A non-negative integer specifying the number of items contained in the external property file. + /// + [DataMember(Name = "itemCount", IsRequired = false, EmitDefaultValue = false)] + public int ItemCount { get; set; } + + /// + /// Key/value pairs that provide additional information about the external property file. + /// + [DataMember(Name = "properties", IsRequired = false, EmitDefaultValue = false)] + internal override IDictionary Properties { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public ExternalPropertyFile() + { + } + + /// + /// Initializes a new instance of the class from the supplied values. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + public ExternalPropertyFile(FileLocation fileLocation, string instanceGuid, int itemCount, IDictionary properties) + { + Init(fileLocation, instanceGuid, itemCount, properties); + } + + /// + /// Initializes a new instance of the class from the specified instance. + /// + /// + /// The instance from which the new instance is to be initialized. + /// + /// + /// Thrown if is null. + /// + public ExternalPropertyFile(ExternalPropertyFile other) + { + if (other == null) + { + throw new ArgumentNullException(nameof(other)); + } + + Init(other.FileLocation, other.InstanceGuid, other.ItemCount, other.Properties); + } + + ISarifNode ISarifNode.DeepClone() + { + return DeepCloneCore(); + } + + /// + /// Creates a deep copy of this instance. + /// + public ExternalPropertyFile DeepClone() + { + return (ExternalPropertyFile)DeepCloneCore(); + } + + private ISarifNode DeepCloneCore() + { + return new ExternalPropertyFile(this); + } + + private void Init(FileLocation fileLocation, string instanceGuid, int itemCount, IDictionary properties) + { + if (fileLocation != null) + { + FileLocation = new FileLocation(fileLocation); + } + + InstanceGuid = instanceGuid; + ItemCount = itemCount; + if (properties != null) + { + Properties = new Dictionary(properties); + } + } + } +} \ No newline at end of file diff --git a/src/Sarif/Autogenerated/ExternalPropertyFileEqualityComparer.cs b/src/Sarif/Autogenerated/ExternalPropertyFileEqualityComparer.cs new file mode 100644 index 000000000..de4612ba1 --- /dev/null +++ b/src/Sarif/Autogenerated/ExternalPropertyFileEqualityComparer.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft. All Rights Reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using Microsoft.CodeAnalysis.Sarif.Readers; + +namespace Microsoft.CodeAnalysis.Sarif +{ + /// + /// Defines methods to support the comparison of objects of type ExternalPropertyFile for equality. + /// + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")] + internal sealed class ExternalPropertyFileEqualityComparer : IEqualityComparer + { + internal static readonly ExternalPropertyFileEqualityComparer Instance = new ExternalPropertyFileEqualityComparer(); + + public bool Equals(ExternalPropertyFile left, ExternalPropertyFile right) + { + if (ReferenceEquals(left, right)) + { + return true; + } + + if (ReferenceEquals(left, null) || ReferenceEquals(right, null)) + { + return false; + } + + if (!FileLocation.ValueComparer.Equals(left.FileLocation, right.FileLocation)) + { + return false; + } + + if (left.InstanceGuid != right.InstanceGuid) + { + return false; + } + + if (left.ItemCount != right.ItemCount) + { + return false; + } + + if (!object.ReferenceEquals(left.Properties, right.Properties)) + { + if (left.Properties == null || right.Properties == null || left.Properties.Count != right.Properties.Count) + { + return false; + } + + foreach (var value_0 in left.Properties) + { + SerializedPropertyInfo value_1; + if (!right.Properties.TryGetValue(value_0.Key, out value_1)) + { + return false; + } + + if (!object.Equals(value_0.Value, value_1)) + { + return false; + } + } + } + + return true; + } + + public int GetHashCode(ExternalPropertyFile obj) + { + if (ReferenceEquals(obj, null)) + { + return 0; + } + + int result = 17; + unchecked + { + if (obj.FileLocation != null) + { + result = (result * 31) + obj.FileLocation.ValueGetHashCode(); + } + + if (obj.InstanceGuid != null) + { + result = (result * 31) + obj.InstanceGuid.GetHashCode(); + } + + result = (result * 31) + obj.ItemCount.GetHashCode(); + if (obj.Properties != null) + { + // Use xor for dictionaries to be order-independent. + int xor_0 = 0; + foreach (var value_2 in obj.Properties) + { + xor_0 ^= value_2.Key.GetHashCode(); + if (value_2.Value != null) + { + xor_0 ^= value_2.Value.GetHashCode(); + } + } + + result = (result * 31) + xor_0; + } + } + + return result; + } + } +} \ No newline at end of file diff --git a/src/Sarif/Autogenerated/ExternalFiles.cs b/src/Sarif/Autogenerated/ExternalPropertyFiles.cs similarity index 50% rename from src/Sarif/Autogenerated/ExternalFiles.cs rename to src/Sarif/Autogenerated/ExternalPropertyFiles.cs index a4534fc64..58793faf5 100644 --- a/src/Sarif/Autogenerated/ExternalFiles.cs +++ b/src/Sarif/Autogenerated/ExternalPropertyFiles.cs @@ -5,20 +5,19 @@ using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; -using Microsoft.CodeAnalysis.Sarif.Readers; namespace Microsoft.CodeAnalysis.Sarif { /// - /// References to external files that should be inlined with the content of a root log file. + /// References to external property files that should be inlined with the content of a root log file. /// [DataContract] [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")] - public partial class ExternalFiles : PropertyBagHolder, ISarifNode + public partial class ExternalPropertyFiles : ISarifNode { - public static IEqualityComparer ValueComparer => ExternalFilesEqualityComparer.Instance; + public static IEqualityComparer ValueComparer => ExternalPropertyFilesEqualityComparer.Instance; - public bool ValueEquals(ExternalFiles other) => ValueComparer.Equals(this, other); + public bool ValueEquals(ExternalPropertyFiles other) => ValueComparer.Equals(this, other); public int ValueGetHashCode() => ValueComparer.GetHashCode(this); /// @@ -28,99 +27,99 @@ public SarifNodeKind SarifNodeKind { get { - return SarifNodeKind.ExternalFiles; + return SarifNodeKind.ExternalPropertyFiles; } } /// - /// The location of a file containing a run.conversion object to be merged with the root log file. + /// An external property file containing a run.conversion object to be merged with the root log file. /// [DataMember(Name = "conversion", IsRequired = false, EmitDefaultValue = false)] - public FileLocation Conversion { get; set; } + public ExternalPropertyFile Conversion { get; set; } /// - /// The location of a file containing a run.files object to be merged with the root log file. + /// An external property file containing a run.graphs object to be merged with the root log file. /// - [DataMember(Name = "files", IsRequired = false, EmitDefaultValue = false)] - public FileLocation Files { get; set; } + [DataMember(Name = "graphs", IsRequired = false, EmitDefaultValue = false)] + public ExternalPropertyFile Graphs { get; set; } /// - /// The location of a file containing a run.graphs object to be merged with the root log file. + /// An external property file containing a run.resources object to be merged with the root log file. /// - [DataMember(Name = "graphs", IsRequired = false, EmitDefaultValue = false)] - public FileLocation Graphs { get; set; } + [DataMember(Name = "resources", IsRequired = false, EmitDefaultValue = false)] + public ExternalPropertyFile Resources { get; set; } /// - /// An array of locations of files containing arrays of run.invocation objects to be merged with the root log file. + /// An external property file containing a run.properties object to be merged with the root log file. /// - [DataMember(Name = "invocations", IsRequired = false, EmitDefaultValue = false)] - public IList Invocations { get; set; } + [DataMember(Name = "properties", IsRequired = false, EmitDefaultValue = false)] + public ExternalPropertyFile Properties { get; set; } /// - /// The location of a file containing a run.logicalLocations object to be merged with the root log file. + /// An array of external property files containing run.files arrays to be merged with the root log file. /// - [DataMember(Name = "logicalLocations", IsRequired = false, EmitDefaultValue = false)] - public FileLocation LogicalLocations { get; set; } + [DataMember(Name = "files", IsRequired = false, EmitDefaultValue = false)] + public IList Files { get; set; } /// - /// The location of a file containing a run.resources object to be merged with the root log file. + /// An array of external property files containing run.invocations arrays to be merged with the root log file. /// - [DataMember(Name = "resources", IsRequired = false, EmitDefaultValue = false)] - public FileLocation Resources { get; set; } + [DataMember(Name = "invocations", IsRequired = false, EmitDefaultValue = false)] + public IList Invocations { get; set; } /// - /// An array of locations of files containins arrays of run.result objects to be merged with the root log file. + /// An array of external property files containing run.logicalLocations arrays to be merged with the root log file. /// - [DataMember(Name = "results", IsRequired = false, EmitDefaultValue = false)] - public IList Results { get; set; } + [DataMember(Name = "logicalLocations", IsRequired = false, EmitDefaultValue = false)] + public IList LogicalLocations { get; set; } /// - /// Key/value pairs that provide additional information about the external files. + /// An array of external property files containing run.results arrays to be merged with the root log file. /// - [DataMember(Name = "properties", IsRequired = false, EmitDefaultValue = false)] - internal override IDictionary Properties { get; set; } + [DataMember(Name = "results", IsRequired = false, EmitDefaultValue = false)] + public IList Results { get; set; } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public ExternalFiles() + public ExternalPropertyFiles() { } /// - /// Initializes a new instance of the class from the supplied values. + /// Initializes a new instance of the class from the supplied values. /// /// /// An initialization value for the property. /// - /// - /// An initialization value for the property. - /// /// /// An initialization value for the property. /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// /// /// An initialization value for the property. /// /// /// An initialization value for the property. /// - /// - /// An initialization value for the property. - /// /// /// An initialization value for the property. /// - /// - /// An initialization value for the property. - /// - public ExternalFiles(FileLocation conversion, FileLocation files, FileLocation graphs, IEnumerable invocations, FileLocation logicalLocations, FileLocation resources, IEnumerable results, IDictionary properties) + public ExternalPropertyFiles(ExternalPropertyFile conversion, ExternalPropertyFile graphs, ExternalPropertyFile resources, ExternalPropertyFile properties, IEnumerable files, IEnumerable invocations, IEnumerable logicalLocations, IEnumerable results) { - Init(conversion, files, graphs, invocations, logicalLocations, resources, results, properties); + Init(conversion, graphs, resources, properties, files, invocations, logicalLocations, results); } /// - /// Initializes a new instance of the class from the specified instance. + /// Initializes a new instance of the class from the specified instance. /// /// /// The instance from which the new instance is to be initialized. @@ -128,14 +127,14 @@ public ExternalFiles(FileLocation conversion, FileLocation files, FileLocation g /// /// Thrown if is null. /// - public ExternalFiles(ExternalFiles other) + public ExternalPropertyFiles(ExternalPropertyFiles other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } - Init(other.Conversion, other.Files, other.Graphs, other.Invocations, other.LogicalLocations, other.Resources, other.Results, other.Properties); + Init(other.Conversion, other.Graphs, other.Resources, other.Properties, other.Files, other.Invocations, other.LogicalLocations, other.Results); } ISarifNode ISarifNode.DeepClone() @@ -146,37 +145,42 @@ ISarifNode ISarifNode.DeepClone() /// /// Creates a deep copy of this instance. /// - public ExternalFiles DeepClone() + public ExternalPropertyFiles DeepClone() { - return (ExternalFiles)DeepCloneCore(); + return (ExternalPropertyFiles)DeepCloneCore(); } private ISarifNode DeepCloneCore() { - return new ExternalFiles(this); + return new ExternalPropertyFiles(this); } - private void Init(FileLocation conversion, FileLocation files, FileLocation graphs, IEnumerable invocations, FileLocation logicalLocations, FileLocation resources, IEnumerable results, IDictionary properties) + private void Init(ExternalPropertyFile conversion, ExternalPropertyFile graphs, ExternalPropertyFile resources, ExternalPropertyFile properties, IEnumerable files, IEnumerable invocations, IEnumerable logicalLocations, IEnumerable results) { if (conversion != null) { - Conversion = new FileLocation(conversion); + Conversion = new ExternalPropertyFile(conversion); } - if (files != null) + if (graphs != null) { - Files = new FileLocation(files); + Graphs = new ExternalPropertyFile(graphs); } - if (graphs != null) + if (resources != null) { - Graphs = new FileLocation(graphs); + Resources = new ExternalPropertyFile(resources); } - if (invocations != null) + if (properties != null) { - var destination_0 = new List(); - foreach (var value_0 in invocations) + Properties = new ExternalPropertyFile(properties); + } + + if (files != null) + { + var destination_0 = new List(); + foreach (var value_0 in files) { if (value_0 == null) { @@ -184,44 +188,65 @@ private void Init(FileLocation conversion, FileLocation files, FileLocation grap } else { - destination_0.Add(new FileLocation(value_0)); + destination_0.Add(new ExternalPropertyFile(value_0)); } } - Invocations = destination_0; + Files = destination_0; } - if (logicalLocations != null) + if (invocations != null) { - LogicalLocations = new FileLocation(logicalLocations); - } + var destination_1 = new List(); + foreach (var value_1 in invocations) + { + if (value_1 == null) + { + destination_1.Add(null); + } + else + { + destination_1.Add(new ExternalPropertyFile(value_1)); + } + } - if (resources != null) - { - Resources = new FileLocation(resources); + Invocations = destination_1; } - if (results != null) + if (logicalLocations != null) { - var destination_1 = new List(); - foreach (var value_1 in results) + var destination_2 = new List(); + foreach (var value_2 in logicalLocations) { - if (value_1 == null) + if (value_2 == null) { - destination_1.Add(null); + destination_2.Add(null); } else { - destination_1.Add(new FileLocation(value_1)); + destination_2.Add(new ExternalPropertyFile(value_2)); } } - Results = destination_1; + LogicalLocations = destination_2; } - if (properties != null) + if (results != null) { - Properties = new Dictionary(properties); + var destination_3 = new List(); + foreach (var value_3 in results) + { + if (value_3 == null) + { + destination_3.Add(null); + } + else + { + destination_3.Add(new ExternalPropertyFile(value_3)); + } + } + + Results = destination_3; } } } diff --git a/src/Sarif/Autogenerated/ExternalFilesEqualityComparer.cs b/src/Sarif/Autogenerated/ExternalPropertyFilesEqualityComparer.cs similarity index 57% rename from src/Sarif/Autogenerated/ExternalFilesEqualityComparer.cs rename to src/Sarif/Autogenerated/ExternalPropertyFilesEqualityComparer.cs index 1bdf8a4e3..345bb11ea 100644 --- a/src/Sarif/Autogenerated/ExternalFilesEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ExternalPropertyFilesEqualityComparer.cs @@ -4,19 +4,18 @@ using System; using System.CodeDom.Compiler; using System.Collections.Generic; -using Microsoft.CodeAnalysis.Sarif.Readers; namespace Microsoft.CodeAnalysis.Sarif { /// - /// Defines methods to support the comparison of objects of type ExternalFiles for equality. + /// Defines methods to support the comparison of objects of type ExternalPropertyFiles for equality. /// [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")] - internal sealed class ExternalFilesEqualityComparer : IEqualityComparer + internal sealed class ExternalPropertyFilesEqualityComparer : IEqualityComparer { - internal static readonly ExternalFilesEqualityComparer Instance = new ExternalFilesEqualityComparer(); + internal static readonly ExternalPropertyFilesEqualityComparer Instance = new ExternalPropertyFilesEqualityComparer(); - public bool Equals(ExternalFiles left, ExternalFiles right) + public bool Equals(ExternalPropertyFiles left, ExternalPropertyFiles right) { if (ReferenceEquals(left, right)) { @@ -28,89 +27,104 @@ public bool Equals(ExternalFiles left, ExternalFiles right) return false; } - if (!FileLocation.ValueComparer.Equals(left.Conversion, right.Conversion)) + if (!ExternalPropertyFile.ValueComparer.Equals(left.Conversion, right.Conversion)) { return false; } - if (!FileLocation.ValueComparer.Equals(left.Files, right.Files)) + if (!ExternalPropertyFile.ValueComparer.Equals(left.Graphs, right.Graphs)) { return false; } - if (!FileLocation.ValueComparer.Equals(left.Graphs, right.Graphs)) + if (!ExternalPropertyFile.ValueComparer.Equals(left.Resources, right.Resources)) { return false; } - if (!object.ReferenceEquals(left.Invocations, right.Invocations)) + if (!ExternalPropertyFile.ValueComparer.Equals(left.Properties, right.Properties)) { - if (left.Invocations == null || right.Invocations == null) + return false; + } + + if (!object.ReferenceEquals(left.Files, right.Files)) + { + if (left.Files == null || right.Files == null) { return false; } - if (left.Invocations.Count != right.Invocations.Count) + if (left.Files.Count != right.Files.Count) { return false; } - for (int index_0 = 0; index_0 < left.Invocations.Count; ++index_0) + for (int index_0 = 0; index_0 < left.Files.Count; ++index_0) { - if (!FileLocation.ValueComparer.Equals(left.Invocations[index_0], right.Invocations[index_0])) + if (!ExternalPropertyFile.ValueComparer.Equals(left.Files[index_0], right.Files[index_0])) { return false; } } } - if (!FileLocation.ValueComparer.Equals(left.LogicalLocations, right.LogicalLocations)) + if (!object.ReferenceEquals(left.Invocations, right.Invocations)) { - return false; - } + if (left.Invocations == null || right.Invocations == null) + { + return false; + } - if (!FileLocation.ValueComparer.Equals(left.Resources, right.Resources)) - { - return false; + if (left.Invocations.Count != right.Invocations.Count) + { + return false; + } + + for (int index_1 = 0; index_1 < left.Invocations.Count; ++index_1) + { + if (!ExternalPropertyFile.ValueComparer.Equals(left.Invocations[index_1], right.Invocations[index_1])) + { + return false; + } + } } - if (!object.ReferenceEquals(left.Results, right.Results)) + if (!object.ReferenceEquals(left.LogicalLocations, right.LogicalLocations)) { - if (left.Results == null || right.Results == null) + if (left.LogicalLocations == null || right.LogicalLocations == null) { return false; } - if (left.Results.Count != right.Results.Count) + if (left.LogicalLocations.Count != right.LogicalLocations.Count) { return false; } - for (int index_1 = 0; index_1 < left.Results.Count; ++index_1) + for (int index_2 = 0; index_2 < left.LogicalLocations.Count; ++index_2) { - if (!FileLocation.ValueComparer.Equals(left.Results[index_1], right.Results[index_1])) + if (!ExternalPropertyFile.ValueComparer.Equals(left.LogicalLocations[index_2], right.LogicalLocations[index_2])) { return false; } } } - if (!object.ReferenceEquals(left.Properties, right.Properties)) + if (!object.ReferenceEquals(left.Results, right.Results)) { - if (left.Properties == null || right.Properties == null || left.Properties.Count != right.Properties.Count) + if (left.Results == null || right.Results == null) { return false; } - foreach (var value_0 in left.Properties) + if (left.Results.Count != right.Results.Count) { - SerializedPropertyInfo value_1; - if (!right.Properties.TryGetValue(value_0.Key, out value_1)) - { - return false; - } + return false; + } - if (!object.Equals(value_0.Value, value_1)) + for (int index_3 = 0; index_3 < left.Results.Count; ++index_3) + { + if (!ExternalPropertyFile.ValueComparer.Equals(left.Results[index_3], right.Results[index_3])) { return false; } @@ -120,7 +134,7 @@ public bool Equals(ExternalFiles left, ExternalFiles right) return true; } - public int GetHashCode(ExternalFiles obj) + public int GetHashCode(ExternalPropertyFiles obj) { if (ReferenceEquals(obj, null)) { @@ -135,64 +149,67 @@ public int GetHashCode(ExternalFiles obj) result = (result * 31) + obj.Conversion.ValueGetHashCode(); } - if (obj.Files != null) + if (obj.Graphs != null) { - result = (result * 31) + obj.Files.ValueGetHashCode(); + result = (result * 31) + obj.Graphs.ValueGetHashCode(); } - if (obj.Graphs != null) + if (obj.Resources != null) { - result = (result * 31) + obj.Graphs.ValueGetHashCode(); + result = (result * 31) + obj.Resources.ValueGetHashCode(); } - if (obj.Invocations != null) + if (obj.Properties != null) + { + result = (result * 31) + obj.Properties.ValueGetHashCode(); + } + + if (obj.Files != null) { - foreach (var value_2 in obj.Invocations) + foreach (var value_0 in obj.Files) { result = result * 31; - if (value_2 != null) + if (value_0 != null) { - result = (result * 31) + value_2.ValueGetHashCode(); + result = (result * 31) + value_0.ValueGetHashCode(); } } } - if (obj.LogicalLocations != null) - { - result = (result * 31) + obj.LogicalLocations.ValueGetHashCode(); - } - - if (obj.Resources != null) + if (obj.Invocations != null) { - result = (result * 31) + obj.Resources.ValueGetHashCode(); + foreach (var value_1 in obj.Invocations) + { + result = result * 31; + if (value_1 != null) + { + result = (result * 31) + value_1.ValueGetHashCode(); + } + } } - if (obj.Results != null) + if (obj.LogicalLocations != null) { - foreach (var value_3 in obj.Results) + foreach (var value_2 in obj.LogicalLocations) { result = result * 31; - if (value_3 != null) + if (value_2 != null) { - result = (result * 31) + value_3.ValueGetHashCode(); + result = (result * 31) + value_2.ValueGetHashCode(); } } } - if (obj.Properties != null) + if (obj.Results != null) { - // Use xor for dictionaries to be order-independent. - int xor_0 = 0; - foreach (var value_4 in obj.Properties) + foreach (var value_3 in obj.Results) { - xor_0 ^= value_4.Key.GetHashCode(); - if (value_4.Value != null) + result = result * 31; + if (value_3 != null) { - xor_0 ^= value_4.Value.GetHashCode(); + result = (result * 31) + value_3.ValueGetHashCode(); } } - - result = (result * 31) + xor_0; } } diff --git a/src/Sarif/Autogenerated/Run.cs b/src/Sarif/Autogenerated/Run.cs index 2f59c30a9..b4aabdf0a 100644 --- a/src/Sarif/Autogenerated/Run.cs +++ b/src/Sarif/Autogenerated/Run.cs @@ -142,6 +142,12 @@ public SarifNodeKind SarifNodeKind [JsonConverter(typeof(EnumConverter))] public ColumnKind ColumnKind { get; set; } + /// + /// References to external property files that should be inlined with the content of a root log file. + /// + [DataMember(Name = "externalPropertyFiles", IsRequired = false, EmitDefaultValue = false)] + public ExternalPropertyFiles ExternalPropertyFiles { get; set; } + /// /// Key/value pairs that provide additional information about the run. /// @@ -212,12 +218,15 @@ public Run() /// /// An initialization value for the property. /// + /// + /// An initialization value for the property. + /// /// /// An initialization value for the property. /// - public Run(Tool tool, IEnumerable invocations, Conversion conversion, IEnumerable versionControlProvenance, IDictionary originalUriBaseIds, IDictionary files, IEnumerable logicalLocations, IDictionary graphs, IEnumerable results, Resources resources, RunAutomationDetails id, IEnumerable aggregateIds, string baselineInstanceGuid, string richMessageMimeType, string redactionToken, string defaultFileEncoding, IEnumerable newlineSequences, ColumnKind columnKind, IDictionary properties) + public Run(Tool tool, IEnumerable invocations, Conversion conversion, IEnumerable versionControlProvenance, IDictionary originalUriBaseIds, IDictionary files, IEnumerable logicalLocations, IDictionary graphs, IEnumerable results, Resources resources, RunAutomationDetails id, IEnumerable aggregateIds, string baselineInstanceGuid, string richMessageMimeType, string redactionToken, string defaultFileEncoding, IEnumerable newlineSequences, ColumnKind columnKind, ExternalPropertyFiles externalPropertyFiles, IDictionary properties) { - Init(tool, invocations, conversion, versionControlProvenance, originalUriBaseIds, files, logicalLocations, graphs, results, resources, id, aggregateIds, baselineInstanceGuid, richMessageMimeType, redactionToken, defaultFileEncoding, newlineSequences, columnKind, properties); + Init(tool, invocations, conversion, versionControlProvenance, originalUriBaseIds, files, logicalLocations, graphs, results, resources, id, aggregateIds, baselineInstanceGuid, richMessageMimeType, redactionToken, defaultFileEncoding, newlineSequences, columnKind, externalPropertyFiles, properties); } /// @@ -236,7 +245,7 @@ public Run(Run other) throw new ArgumentNullException(nameof(other)); } - Init(other.Tool, other.Invocations, other.Conversion, other.VersionControlProvenance, other.OriginalUriBaseIds, other.Files, other.LogicalLocations, other.Graphs, other.Results, other.Resources, other.Id, other.AggregateIds, other.BaselineInstanceGuid, other.RichMessageMimeType, other.RedactionToken, other.DefaultFileEncoding, other.NewlineSequences, other.ColumnKind, other.Properties); + Init(other.Tool, other.Invocations, other.Conversion, other.VersionControlProvenance, other.OriginalUriBaseIds, other.Files, other.LogicalLocations, other.Graphs, other.Results, other.Resources, other.Id, other.AggregateIds, other.BaselineInstanceGuid, other.RichMessageMimeType, other.RedactionToken, other.DefaultFileEncoding, other.NewlineSequences, other.ColumnKind, other.ExternalPropertyFiles, other.Properties); } ISarifNode ISarifNode.DeepClone() @@ -257,7 +266,7 @@ private ISarifNode DeepCloneCore() return new Run(this); } - private void Init(Tool tool, IEnumerable invocations, Conversion conversion, IEnumerable versionControlProvenance, IDictionary originalUriBaseIds, IDictionary files, IEnumerable logicalLocations, IDictionary graphs, IEnumerable results, Resources resources, RunAutomationDetails id, IEnumerable aggregateIds, string baselineInstanceGuid, string richMessageMimeType, string redactionToken, string defaultFileEncoding, IEnumerable newlineSequences, ColumnKind columnKind, IDictionary properties) + private void Init(Tool tool, IEnumerable invocations, Conversion conversion, IEnumerable versionControlProvenance, IDictionary originalUriBaseIds, IDictionary files, IEnumerable logicalLocations, IDictionary graphs, IEnumerable results, Resources resources, RunAutomationDetails id, IEnumerable aggregateIds, string baselineInstanceGuid, string richMessageMimeType, string redactionToken, string defaultFileEncoding, IEnumerable newlineSequences, ColumnKind columnKind, ExternalPropertyFiles externalPropertyFiles, IDictionary properties) { if (tool != null) { @@ -412,6 +421,11 @@ private void Init(Tool tool, IEnumerable invocations, Conversion con } ColumnKind = columnKind; + if (externalPropertyFiles != null) + { + ExternalPropertyFiles = new ExternalPropertyFiles(externalPropertyFiles); + } + if (properties != null) { Properties = new Dictionary(properties); diff --git a/src/Sarif/Autogenerated/RunEqualityComparer.cs b/src/Sarif/Autogenerated/RunEqualityComparer.cs index 0b4963d1c..9939d27c6 100644 --- a/src/Sarif/Autogenerated/RunEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RunEqualityComparer.cs @@ -265,6 +265,11 @@ public bool Equals(Run left, Run right) return false; } + if (!ExternalPropertyFiles.ValueComparer.Equals(left.ExternalPropertyFiles, right.ExternalPropertyFiles)) + { + return false; + } + if (!object.ReferenceEquals(left.Properties, right.Properties)) { if (left.Properties == null || right.Properties == null || left.Properties.Count != right.Properties.Count) @@ -461,6 +466,11 @@ public int GetHashCode(Run obj) } result = (result * 31) + obj.ColumnKind.GetHashCode(); + if (obj.ExternalPropertyFiles != null) + { + result = (result * 31) + obj.ExternalPropertyFiles.ValueGetHashCode(); + } + if (obj.Properties != null) { // Use xor for dictionaries to be order-independent. diff --git a/src/Sarif/Autogenerated/SarifNodeKind.cs b/src/Sarif/Autogenerated/SarifNodeKind.cs index 12adfd879..c331ace09 100644 --- a/src/Sarif/Autogenerated/SarifNodeKind.cs +++ b/src/Sarif/Autogenerated/SarifNodeKind.cs @@ -44,9 +44,13 @@ public enum SarifNodeKind /// ExceptionData, /// - /// A value indicating that the object is of type . + /// A value indicating that the object is of type . /// - ExternalFiles, + ExternalPropertyFile, + /// + /// A value indicating that the object is of type . + /// + ExternalPropertyFiles, /// /// A value indicating that the object is of type . /// diff --git a/src/Sarif/Autogenerated/SarifRewritingVisitor.cs b/src/Sarif/Autogenerated/SarifRewritingVisitor.cs index f609dadb5..851bdd0d4 100644 --- a/src/Sarif/Autogenerated/SarifRewritingVisitor.cs +++ b/src/Sarif/Autogenerated/SarifRewritingVisitor.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Rewriting visitor for the Sarif object model. /// [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")] - public abstract class SarifRewritingVisitor + public abstract partial class SarifRewritingVisitor { /// /// Starts a rewriting visit of a node in the Sarif object model. @@ -58,8 +58,10 @@ public virtual object VisitActual(ISarifNode node) return VisitEdgeTraversal((EdgeTraversal)node); case SarifNodeKind.ExceptionData: return VisitExceptionData((ExceptionData)node); - case SarifNodeKind.ExternalFiles: - return VisitExternalFiles((ExternalFiles)node); + case SarifNodeKind.ExternalPropertyFile: + return VisitExternalPropertyFile((ExternalPropertyFile)node); + case SarifNodeKind.ExternalPropertyFiles: + return VisitExternalPropertyFiles((ExternalPropertyFiles)node); case SarifNodeKind.FileChange: return VisitFileChange((FileChange)node); case SarifNodeKind.FileContent: @@ -135,50 +137,6 @@ private T VisitNullChecked(T node) where T : class, ISarifNode return VisitNullChecked(node, ref emptyKey); } - private T VisitNullChecked(T node, ref string key) where T : class, ISarifNode - { - if (node == null) - { - return null; - } - - if (key == null) - { - return (T)Visit(node); - } - - return (T)VisitDictionaryEntry(node, ref key); - } - - private ISarifNode VisitDictionaryEntry(ISarifNode node, ref string key) - { - if (node == null) - { - throw new ArgumentNullException(nameof(key)); - } - - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - switch (node.SarifNodeKind) - { - case SarifNodeKind.FileData: - return VisitFileDataDictionaryEntry((FileData)node, ref key); - - // add other dictionary things - - default: - throw new InvalidOperationException(); // whoops! unknown type - } - } - - public virtual FileData VisitFileDataDictionaryEntry(FileData node, ref string key) - { - return (FileData)Visit(node); - } - public virtual Attachment VisitAttachment(Attachment node) { if (node != null) @@ -278,13 +236,31 @@ public virtual ExceptionData VisitExceptionData(ExceptionData node) return node; } - public virtual ExternalFiles VisitExternalFiles(ExternalFiles node) + public virtual ExternalPropertyFile VisitExternalPropertyFile(ExternalPropertyFile node) + { + if (node != null) + { + node.FileLocation = VisitNullChecked(node.FileLocation); + } + + return node; + } + + public virtual ExternalPropertyFiles VisitExternalPropertyFiles(ExternalPropertyFiles node) { if (node != null) { node.Conversion = VisitNullChecked(node.Conversion); - node.Files = VisitNullChecked(node.Files); node.Graphs = VisitNullChecked(node.Graphs); + node.Resources = VisitNullChecked(node.Resources); + if (node.Files != null) + { + for (int index_0 = 0; index_0 < node.Files.Count; ++index_0) + { + node.Files[index_0] = VisitNullChecked(node.Files[index_0]); + } + } + if (node.Invocations != null) { for (int index_0 = 0; index_0 < node.Invocations.Count; ++index_0) @@ -293,8 +269,14 @@ public virtual ExternalFiles VisitExternalFiles(ExternalFiles node) } } - node.LogicalLocations = VisitNullChecked(node.LogicalLocations); - node.Resources = VisitNullChecked(node.Resources); + if (node.LogicalLocations != null) + { + for (int index_0 = 0; index_0 < node.LogicalLocations.Count; ++index_0) + { + node.LogicalLocations[index_0] = VisitNullChecked(node.LogicalLocations[index_0]); + } + } + if (node.Results != null) { for (int index_0 = 0; index_0 < node.Results.Count; ++index_0) @@ -578,28 +560,6 @@ public virtual Replacement VisitReplacement(Replacement node) return node; } - public virtual Resources VisitResources(Resources node) - { - if (node != null) - { - if (node.Rules != null) - { - var keys = node.Rules.Keys.ToArray(); - foreach (var key in keys) - { - var value = node.Rules[key]; - - if (value != null) - { - node.Rules[key] = VisitNullChecked(value); - } - } - } - } - - return node; - } - public virtual Result VisitResult(Result node) { if (node != null) @@ -762,14 +722,14 @@ public virtual Run VisitRun(Run node) var value = node.Files[key]; if (value != null) { - string newKey = key; - node.Files.Remove(key); - value = VisitNullChecked(value, ref newKey); - - if (newKey != null) - { - node.Files[newKey] = value; - } + string newKey = key; + node.Files.Remove(key); + value = VisitNullChecked(value, ref newKey); + + if (newKey != null) + { + node.Files[newKey] = value; + } } } } @@ -804,7 +764,6 @@ public virtual Run VisitRun(Run node) } node.Resources = VisitNullChecked(node.Resources); - node.Id = VisitNullChecked(node.Id); if (node.AggregateIds != null) { @@ -813,6 +772,8 @@ public virtual Run VisitRun(Run node) node.AggregateIds[index_0] = VisitNullChecked(node.AggregateIds[index_0]); } } + + node.ExternalPropertyFiles = VisitNullChecked(node.ExternalPropertyFiles); } return node; @@ -828,7 +789,6 @@ public virtual RunAutomationDetails VisitRunAutomationDetails(RunAutomationDetai return node; } - public virtual SarifLog VisitSarifLog(SarifLog node) { if (node != null) diff --git a/src/Sarif/CodeGenHints.json b/src/Sarif/CodeGenHints.json index e53f12279..acc15c3ff 100644 --- a/src/Sarif/CodeGenHints.json +++ b/src/Sarif/CodeGenHints.json @@ -93,7 +93,7 @@ } } ], - "externalFiles": [ + "externalPropertyFile": [ { "kind": "BaseTypeHint", "arguments": { diff --git a/src/Sarif/Core/SarifRewritingVisitor.cs b/src/Sarif/Core/SarifRewritingVisitor.cs new file mode 100644 index 000000000..0c022a0ae --- /dev/null +++ b/src/Sarif/Core/SarifRewritingVisitor.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft. All Rights Reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Linq; + +namespace Microsoft.CodeAnalysis.Sarif +{ + /// + /// Rewriting visitor for the Sarif object model. + /// + public abstract partial class SarifRewritingVisitor + { + // NOTE: this partial class is intended to alleviate some manual work that repeatedly needs to + // be done when updating the schema (as our current code emit doesn't handle all + // constructs required by this class. At some point, either the code emit will be + // updated or alternately we will have eliminated the need to visit dictionaries in + // the format, and this partial class can be deleted again. + private T VisitNullChecked(T node, ref string key) where T : class, ISarifNode + { + if (node == null) + { + return null; + } + + if (key == null) + { + return (T)Visit(node); + } + + return (T)VisitDictionaryEntry(node, ref key); + } + + private ISarifNode VisitDictionaryEntry(ISarifNode node, ref string key) + { + if (node == null) + { + throw new ArgumentNullException(nameof(key)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + switch (node.SarifNodeKind) + { + case SarifNodeKind.FileData: + return VisitFileDataDictionaryEntry((FileData)node, ref key); + + // add other dictionary things + + default: + throw new InvalidOperationException(); // whoops! unknown type + } + } + + public virtual FileData VisitFileDataDictionaryEntry(FileData node, ref string key) + { + return (FileData)Visit(node); + } + + public virtual Resources VisitResources(Resources node) + { + if (node != null) + { + if (node.Rules != null) + { + var keys = node.Rules.Keys.ToArray(); + foreach (var key in keys) + { + var value = node.Rules[key]; + + if (value != null) + { + node.Rules[key] = VisitNullChecked(value); + } + } + } + } + + return node; + } + } +} diff --git a/src/Sarif/NotYetAutoGenerated/ExternalPropertyFiles.cs b/src/Sarif/NotYetAutoGenerated/ExternalPropertyFiles.cs new file mode 100644 index 000000000..58793faf5 --- /dev/null +++ b/src/Sarif/NotYetAutoGenerated/ExternalPropertyFiles.cs @@ -0,0 +1,253 @@ +// Copyright (c) Microsoft. All Rights Reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace Microsoft.CodeAnalysis.Sarif +{ + /// + /// References to external property files that should be inlined with the content of a root log file. + /// + [DataContract] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")] + public partial class ExternalPropertyFiles : ISarifNode + { + public static IEqualityComparer ValueComparer => ExternalPropertyFilesEqualityComparer.Instance; + + public bool ValueEquals(ExternalPropertyFiles other) => ValueComparer.Equals(this, other); + public int ValueGetHashCode() => ValueComparer.GetHashCode(this); + + /// + /// Gets a value indicating the type of object implementing . + /// + public SarifNodeKind SarifNodeKind + { + get + { + return SarifNodeKind.ExternalPropertyFiles; + } + } + + /// + /// An external property file containing a run.conversion object to be merged with the root log file. + /// + [DataMember(Name = "conversion", IsRequired = false, EmitDefaultValue = false)] + public ExternalPropertyFile Conversion { get; set; } + + /// + /// An external property file containing a run.graphs object to be merged with the root log file. + /// + [DataMember(Name = "graphs", IsRequired = false, EmitDefaultValue = false)] + public ExternalPropertyFile Graphs { get; set; } + + /// + /// An external property file containing a run.resources object to be merged with the root log file. + /// + [DataMember(Name = "resources", IsRequired = false, EmitDefaultValue = false)] + public ExternalPropertyFile Resources { get; set; } + + /// + /// An external property file containing a run.properties object to be merged with the root log file. + /// + [DataMember(Name = "properties", IsRequired = false, EmitDefaultValue = false)] + public ExternalPropertyFile Properties { get; set; } + + /// + /// An array of external property files containing run.files arrays to be merged with the root log file. + /// + [DataMember(Name = "files", IsRequired = false, EmitDefaultValue = false)] + public IList Files { get; set; } + + /// + /// An array of external property files containing run.invocations arrays to be merged with the root log file. + /// + [DataMember(Name = "invocations", IsRequired = false, EmitDefaultValue = false)] + public IList Invocations { get; set; } + + /// + /// An array of external property files containing run.logicalLocations arrays to be merged with the root log file. + /// + [DataMember(Name = "logicalLocations", IsRequired = false, EmitDefaultValue = false)] + public IList LogicalLocations { get; set; } + + /// + /// An array of external property files containing run.results arrays to be merged with the root log file. + /// + [DataMember(Name = "results", IsRequired = false, EmitDefaultValue = false)] + public IList Results { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public ExternalPropertyFiles() + { + } + + /// + /// Initializes a new instance of the class from the supplied values. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + /// + /// An initialization value for the property. + /// + public ExternalPropertyFiles(ExternalPropertyFile conversion, ExternalPropertyFile graphs, ExternalPropertyFile resources, ExternalPropertyFile properties, IEnumerable files, IEnumerable invocations, IEnumerable logicalLocations, IEnumerable results) + { + Init(conversion, graphs, resources, properties, files, invocations, logicalLocations, results); + } + + /// + /// Initializes a new instance of the class from the specified instance. + /// + /// + /// The instance from which the new instance is to be initialized. + /// + /// + /// Thrown if is null. + /// + public ExternalPropertyFiles(ExternalPropertyFiles other) + { + if (other == null) + { + throw new ArgumentNullException(nameof(other)); + } + + Init(other.Conversion, other.Graphs, other.Resources, other.Properties, other.Files, other.Invocations, other.LogicalLocations, other.Results); + } + + ISarifNode ISarifNode.DeepClone() + { + return DeepCloneCore(); + } + + /// + /// Creates a deep copy of this instance. + /// + public ExternalPropertyFiles DeepClone() + { + return (ExternalPropertyFiles)DeepCloneCore(); + } + + private ISarifNode DeepCloneCore() + { + return new ExternalPropertyFiles(this); + } + + private void Init(ExternalPropertyFile conversion, ExternalPropertyFile graphs, ExternalPropertyFile resources, ExternalPropertyFile properties, IEnumerable files, IEnumerable invocations, IEnumerable logicalLocations, IEnumerable results) + { + if (conversion != null) + { + Conversion = new ExternalPropertyFile(conversion); + } + + if (graphs != null) + { + Graphs = new ExternalPropertyFile(graphs); + } + + if (resources != null) + { + Resources = new ExternalPropertyFile(resources); + } + + if (properties != null) + { + Properties = new ExternalPropertyFile(properties); + } + + if (files != null) + { + var destination_0 = new List(); + foreach (var value_0 in files) + { + if (value_0 == null) + { + destination_0.Add(null); + } + else + { + destination_0.Add(new ExternalPropertyFile(value_0)); + } + } + + Files = destination_0; + } + + if (invocations != null) + { + var destination_1 = new List(); + foreach (var value_1 in invocations) + { + if (value_1 == null) + { + destination_1.Add(null); + } + else + { + destination_1.Add(new ExternalPropertyFile(value_1)); + } + } + + Invocations = destination_1; + } + + if (logicalLocations != null) + { + var destination_2 = new List(); + foreach (var value_2 in logicalLocations) + { + if (value_2 == null) + { + destination_2.Add(null); + } + else + { + destination_2.Add(new ExternalPropertyFile(value_2)); + } + } + + LogicalLocations = destination_2; + } + + if (results != null) + { + var destination_3 = new List(); + foreach (var value_3 in results) + { + if (value_3 == null) + { + destination_3.Add(null); + } + else + { + destination_3.Add(new ExternalPropertyFile(value_3)); + } + } + + Results = destination_3; + } + } + } +} \ No newline at end of file diff --git a/src/Sarif/NotYetAutoGenerated/ExternalPropertyFilesEqualityComparer.cs b/src/Sarif/NotYetAutoGenerated/ExternalPropertyFilesEqualityComparer.cs new file mode 100644 index 000000000..345bb11ea --- /dev/null +++ b/src/Sarif/NotYetAutoGenerated/ExternalPropertyFilesEqualityComparer.cs @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft. All Rights Reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; + +namespace Microsoft.CodeAnalysis.Sarif +{ + /// + /// Defines methods to support the comparison of objects of type ExternalPropertyFiles for equality. + /// + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")] + internal sealed class ExternalPropertyFilesEqualityComparer : IEqualityComparer + { + internal static readonly ExternalPropertyFilesEqualityComparer Instance = new ExternalPropertyFilesEqualityComparer(); + + public bool Equals(ExternalPropertyFiles left, ExternalPropertyFiles right) + { + if (ReferenceEquals(left, right)) + { + return true; + } + + if (ReferenceEquals(left, null) || ReferenceEquals(right, null)) + { + return false; + } + + if (!ExternalPropertyFile.ValueComparer.Equals(left.Conversion, right.Conversion)) + { + return false; + } + + if (!ExternalPropertyFile.ValueComparer.Equals(left.Graphs, right.Graphs)) + { + return false; + } + + if (!ExternalPropertyFile.ValueComparer.Equals(left.Resources, right.Resources)) + { + return false; + } + + if (!ExternalPropertyFile.ValueComparer.Equals(left.Properties, right.Properties)) + { + return false; + } + + if (!object.ReferenceEquals(left.Files, right.Files)) + { + if (left.Files == null || right.Files == null) + { + return false; + } + + if (left.Files.Count != right.Files.Count) + { + return false; + } + + for (int index_0 = 0; index_0 < left.Files.Count; ++index_0) + { + if (!ExternalPropertyFile.ValueComparer.Equals(left.Files[index_0], right.Files[index_0])) + { + return false; + } + } + } + + if (!object.ReferenceEquals(left.Invocations, right.Invocations)) + { + if (left.Invocations == null || right.Invocations == null) + { + return false; + } + + if (left.Invocations.Count != right.Invocations.Count) + { + return false; + } + + for (int index_1 = 0; index_1 < left.Invocations.Count; ++index_1) + { + if (!ExternalPropertyFile.ValueComparer.Equals(left.Invocations[index_1], right.Invocations[index_1])) + { + return false; + } + } + } + + if (!object.ReferenceEquals(left.LogicalLocations, right.LogicalLocations)) + { + if (left.LogicalLocations == null || right.LogicalLocations == null) + { + return false; + } + + if (left.LogicalLocations.Count != right.LogicalLocations.Count) + { + return false; + } + + for (int index_2 = 0; index_2 < left.LogicalLocations.Count; ++index_2) + { + if (!ExternalPropertyFile.ValueComparer.Equals(left.LogicalLocations[index_2], right.LogicalLocations[index_2])) + { + return false; + } + } + } + + if (!object.ReferenceEquals(left.Results, right.Results)) + { + if (left.Results == null || right.Results == null) + { + return false; + } + + if (left.Results.Count != right.Results.Count) + { + return false; + } + + for (int index_3 = 0; index_3 < left.Results.Count; ++index_3) + { + if (!ExternalPropertyFile.ValueComparer.Equals(left.Results[index_3], right.Results[index_3])) + { + return false; + } + } + } + + return true; + } + + public int GetHashCode(ExternalPropertyFiles obj) + { + if (ReferenceEquals(obj, null)) + { + return 0; + } + + int result = 17; + unchecked + { + if (obj.Conversion != null) + { + result = (result * 31) + obj.Conversion.ValueGetHashCode(); + } + + if (obj.Graphs != null) + { + result = (result * 31) + obj.Graphs.ValueGetHashCode(); + } + + if (obj.Resources != null) + { + result = (result * 31) + obj.Resources.ValueGetHashCode(); + } + + if (obj.Properties != null) + { + result = (result * 31) + obj.Properties.ValueGetHashCode(); + } + + if (obj.Files != null) + { + foreach (var value_0 in obj.Files) + { + result = result * 31; + if (value_0 != null) + { + result = (result * 31) + value_0.ValueGetHashCode(); + } + } + } + + if (obj.Invocations != null) + { + foreach (var value_1 in obj.Invocations) + { + result = result * 31; + if (value_1 != null) + { + result = (result * 31) + value_1.ValueGetHashCode(); + } + } + } + + if (obj.LogicalLocations != null) + { + foreach (var value_2 in obj.LogicalLocations) + { + result = result * 31; + if (value_2 != null) + { + result = (result * 31) + value_2.ValueGetHashCode(); + } + } + } + + if (obj.Results != null) + { + foreach (var value_3 in obj.Results) + { + result = result * 31; + if (value_3 != null) + { + result = (result * 31) + value_3.ValueGetHashCode(); + } + } + } + } + + return result; + } + } +} \ No newline at end of file diff --git a/src/Sarif/NotYetAutoGenerated/SarifRewritingVisitor.cs b/src/Sarif/NotYetAutoGenerated/SarifRewritingVisitor.cs index f609dadb5..851bdd0d4 100644 --- a/src/Sarif/NotYetAutoGenerated/SarifRewritingVisitor.cs +++ b/src/Sarif/NotYetAutoGenerated/SarifRewritingVisitor.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Rewriting visitor for the Sarif object model. /// [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")] - public abstract class SarifRewritingVisitor + public abstract partial class SarifRewritingVisitor { /// /// Starts a rewriting visit of a node in the Sarif object model. @@ -58,8 +58,10 @@ public virtual object VisitActual(ISarifNode node) return VisitEdgeTraversal((EdgeTraversal)node); case SarifNodeKind.ExceptionData: return VisitExceptionData((ExceptionData)node); - case SarifNodeKind.ExternalFiles: - return VisitExternalFiles((ExternalFiles)node); + case SarifNodeKind.ExternalPropertyFile: + return VisitExternalPropertyFile((ExternalPropertyFile)node); + case SarifNodeKind.ExternalPropertyFiles: + return VisitExternalPropertyFiles((ExternalPropertyFiles)node); case SarifNodeKind.FileChange: return VisitFileChange((FileChange)node); case SarifNodeKind.FileContent: @@ -135,50 +137,6 @@ private T VisitNullChecked(T node) where T : class, ISarifNode return VisitNullChecked(node, ref emptyKey); } - private T VisitNullChecked(T node, ref string key) where T : class, ISarifNode - { - if (node == null) - { - return null; - } - - if (key == null) - { - return (T)Visit(node); - } - - return (T)VisitDictionaryEntry(node, ref key); - } - - private ISarifNode VisitDictionaryEntry(ISarifNode node, ref string key) - { - if (node == null) - { - throw new ArgumentNullException(nameof(key)); - } - - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - switch (node.SarifNodeKind) - { - case SarifNodeKind.FileData: - return VisitFileDataDictionaryEntry((FileData)node, ref key); - - // add other dictionary things - - default: - throw new InvalidOperationException(); // whoops! unknown type - } - } - - public virtual FileData VisitFileDataDictionaryEntry(FileData node, ref string key) - { - return (FileData)Visit(node); - } - public virtual Attachment VisitAttachment(Attachment node) { if (node != null) @@ -278,13 +236,31 @@ public virtual ExceptionData VisitExceptionData(ExceptionData node) return node; } - public virtual ExternalFiles VisitExternalFiles(ExternalFiles node) + public virtual ExternalPropertyFile VisitExternalPropertyFile(ExternalPropertyFile node) + { + if (node != null) + { + node.FileLocation = VisitNullChecked(node.FileLocation); + } + + return node; + } + + public virtual ExternalPropertyFiles VisitExternalPropertyFiles(ExternalPropertyFiles node) { if (node != null) { node.Conversion = VisitNullChecked(node.Conversion); - node.Files = VisitNullChecked(node.Files); node.Graphs = VisitNullChecked(node.Graphs); + node.Resources = VisitNullChecked(node.Resources); + if (node.Files != null) + { + for (int index_0 = 0; index_0 < node.Files.Count; ++index_0) + { + node.Files[index_0] = VisitNullChecked(node.Files[index_0]); + } + } + if (node.Invocations != null) { for (int index_0 = 0; index_0 < node.Invocations.Count; ++index_0) @@ -293,8 +269,14 @@ public virtual ExternalFiles VisitExternalFiles(ExternalFiles node) } } - node.LogicalLocations = VisitNullChecked(node.LogicalLocations); - node.Resources = VisitNullChecked(node.Resources); + if (node.LogicalLocations != null) + { + for (int index_0 = 0; index_0 < node.LogicalLocations.Count; ++index_0) + { + node.LogicalLocations[index_0] = VisitNullChecked(node.LogicalLocations[index_0]); + } + } + if (node.Results != null) { for (int index_0 = 0; index_0 < node.Results.Count; ++index_0) @@ -578,28 +560,6 @@ public virtual Replacement VisitReplacement(Replacement node) return node; } - public virtual Resources VisitResources(Resources node) - { - if (node != null) - { - if (node.Rules != null) - { - var keys = node.Rules.Keys.ToArray(); - foreach (var key in keys) - { - var value = node.Rules[key]; - - if (value != null) - { - node.Rules[key] = VisitNullChecked(value); - } - } - } - } - - return node; - } - public virtual Result VisitResult(Result node) { if (node != null) @@ -762,14 +722,14 @@ public virtual Run VisitRun(Run node) var value = node.Files[key]; if (value != null) { - string newKey = key; - node.Files.Remove(key); - value = VisitNullChecked(value, ref newKey); - - if (newKey != null) - { - node.Files[newKey] = value; - } + string newKey = key; + node.Files.Remove(key); + value = VisitNullChecked(value, ref newKey); + + if (newKey != null) + { + node.Files[newKey] = value; + } } } } @@ -804,7 +764,6 @@ public virtual Run VisitRun(Run node) } node.Resources = VisitNullChecked(node.Resources); - node.Id = VisitNullChecked(node.Id); if (node.AggregateIds != null) { @@ -813,6 +772,8 @@ public virtual Run VisitRun(Run node) node.AggregateIds[index_0] = VisitNullChecked(node.AggregateIds[index_0]); } } + + node.ExternalPropertyFiles = VisitNullChecked(node.ExternalPropertyFiles); } return node; @@ -828,7 +789,6 @@ public virtual RunAutomationDetails VisitRunAutomationDetails(RunAutomationDetai return node; } - public virtual SarifLog VisitSarifLog(SarifLog node) { if (node != null) diff --git a/src/Sarif/Schemata/sarif-schema.json b/src/Sarif/Schemata/sarif-schema.json index 9f4cc04fd..63bb9f66f 100644 --- a/src/Sarif/Schemata/sarif-schema.json +++ b/src/Sarif/Schemata/sarif-schema.json @@ -254,60 +254,96 @@ } }, - "externalFiles": { - "description": "References to external files that should be inlined with the content of a root log file.", + "externalPropertyFile": { + "type": "object", + "properties": { + "fileLocation": { + "description": "The location of the external property file.", + "$ref": "#/definitions/fileLocation" + }, + + "instanceGuid": { + "description": "A stable, unique identifer for the external property file in the form of a GUID.", + "type": "string" + }, + + "itemCount": { + "description": "A non-negative integer specifying the number of items contained in the external property file.", + "type": "integer", + "minimum": 0 + }, + + "properties": { + "description": "Key/value pairs that provide additional information about the external property file.", + "$ref": "#/definitions/propertyBag" + } + } + }, + + "externalPropertyFiles": { + "description": "References to external property files that should be inlined with the content of a root log file.", "additionalProperties": false, "type": "object", "properties": { "conversion": { - "description": "The location of a file containing a run.conversion object to be merged with the root log file.", - "$ref": "#/definitions/fileLocation" + "description": "An external property file containing a run.conversion object to be merged with the root log file.", + "$ref": "#/definitions/externalPropertyFile" }, - "files": { - "description": "The location of a file containing a run.files object to be merged with the root log file.", - "$ref": "#/definitions/fileLocation" + "graphs": { + "description": "An external property file containing a run.graphs object to be merged with the root log file.", + "$ref": "#/definitions/externalPropertyFile" }, - "graphs": { - "description": "The location of a file containing a run.graphs object to be merged with the root log file.", - "$ref": "#/definitions/fileLocation" + "resources": { + "description": "An external property file containing a run.resources object to be merged with the root log file.", + "$ref": "#/definitions/externalPropertyFile" }, - "invocations": { - "description": "An array of locations of files containing arrays of run.invocation objects to be merged with the root log file.", + "properties": { + "description": "An external property file containing a run.properties object to be merged with the root log file.", + "$ref": "#/definitions/externalPropertyFile" + }, + + "files": { + "description": "An array of external property files containing run.files arrays to be merged with the root log file.", "type": "array", "minItems": 1, "uniqueItems": true, "items": { - "$ref": "#/definitions/fileLocation" + "$ref": "#/definitions/externalPropertyFile" } }, - "logicalLocations": { - "description": "The location of a file containing a run.logicalLocations object to be merged with the root log file.", - "$ref": "#/definitions/fileLocation" + "invocations": { + "description": "An array of external property files containing run.invocations arrays to be merged with the root log file.", + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "$ref": "#/definitions/externalPropertyFile" + } }, - "resources": { - "description": "The location of a file containing a run.resources object to be merged with the root log file.", - "$ref": "#/definitions/fileLocation" + "logicalLocations": { + "description": "An array of external property files containing run.logicalLocations arrays to be merged with the root log file.", + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "$ref": "#/definitions/externalPropertyFile" + } }, "results": { - "description": "An array of locations of files containins arrays of run.result objects to be merged with the root log file.", + "description": "An array of external property files containing run.results arrays to be merged with the root log file.", "type": "array", "minItems": 1, "uniqueItems": true, "items": { - "$ref": "#/definitions/fileLocation" + "$ref": "#/definitions/externalPropertyFile" } - }, - - "properties": { - "description": "Key/value pairs that provide additional information about the external files.", - "$ref": "#/definitions/propertyBag" } } }, @@ -1317,7 +1353,7 @@ "rank": { "description": "A number representing the priority or importance of the result.", - "type":"number", + "type": "number", "minimum": 0.0, "maximum": 100.0, "default": 0.0 @@ -1508,7 +1544,7 @@ "defaultRank": { "description": "Specifies the default priority or importance for results generated by this rule.", - "type":"number", + "type": "number", "minimum": 0.0, "maximum": 100.0, "default": 0.0 @@ -1661,6 +1697,11 @@ "default": "unicodeCodePoints" }, + "externalPropertyFiles": { + "description": "References to external property files that should be inlined with the content of a root log file.", + "$ref": "#/definitions/externalPropertyFiles" + }, + "properties": { "description": "Key/value pairs that provide additional information about the run.", "$ref": "#/definitions/propertyBag" @@ -1670,7 +1711,6 @@ "required": [ "tool" ] }, - "runAutomationDetails": { "description": "Information that describes a run's identity and role within an engineering system process.", "additionalProperties": false,