Skip to content

Commit

Permalink
Rename tool.fileVersion to tool.dottedQuadFileVersion (#1148)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcfanning authored Dec 6, 2018
1 parent 41cd5c4 commit b015513
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,5 @@
* FEATURE: Fortify FPR converter improvements
* 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 BREAKING: result.message is now a required property https://github.com/oasis-tcs/sarif-spec/issues/283
* 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
"copyright": "Copyright (c) 2016 by Example Corporation. All rights reserved."
}
},
"conversion": {
"tool": {
"name": "CodeScanner Legacy File Format Converter",
"fullName": "CodeScanner Converter Tool",
"version": "4.3",
"semanticVersion": "4.3.0",
"fileVersion": "4.3.0.0",
"language": "en-US",
"sarifLoggerVersion": "1.25.0"
}
},
"versionControlProvenance": [
{
"uri": "https://github.com/contoso/example",
Expand Down
13 changes: 12 additions & 1 deletion src/Sarif.FunctionalTests/v2/SpecExamples/Comprehensive.sarif
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@
"fullName": "CodeScanner 1.1 for Unix (en-US)",
"version": "2.1",
"semanticVersion": "2.1.0",
"fileVersion": "2.1.0.0",
"dottedQuadFileVersion": "2.1.0.0",
"language": "en-US",
"sarifLoggerVersion": "1.25.0",
"properties": {
"copyright": "Copyright (c) 2016 by Example Corporation. All rights reserved."
}
},
"conversion": {
"tool": {
"name": "CodeScanner Legacy File Format Converter",
"fullName": "CodeScanner Converter Tool",
"version": "4.3",
"semanticVersion": "4.3.0",
"dottedQuadFileVersion": "4.3.0.0",
"language": "en-US",
"sarifLoggerVersion": "1.25.0"
}
},
"versionControlProvenance": [
{
"uri": "https://github.com/contoso/example",
Expand Down
4 changes: 2 additions & 2 deletions src/Sarif.ValidationTests/SarifValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public void ValidateAllTheThings()
Func<SarifLog, SarifLog> callback =
(sarifLog) =>
{
sarifLog.Runs[0].Tool.FileVersion = "1.0.1.2";
sarifLog.Runs[0].Conversion.Tool.FileVersion = "2.7.1500.12";
sarifLog.Runs[0].Tool.DottedQuadFileVersion = "1.0.1.2";
sarifLog.Runs[0].Conversion.Tool.DottedQuadFileVersion = "2.7.1500.12";
return sarifLog;
};

Expand Down
20 changes: 10 additions & 10 deletions src/Sarif/Autogenerated/Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public SarifNodeKind SarifNodeKind
public string SemanticVersion { get; set; }

/// <summary>
/// The binary version of the tool's primary executable file (for operating systems such as Windows that provide that information).
/// The binary version of the tool's primary executable file expressed as four non-negative integers separated by a period (for operating systems that express file versions in this way).
/// </summary>
[DataMember(Name = "fileVersion", IsRequired = false, EmitDefaultValue = false)]
public string FileVersion { get; set; }
[DataMember(Name = "dottedQuadFileVersion", IsRequired = false, EmitDefaultValue = false)]
public string DottedQuadFileVersion { get; set; }

/// <summary>
/// The absolute URI from which the tool can be downloaded.
Expand Down Expand Up @@ -110,8 +110,8 @@ public Tool()
/// <param name="semanticVersion">
/// An initialization value for the <see cref="P: SemanticVersion" /> property.
/// </param>
/// <param name="fileVersion">
/// An initialization value for the <see cref="P: FileVersion" /> property.
/// <param name="dottedQuadFileVersion">
/// An initialization value for the <see cref="P: DottedQuadFileVersion" /> property.
/// </param>
/// <param name="downloadUri">
/// An initialization value for the <see cref="P: DownloadUri" /> property.
Expand All @@ -125,9 +125,9 @@ public Tool()
/// <param name="properties">
/// An initialization value for the <see cref="P: Properties" /> property.
/// </param>
public Tool(string name, string fullName, string version, string semanticVersion, string fileVersion, Uri downloadUri, string sarifLoggerVersion, string language, IDictionary<string, SerializedPropertyInfo> properties)
public Tool(string name, string fullName, string version, string semanticVersion, string dottedQuadFileVersion, Uri downloadUri, string sarifLoggerVersion, string language, IDictionary<string, SerializedPropertyInfo> properties)
{
Init(name, fullName, version, semanticVersion, fileVersion, downloadUri, sarifLoggerVersion, language, properties);
Init(name, fullName, version, semanticVersion, dottedQuadFileVersion, downloadUri, sarifLoggerVersion, language, properties);
}

/// <summary>
Expand All @@ -146,7 +146,7 @@ public Tool(Tool other)
throw new ArgumentNullException(nameof(other));
}

Init(other.Name, other.FullName, other.Version, other.SemanticVersion, other.FileVersion, other.DownloadUri, other.SarifLoggerVersion, other.Language, other.Properties);
Init(other.Name, other.FullName, other.Version, other.SemanticVersion, other.DottedQuadFileVersion, other.DownloadUri, other.SarifLoggerVersion, other.Language, other.Properties);
}

ISarifNode ISarifNode.DeepClone()
Expand All @@ -167,13 +167,13 @@ private ISarifNode DeepCloneCore()
return new Tool(this);
}

