Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External property files #1194

Merged
merged 9 commits into from
Jan 2, 2019
16 changes: 10 additions & 6 deletions src/ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,15 @@
* 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.
* 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 is provided for legacy versions of the external property files API.
135 changes: 135 additions & 0 deletions src/Sarif/Autogenerated/ExternalPropertyFile.cs
Original file line number Diff line number Diff line change
@@ -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<ExternalPropertyFile> ValueComparer => ExternalPropertyFileEqualityComparer.Instance;

public bool ValueEquals(ExternalPropertyFile other) => ValueComparer.Equals(this, other);
public int ValueGetHashCode() => ValueComparer.GetHashCode(this);

/// <summary>
/// Gets a value indicating the type of object implementing <see cref="ISarifNode" />.
/// </summary>
public SarifNodeKind SarifNodeKind
{
get
{
return SarifNodeKind.ExternalPropertyFile;
}
}

/// <summary>
/// The location of the external property file.
/// </summary>
[DataMember(Name = "fileLocation", IsRequired = false, EmitDefaultValue = false)]
public FileLocation FileLocation { get; set; }

/// <summary>
/// A stable, unique identifer for the external property file in the form of a GUID.
/// </summary>
[DataMember(Name = "instanceGuid", IsRequired = false, EmitDefaultValue = false)]
public string InstanceGuid { get; set; }

/// <summary>
/// A non-negative integer specifying the number of items contained in the external property file.
/// </summary>
[DataMember(Name = "itemCount", IsRequired = false, EmitDefaultValue = false)]
public int ItemCount { get; set; }

/// <summary>
/// Key/value pairs that provide additional information about the external property file.
/// </summary>
[DataMember(Name = "properties", IsRequired = false, EmitDefaultValue = false)]
internal override IDictionary<string, SerializedPropertyInfo> Properties { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="ExternalPropertyFile" /> class.
/// </summary>
public ExternalPropertyFile()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ExternalPropertyFile" /> class from the supplied values.
/// </summary>
/// <param name="fileLocation">
/// An initialization value for the <see cref="P: FileLocation" /> property.
/// </param>
/// <param name="instanceGuid">
/// An initialization value for the <see cref="P: InstanceGuid" /> property.
/// </param>
/// <param name="itemCount">
/// An initialization value for the <see cref="P: ItemCount" /> property.
/// </param>
/// <param name="properties">
/// An initialization value for the <see cref="P: Properties" /> property.
/// </param>
public ExternalPropertyFile(FileLocation fileLocation, string instanceGuid, int itemCount, IDictionary<string, SerializedPropertyInfo> properties)
{
Init(fileLocation, instanceGuid, itemCount, properties);
}

/// <summary>
/// Initializes a new instance of the <see cref="ExternalPropertyFile" /> class from the specified instance.
/// </summary>
/// <param name="other">
/// The instance from which the new instance is to be initialized.
/// </param>
/// <exception cref="ArgumentNullException">
/// Thrown if <paramref name="other" /> is null.
/// </exception>
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();
}

/// <summary>
/// Creates a deep copy of this instance.
/// </summary>
public ExternalPropertyFile DeepClone()
{
return (ExternalPropertyFile)DeepCloneCore();
}

private ISarifNode DeepCloneCore()
{
return new ExternalPropertyFile(this);
}

private void Init(FileLocation fileLocation, string instanceGuid, int itemCount, IDictionary<string, SerializedPropertyInfo> properties)
{
if (fileLocation != null)
{
FileLocation = new FileLocation(fileLocation);
}

InstanceGuid = instanceGuid;
ItemCount = itemCount;
if (properties != null)
{
Properties = new Dictionary<string, SerializedPropertyInfo>(properties);
}
}
}
}
112 changes: 112 additions & 0 deletions src/Sarif/Autogenerated/ExternalPropertyFileEqualityComparer.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Defines methods to support the comparison of objects of type ExternalPropertyFile for equality.
/// </summary>
[GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")]
internal sealed class ExternalPropertyFileEqualityComparer : IEqualityComparer<ExternalPropertyFile>
{
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;
}
}
}
Loading