-
Notifications
You must be signed in to change notification settings - Fork 94
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
BREAKING: Id
field of Location
changed from int
(32bit) to BigInteger
(unlimited)
#2463
Conversation
Id
field of Location
changed from int
(32bit) to BigInteger
(unlimited) [#2463](https://github.com/microsoft/sarif-sdk/pull/2463)
Id
field of Location
changed from int
(32bit) to BigInteger
(unlimited) [#2463](https://github.com/microsoft/sarif-sdk/pull/2463)Id
field of Location
changed from int
(32bit) to BigInteger
(unlimited)
/// </summary> | ||
[DataContract] | ||
[GeneratedCode("Microsoft.Json.Schema.ToDotNet", "1.1.0.0")] | ||
public partial class Location : PropertyBagHolder, ISarifNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public bool ShouldSerializeId() | ||
{ | ||
return Id != -1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is needed because DefaultValue does not work for BigInteger.
then this need 2 things,
- in the constructor to set it, which we already have.
- ShouldSerializeXXX to handle the serialization. #Closed
src/ReleaseHistory.md
Outdated
@@ -11,6 +11,7 @@ | |||
* BUGFIX: Fix `Merge` command produces empty SARIF file in Linux when providing file name only without path. [#2408](https://github.com/microsoft/sarif-sdk/pull/2408) | |||
* BUGFIX: Fix `NullReferenceException` when filing work item with a SARIF file which has no filable results. [#2412](https://github.com/microsoft/sarif-sdk/pull/2412) | |||
* BUGFIX: Fix missing `endLine` and `endColumn` properties and remove vulnerable packages for ESLint SARIF formatter. [#2458](https://github.com/microsoft/sarif-sdk/pull/2458) | |||
* BREAKING: `Id` field of `Location` changed from `int`(32bit) to `BigInteger`(unlimited) [#2463](https://github.com/microsoft/sarif-sdk/pull/2463) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
src/Sarif/Autogenerated/Location.cs
Outdated
|
||
public bool ShouldSerializeId() | ||
{ | ||
return Id != -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unit test for this.
location.Id = int.MaxValue; | ||
AssertShouldSerializeId(location, true); | ||
|
||
location.Id = long.MaxValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AssertShouldSerializeId(location, false); | ||
|
||
location.Id = -1; | ||
AssertShouldSerializeId(location, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add test for long.MinValue - 1
add test for long.MinValue
add test for int.MinValue
add test for -2 #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added all
@@ -85,5 +92,68 @@ public void Location_LogicalLocation_WhenSetToNull_RemovesLogicalLocationsArray( | |||
|
|||
location.LogicalLocations.Should().BeNull(); | |||
} | |||
|
|||
[Fact] | |||
public void Location_SerializeId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to round trip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* BUGFIX: Eliminate dispose of stream and `StreamWriter` arguments passed to `SarifLog.Save` helpers. This would result in `ObjectDisposedException` being raised on attempt to access streams after save. | ||
* BREAKING: `Id` property of `Location` changed from `int`(32bit) to `BigInteger`(unlimited) to fix `Newtonsoft.Json.JsonReaderException: JSON integer XXXXX is too large or small for an Int32.` [#2463](https://github.com/microsoft/sarif-sdk/pull/2463) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the very first part "error ERR999.UnhandledEngineException" which only apply to the SDK validate tool.
the rest error message apply to both SDK validate tool and directly using:
JsonConvert.DeserializeObject<SarifLog>(content)
} | ||
|
||
[Fact] | ||
public void Location_VerifyAbleToDeserializeWithBigIntegerId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"level": "note", | ||
"locations": [ | ||
{ | ||
"id": 31197130097450771296369962162453149327732752356239421572342053257324632475324, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description:
We found that in SARIF spec, there is no definition of the max length of integer type, whether it is 32 bit, 64 bit or no limit.
Our current SDK code assumes 32 bit, which should be wrong assumption, should be no limit since spec does not mention any limit.
Fixes:
Spot fix the
Location.Id
to useBigInteger
which is no limit.Note that we should also change the jschema to use
BigInteger
across the solution. created a issue there:microsoft/jschema#144