diff --git a/CHANGELOG.md b/CHANGELOG.md index 87fffc67..e65fb07d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.4.2 (25 June 2024) +- [#824](https://github.com/zzzprojects/System.Linq.Dynamic.Core/pull/824) - Fixed: Incorrect Handling of Qualifiers in ConstantExpressionHelper contributed by [RenanCarlosPereira](https://github.com/RenanCarlosPereira) +- [#821](https://github.com/zzzprojects/System.Linq.Dynamic.Core/issues/821) - Incorrect Handling of Qualifiers in ConstantExpressionHelper [bug] + # v1.4.1 (21 June 2024) - [#819](https://github.com/zzzprojects/System.Linq.Dynamic.Core/pull/819) - Update EntityFramework to version 6.5 to fix CVE [feature] contributed by [StefH](https://github.com/StefH) - [#820](https://github.com/zzzprojects/System.Linq.Dynamic.Core/pull/820) - Use Testcontainers.MsSql for unit tests [test] contributed by [StefH](https://github.com/StefH) diff --git a/Generate-ReleaseNotes.bat b/Generate-ReleaseNotes.bat index bbfc4e61..8d90b2bc 100644 --- a/Generate-ReleaseNotes.bat +++ b/Generate-ReleaseNotes.bat @@ -1,5 +1,5 @@ rem https://github.com/StefH/GitHubReleaseNotes -SET version=v1.4.1 +SET version=v1.4.2 GitHubReleaseNotes --output CHANGELOG.md --exclude-labels invalid question documentation wontfix environment --language en --version %version% --token %GH_TOKEN% diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 78974861..2fad1f31 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,6 +1,7 @@ 12 + enable true diff --git a/test/System.Linq.Dynamic.Core.Tests.Net7/System.Linq.Dynamic.Core.Tests.Net7.csproj b/test/System.Linq.Dynamic.Core.Tests.Net7/System.Linq.Dynamic.Core.Tests.Net7.csproj index 4ba004a4..fed1372c 100644 --- a/test/System.Linq.Dynamic.Core.Tests.Net7/System.Linq.Dynamic.Core.Tests.Net7.csproj +++ b/test/System.Linq.Dynamic.Core.Tests.Net7/System.Linq.Dynamic.Core.Tests.Net7.csproj @@ -7,7 +7,6 @@ True ../../src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.snk false - enable $(DefineConstants);NETCOREAPP;EFCORE;EFCORE_3X;NETCOREAPP3_1;AspNetCoreIdentity diff --git a/test/System.Linq.Dynamic.Core.Tests.NetCoreApp31/System.Linq.Dynamic.Core.Tests.NetCoreApp31.csproj b/test/System.Linq.Dynamic.Core.Tests.NetCoreApp31/System.Linq.Dynamic.Core.Tests.NetCoreApp31.csproj index 2a2b4d0c..05c39bbc 100644 --- a/test/System.Linq.Dynamic.Core.Tests.NetCoreApp31/System.Linq.Dynamic.Core.Tests.NetCoreApp31.csproj +++ b/test/System.Linq.Dynamic.Core.Tests.NetCoreApp31/System.Linq.Dynamic.Core.Tests.NetCoreApp31.csproj @@ -5,7 +5,6 @@ System.Linq.Dynamic.Core.Tests full True - enable ../../src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.snk {7AFC2836-0F6E-4B0D-8BB3-13317A3B6616} $(DefineConstants);EFCORE;EFCORE_3X;AspNetCoreIdentity diff --git a/test/System.Linq.Dynamic.Core.Tests/Parser/NumberParserTests.cs b/test/System.Linq.Dynamic.Core.Tests/Parser/NumberParserTests.cs index 0db7404a..e291c34e 100644 --- a/test/System.Linq.Dynamic.Core.Tests/Parser/NumberParserTests.cs +++ b/test/System.Linq.Dynamic.Core.Tests/Parser/NumberParserTests.cs @@ -5,200 +5,195 @@ using System.Linq.Expressions; using Xunit; -namespace System.Linq.Dynamic.Core.Tests.Parser +namespace System.Linq.Dynamic.Core.Tests.Parser; + +public class NumberParserTests { - public class NumberParserTests + private readonly ParsingConfig _parsingConfig = new(); + + public static object?[][] Decimals() { - private readonly ParsingConfig _parsingConfig = new ParsingConfig(); + return + [ + ["de-DE", "1", 1m], + ["de-DE", "-42", -42m], + ["de-DE", "3,215", 3.215m], + ["de-DE", "3.215", 3215m], + + [null, "1", 1m], + [null, "-42", -42m], + [null, "3,215", 3215m], + [null, "3.215", 3.215m] + ]; + } - public static object[][] Decimals() + [Theory] + [MemberData(nameof(Decimals))] + public void NumberParser_ParseNumber_Decimal(string? culture, string text, decimal expected) + { + // Arrange + if (culture != null) { - return new object[][] - { - new object[] {"de-DE", "1", 1m}, - new object[] {"de-DE", "-42", -42m}, - new object[] {"de-DE", "3,215", 3.215m}, - new object[] {"de-DE", "3.215", 3215m}, - - new object[] {null, "1", 1m}, - new object[] {null, "-42", -42m}, - new object[] {null, "3,215", 3215m}, - new object[] {null, "3.215", 3.215m} - }; + _parsingConfig.NumberParseCulture = CultureInfo.CreateSpecificCulture(culture); } - [Theory] - [MemberData(nameof(Decimals))] - public void NumberParser_ParseNumber_Decimal(string culture, string text, decimal expected) - { - // Arrange - if (culture != null) - { - _parsingConfig.NumberParseCulture = CultureInfo.CreateSpecificCulture(culture); - } - - // Act - var result = new NumberParser(_parsingConfig).ParseNumber(text, typeof(decimal)); + // Act + var result = new NumberParser(_parsingConfig).ParseNumber(text, typeof(decimal)); - // Assert - result.Should().Be(expected); - } + // Assert + result.Should().Be(expected); + } - public static object[][] Floats() + public static IEnumerable Floats() + { + return new object?[][] { - return new object[][] - { - new object[] {"de-DE", "1", 1f}, - new object[] {"de-DE", "-42", -42f}, - new object[] {"de-DE", "3,215", 3.215f}, - new object[] {"de-DE", "3.215", 3215f}, - new object[] {"de-DE", "1,2345E-4", 0.00012345f}, - new object[] {"de-DE", "1,2345e-4", 0.00012345f}, - new object[] {"de-DE", "1,2345E4", 12345d}, - new object[] {"de-DE", "1,2345e4", 12345d}, - - new object[] {null, "1", 1f}, - new object[] {null, "-42", -42f}, - new object[] {null, "3,215", 3215f}, - new object[] {null, "3.215", 3.215f}, - new object[] {null, "1.2345E-4", 0.00012345f}, - new object[] {null, "1.2345e-4", 0.00012345f}, - new object[] {null, "1.2345E4", 12345f}, - new object[] {null, "1.2345e4", 12345f} - }; - } + ["de-DE", "1", 1f], + ["de-DE", "-42", -42f], + ["de-DE", "3,215", 3.215f], + ["de-DE", "3.215", 3215f], + ["de-DE", "1,2345E-4", 0.00012345f], + ["de-DE", "1,2345e-4", 0.00012345f], + ["de-DE", "1,2345E4", 12345d], + ["de-DE", "1,2345e4", 12345d], + + [null, "1", 1f], + [null, "-42", -42f], + [null, "3,215", 3215f], + [null, "3.215", 3.215f], + [null, "1.2345E-4", 0.00012345f], + [null, "1.2345e-4", 0.00012345f], + [null, "1.2345E4", 12345f], + [null, "1.2345e4", 12345f] + }; + } - [Theory] - [MemberData(nameof(Floats))] - public void NumberParser_ParseNumber_Float(string culture, string text, float expected) + [Theory] + [MemberData(nameof(Floats))] + public void NumberParser_ParseNumber_Float(string? culture, string text, float expected) + { + // Arrange + if (culture != null) { - // Arrange - if (culture != null) - { - _parsingConfig.NumberParseCulture = CultureInfo.CreateSpecificCulture(culture); - } + _parsingConfig.NumberParseCulture = CultureInfo.CreateSpecificCulture(culture); + } - // Act - var result = new NumberParser(_parsingConfig).ParseNumber(text, typeof(float)); + // Act + var result = new NumberParser(_parsingConfig).ParseNumber(text, typeof(float)); - // Assert - result.Should().Be(expected); - } + // Assert + result.Should().Be(expected); + } - public static IEnumerable Doubles() + public static IEnumerable Doubles() + { + return new object?[][] { - return new object[][] - { - new object[] {"de-DE", "1", 1d}, - new object[] {"de-DE", "-42", -42d}, - new object[] {"de-DE", "3,215", 3.215d}, - new object[] {"de-DE", "3.215", 3215d}, - new object[] {"de-DE", "1,2345E-4", 0.00012345d}, - new object[] {"de-DE", "1,2345e-4", 0.00012345d}, - new object[] {"de-DE", "1,2345E4", 12345d}, - new object[] {"de-DE", "1,2345e4", 12345d}, - - new object[] {null, "1", 1d}, - new object[] {null, "-42", -42d}, - new object[] {null, "3,215", 3215d}, - new object[] {null, "3.215", 3.215d}, - new object[] {null, "1.2345E-4", 0.00012345d}, - new object[] {null, "1.2345e-4", 0.00012345d}, - new object[] {null, "1.2345E4", 12345d}, - new object[] {null, "1.2345e4", 12345d} - }; - } + ["de-DE", "1", 1d], + ["de-DE", "-42", -42d], + ["de-DE", "3,215", 3.215d], + ["de-DE", "3.215", 3215d], + ["de-DE", "1,2345E-4", 0.00012345d], + ["de-DE", "1,2345e-4", 0.00012345d], + ["de-DE", "1,2345E4", 12345d], + ["de-DE", "1,2345e4", 12345d], + + [null, "1", 1d], + [null, "-42", -42d], + [null, "3,215", 3215d], + [null, "3.215", 3.215d], + [null, "1.2345E-4", 0.00012345d], + [null, "1.2345e-4", 0.00012345d], + [null, "1.2345E4", 12345d], + [null, "1.2345e4", 12345d] + }; + } - [Theory] - [MemberData(nameof(Doubles))] - public void NumberParser_ParseNumber_Double(string culture, string text, double expected) + [Theory] + [MemberData(nameof(Doubles))] + public void NumberParser_ParseNumber_Double(string? culture, string text, double expected) + { + // Arrange + if (culture != null) { - // Arrange - if (culture != null) - { - _parsingConfig.NumberParseCulture = CultureInfo.CreateSpecificCulture(culture); - } - - // Act - var result = new NumberParser(_parsingConfig).ParseNumber(text, typeof(double)); - - // Assert - result.Should().Be(expected); + _parsingConfig.NumberParseCulture = CultureInfo.CreateSpecificCulture(culture); } - [Theory] - [InlineData("42", 42)] - [InlineData("-42", -42)] - [InlineData("77u", 77)] - [InlineData("77l", 77)] - [InlineData("77ul", 77)] - [InlineData("0xff", 255)] - [InlineData("-0xff", -255)] - [InlineData("0b1100000011101", 6173)] - [InlineData("-0b1100000011101", -6173)] - [InlineData("123d", 123d)] - [InlineData("123f", 123f)] - [InlineData("123m", 123)] - [InlineData("-123d", -123d)] - [InlineData("-123f", -123f)] - [InlineData("-123m", -123)] - public void NumberParser_ParseIntegerLiteral(string text, double expected) - { - // Arrange + // Act + var result = new NumberParser(_parsingConfig).ParseNumber(text, typeof(double)); - // Act - var result = new NumberParser(_parsingConfig).ParseIntegerLiteral(0, text) as ConstantExpression; + // Assert + result.Should().Be(expected); + } - // Assert - result.Value.Should().Be(expected); - } + [Theory] + [InlineData("42", 42)] + [InlineData("-42", -42)] + [InlineData("77u", 77)] + [InlineData("77l", 77)] + [InlineData("77ul", 77)] + [InlineData("0xff", 255)] + [InlineData("-0xff", -255)] + [InlineData("0b1100000011101", 6173)] + [InlineData("-0b1100000011101", -6173)] + [InlineData("123d", 123d)] + [InlineData("123f", 123f)] + [InlineData("123m", 123)] + [InlineData("-123d", -123d)] + [InlineData("-123f", -123f)] + [InlineData("-123m", -123)] + public void NumberParser_ParseIntegerLiteral(string text, double expected) + { + // Act + var result = new NumberParser(_parsingConfig).ParseIntegerLiteral(0, text) as ConstantExpression; - [Theory] - [InlineData("42", 'm', 42)] - [InlineData("-42", 'm', -42)] - [InlineData("42m", 'm', 42)] - [InlineData("-42m", 'm', -42)] - public void NumberParser_ParseDecimalLiteral(string text, char qualifier, decimal expected) - { - // Arrange + // Assert + result?.Value.Should().Be(expected); + } - // Act - var result = new NumberParser(_parsingConfig).ParseRealLiteral(text, qualifier, true) as ConstantExpression; + [Theory] + [InlineData("42", 'm', 42)] + [InlineData("-42", 'm', -42)] + [InlineData("42m", 'm', 42)] + [InlineData("-42m", 'm', -42)] + public void NumberParser_ParseDecimalLiteral(string text, char qualifier, decimal expected) + { + // Act + var result = new NumberParser(_parsingConfig).ParseRealLiteral(text, qualifier, true) as ConstantExpression; - // Assert - result!.Value.Should().Be(expected); - } + // Assert + result?.Value.Should().Be(expected); + } - [Theory] - [InlineData("42", 'd', 42)] - [InlineData("-42", 'd', -42)] - [InlineData("42d", 'd', 42)] - [InlineData("-42d", 'd', -42)] - public void NumberParser_ParseDoubleLiteral(string text, char qualifier, double expected) - { - // Arrange + [Theory] + [InlineData("42", 'd', 42)] + [InlineData("-42", 'd', -42)] + [InlineData("42d", 'd', 42)] + [InlineData("-42d", 'd', -42)] + public void NumberParser_ParseDoubleLiteral(string text, char qualifier, double expected) + { + // Arrange - // Act - var result = new NumberParser(_parsingConfig).ParseRealLiteral(text, qualifier, true) as ConstantExpression; + // Act + var result = new NumberParser(_parsingConfig).ParseRealLiteral(text, qualifier, true) as ConstantExpression; - // Assert - result!.Value.Should().Be(expected); - } + // Assert + result?.Value.Should().Be(expected); + } - [Theory] - [InlineData("42", 'f', 42)] - [InlineData("-42", 'f', -42)] - [InlineData("42f", 'f', 42)] - [InlineData("-42f", 'f', -42)] - public void NumberParser_ParseFloatLiteral(string text, char qualifier, float expected) - { - // Arrange + [Theory] + [InlineData("42", 'f', 42)] + [InlineData("-42", 'f', -42)] + [InlineData("42f", 'f', 42)] + [InlineData("-42f", 'f', -42)] + public void NumberParser_ParseFloatLiteral(string text, char qualifier, float expected) + { + // Arrange - // Act - var result = new NumberParser(_parsingConfig).ParseRealLiteral(text, qualifier, true) as ConstantExpression; + // Act + var result = new NumberParser(_parsingConfig).ParseRealLiteral(text, qualifier, true) as ConstantExpression; - // Assert - result!.Value.Should().Be(expected); - } + // Assert + result?.Value.Should().Be(expected); } -} +} \ No newline at end of file diff --git a/test/System.Linq.Dynamic.Core.Tests/System.Linq.Dynamic.Core.Tests.csproj b/test/System.Linq.Dynamic.Core.Tests/System.Linq.Dynamic.Core.Tests.csproj index e47b21d8..fbfdfa17 100644 --- a/test/System.Linq.Dynamic.Core.Tests/System.Linq.Dynamic.Core.Tests.csproj +++ b/test/System.Linq.Dynamic.Core.Tests/System.Linq.Dynamic.Core.Tests.csproj @@ -6,7 +6,6 @@ True ../../src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.snk false - enable $(DefineConstants);NETCOREAPP;EFCORE;EFCORE_3X;NETCOREAPP3_1;AspNetCoreIdentity diff --git a/version.xml b/version.xml index d0d14392..257b812f 100644 --- a/version.xml +++ b/version.xml @@ -1,5 +1,5 @@ - 1 + 2 \ No newline at end of file