Skip to content

Commit

Permalink
Fix ArgumentNullException when PropertiesDictionary is used and c…
Browse files Browse the repository at this point in the history
…omparer is null (#2482)

* Defaulting comparer when its null

* Updating condition to work on windows and linux

* Removing converters and library from the change

* Updating to net48

* Updating driver only

* updating release history

* Adding tests

* Updating release history
  • Loading branch information
eddynaka authored Apr 26, 2022
1 parent 503fe29 commit cb83683
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ReleaseHistory.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SARIF Package Release History (SDK, Driver, Converters, and Multitool)

## Unreleased

* BUGFIX: Fix `ArgumentNullException` when `PropertiesDictionary` is instantiated with a null comparer. [#2482](https://github.com/microsoft/sarif-sdk/pull/2482)
* BUGFIX: Fix `UnhandledEngineException` when target path does not exist for multithreaded application by validating directories as is done for singlethreaded analysis. [#2461](https://github.com/microsoft/sarif-sdk/pull/2461)

## **v2.4.14** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/2.4.14) | [Driver](https://www.nuget.org/packages/Sarif.Driver/2.4.14) | [Converters](https://www.nuget.org/packages/Sarif.Converters/2.4.14) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/2.4.14) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/2.4.14)
Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/TypedPropertiesDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public TypedPropertiesDictionary() : this(null, StringComparer.Ordinal)
{
}

public TypedPropertiesDictionary(PropertiesDictionary initializer, IEqualityComparer<string> comparer) : base(comparer)
public TypedPropertiesDictionary(PropertiesDictionary initializer, IEqualityComparer<string> comparer) : base(comparer ?? StringComparer.Ordinal)
{
if (initializer != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net48</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<RootNamespace>Test.UnitTests.Sarif.WorkItems</RootNamespace>
Expand Down
18 changes: 18 additions & 0 deletions src/Test.UnitTests.Sarif/PropertiesDictionaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ public void PropertiesDictionary_TestCacheDescription()
PropertiesDictionary_TestCacheDescription_Helper(GeneratePropertiesDictionaryProperty, PROPERTIES_NONDEFAULT);
}

[Fact]
public void PropertiesDictionary_ShouldNotThrownException_WhenComparerIsNull()
{
var initializer = new PropertiesDictionary();

Exception exception = Record.Exception(() =>
{
new PropertiesDictionary(initializer);
});
exception.Should().BeNull();

exception = Record.Exception(() =>
{
new PropertiesDictionary(initializer, comparer: null);
});
exception.Should().BeNull();
}

private void PropertiesDictionary_TestCacheDescription_Helper(Func<int, string, IOption> GeneratePropertyMethod, object value)
{
string textLoaded = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net48</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
Expand Down

0 comments on commit cb83683

Please sign in to comment.