-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
2,908 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Note: This comparer may not have all properties compared. Will be replaced by a comprehensive | ||
/// comparer generated by JSchema as part of EqualityComparer in a planned comprehensive solution. | ||
/// Tracking by issue: https://github.com/microsoft/jschema/issues/141 | ||
/// </summary> | ||
namespace Microsoft.CodeAnalysis.Sarif.Comparers | ||
{ | ||
internal class ArtifactComparer : IComparer<Artifact> | ||
{ | ||
internal static readonly ArtifactComparer Instance = new ArtifactComparer(); | ||
|
||
public int Compare(Artifact left, Artifact right) | ||
{ | ||
int compareResult = 0; | ||
|
||
if (left.TryReferenceCompare(right, out compareResult)) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = MessageComparer.Instance.Compare(left.Description, right.Description); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = ArtifactLocationComparer.Instance.Compare(left.Location, right.Location); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.ParentIndex.CompareTo(right.ParentIndex); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.Offset.CompareTo(right.Offset); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.Length.CompareTo(right.Length); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.Roles.CompareTo(right.Roles); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = string.Compare(left.MimeType, right.MimeType); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = ArtifactContentComparer.Instance.Compare(left.Contents, right.Contents); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = string.Compare(left.Encoding, right.Encoding); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = string.Compare(left.SourceLanguage, right.SourceLanguage); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.Hashes.DictionaryCompare(right.Hashes); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.LastModifiedTimeUtc.CompareTo(right.LastModifiedTimeUtc); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
// Note: There may be other properties are not compared. | ||
return compareResult; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Note: This comparer may not have all properties compared. Will be replaced by a comprehensive | ||
/// comparer generated by JSchema as part of EqualityComparer in a planned comprehensive solution. | ||
/// Tracking by issue: https://github.com/microsoft/jschema/issues/141 | ||
/// </summary> | ||
namespace Microsoft.CodeAnalysis.Sarif.Comparers | ||
{ | ||
internal class ArtifactContentComparer : IComparer<ArtifactContent> | ||
{ | ||
internal static readonly ArtifactContentComparer Instance = new ArtifactContentComparer(); | ||
|
||
public int Compare(ArtifactContent left, ArtifactContent right) | ||
{ | ||
int compareResult = 0; | ||
|
||
if (left.TryReferenceCompare(right, out compareResult)) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = string.Compare(left.Text, right.Text); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = string.Compare(left.Binary, right.Binary); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = MultiformatMessageStringComparer.Instance.Compare(left.Rendered, right.Rendered); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
// Note: There may be other properties are not compared. | ||
return compareResult; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Note: This comparer may not have all properties compared. Will be replaced by a comprehensive | ||
/// comparer generated by JSchema as part of EqualityComparer in a planned comprehensive solution. | ||
/// Tracking by issue: https://github.com/microsoft/jschema/issues/141 | ||
/// </summary> | ||
namespace Microsoft.CodeAnalysis.Sarif.Comparers | ||
{ | ||
internal class ArtifactLocationComparer : IComparer<ArtifactLocation> | ||
{ | ||
internal static readonly ArtifactLocationComparer Instance = new ArtifactLocationComparer(); | ||
|
||
public int Compare(ArtifactLocation left, ArtifactLocation right) | ||
{ | ||
int compareResult = 0; | ||
|
||
if (left.TryReferenceCompare(right, out compareResult)) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.Uri.UriCompare(right.Uri); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = string.Compare(left.UriBaseId, right.UriBaseId); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.Index.CompareTo(right.Index); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = MessageComparer.Instance.Compare(left.Description, right.Description); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
// Note: There may be other properties are not compared. | ||
return compareResult; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Note: This comparer may not have all properties compared. Will be replaced by a comprehensive | ||
/// comparer generated by JSchema as part of EqualityComparer in a planned comprehensive solution. | ||
/// Tracking by issue: https://github.com/microsoft/jschema/issues/141 | ||
/// </summary> | ||
namespace Microsoft.CodeAnalysis.Sarif.Comparers | ||
{ | ||
internal class CodeFlowComparer : IComparer<CodeFlow> | ||
{ | ||
internal static readonly CodeFlowComparer Instance = new CodeFlowComparer(); | ||
|
||
public int Compare(CodeFlow left, CodeFlow right) | ||
{ | ||
int compareResult = 0; | ||
|
||
if (left.TryReferenceCompare(right, out compareResult)) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = MessageComparer.Instance.Compare(left.Message, right.Message); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
compareResult = left.ThreadFlows.ListCompare(right.ThreadFlows, ThreadFlowComparer.Instance); | ||
|
||
if (compareResult != 0) | ||
{ | ||
return compareResult; | ||
} | ||
|
||
// Note: There may be other properties are not compared. | ||
return compareResult; | ||
} | ||
} | ||
} |
Oops, something went wrong.