private void Init(string name, string fullName, string version, string semanticVersion, string fileVersion, Uri downloadUri, string sarifLoggerVersion, string language, IDictionary<string, SerializedPropertyInfo> properties)
private void Init(string name, string fullName, string version, string semanticVersion, string dottedQuadFileVersion, Uri downloadUri, string sarifLoggerVersion, string language, IDictionary<string, SerializedPropertyInfo> properties)
{
Name = name;
FullName = fullName;
Version = version;
SemanticVersion = semanticVersion;
FileVersion = fileVersion;
DottedQuadFileVersion = dottedQuadFileVersion;
if (downloadUri != null)
{
DownloadUri = new Uri(downloadUri.OriginalString, downloadUri.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative);
Expand Down
6 changes: 3 additions & 3 deletions src/Sarif/Autogenerated/ToolEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public bool Equals(Tool left, Tool right)
return false;
}

if (left.FileVersion != right.FileVersion)
if (left.DottedQuadFileVersion != right.DottedQuadFileVersion)
{
return false;
}
Expand Down Expand Up @@ -123,9 +123,9 @@ public int GetHashCode(Tool obj)
result = (result * 31) + obj.SemanticVersion.GetHashCode();
}

if (obj.FileVersion != null)
if (obj.DottedQuadFileVersion != null)
{
result = (result * 31) + obj.FileVersion.GetHashCode();
result = (result * 31) + obj.DottedQuadFileVersion.GetHashCode();
}

if (obj.DownloadUri != null)
Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/Core/Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static Tool CreateFromAssemblyData(string prereleaseInfo = null)

if (fileVersion.FileVersion != tool.Version)
{
tool.FileVersion = fileVersion.FileVersion;
tool.DottedQuadFileVersion = fileVersion.FileVersion;
}

tool.FullName = name + " " + tool.Version + (prereleaseInfo ?? "");
Expand Down
4 changes: 2 additions & 2 deletions src/Sarif/Schemata/sarif-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1826,8 +1826,8 @@
"type": "string"
},

"fileVersion": {
"description": "The binary version of the tool's primary executable file (for operating systems such as Windows that provide that information).",
"dottedQuadFileVersion": {
"description": "The binary version of the tool's primary executable file expressed as four non-negative integers separated by a period (for operating systems that express file versions in this way).",
"type": "string",
"pattern": "[0-9]+(\\.[0-9]+){3}"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/Visitors/SarifCurrentToVersionOneVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ internal ToolVersionOne CreateTool(Tool v2Tool)
{
tool = new ToolVersionOne()
{
FileVersion = v2Tool.FileVersion,
FileVersion = v2Tool.DottedQuadFileVersion,
FullName = v2Tool.FullName,
Language = v2Tool.Language,
Name = v2Tool.Name,
Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/Visitors/SarifVersionOneToCurrentVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ internal Tool CreateTool(ToolVersionOne v1Tool)
{
tool = new Tool()
{
FileVersion = v1Tool.FileVersion,
DottedQuadFileVersion = v1Tool.FileVersion,
FullName = v1Tool.FullName,
Language = v1Tool.Language,
Name = v1Tool.Name,
Expand Down
16 changes: 16 additions & 0 deletions src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,23 @@ private static bool ApplyChangesFromTC25ThroughTC28(JObject sarifLog)
{
message = new JObject(new JProperty("text", "[No message provided]."));
result["message"] = message;
modifiedLog = true;
}
}
}

// Rename fileVersion to dottedQuadFileVersion and specify format constraint
// https://github.com/oasis-tcs/sarif-spec/issues/274
//
// Applies to run.tool.fileVersion and run.conversion.tool.fileVersion

modifiedLog |= RenameProperty((JObject)run["tool"], previousName: "fileVersion", newName: "dottedQuadFileVersion");

JObject conversion = (JObject)run["conversion"];
if (conversion != null)
{
modifiedLog |= RenameProperty((JObject)conversion["tool"], previousName: "fileVersion", newName: "dottedQuadFileVersion");
}
}
}

Expand Down Expand Up @@ -449,6 +463,8 @@ internal static bool UpdateRunFiles(JObject run)

private static bool RenameProperty(JObject jObject, string previousName, string newName)
{
if (jObject == null) { return false; }

JToken propertyValue = jObject[previousName];

if (propertyValue != null)
Expand Down

0 comments on commit b015513

Please sign in to comment.