Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Summary>Expression mapping (OData) extensions for AutoMapper</Summary>
<Description>Expression mapping (OData) extensions for AutoMapper</Description>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyOriginatorKeyFile>..\..\AutoMapper.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="[15.0.0,16.0.0)" />
<PackageReference Include="AutoMapper" Version="[15.0.1,16.0.0)" />
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework Condition=" '$(OS)' != 'Windows_NT' ">net8.0</TargetFramework>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net481;net8.0</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="Microsoft.OData.Edm" Version="8.2.3" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.21.7" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public enum SimpleEnum

public record Entity
{
public int Id { get; init; }
public SimpleEnum SimpleEnum { get; init; }
public int Id { get; set; }
public SimpleEnum SimpleEnum { get; set; }
}

public enum SimpleEnumModel
Expand All @@ -182,8 +182,8 @@ public enum SimpleEnumModel

public record EntityModel
{
public int Id { get; init; }
public SimpleEnumModel SimpleEnum { get; init; }
public int Id { get; set; }
public SimpleEnumModel SimpleEnum { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public void Map_expression_wchich_includes_local_constant()

public record Entity
{
public int Id { get; init; }
public int Id { get; set; }
}

public record EntityModel
{
public int Id { get; init; }
public int Id { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,19 @@ public void Can_map_using_type_binary_expression_to_test_the_parameter_expressio

//assert
Assert.Single(list);
#if NET8_0_OR_GREATER
Assert.Equal
(
"x => (Convert(IIF((x Is Triangle), Triangle, IIF((x Is Circle), Circle, Unknown)), Int32) == 2)",
whereMapped.ToString()
);
#else
Assert.Equal
(
"x => (Convert(IIF((x Is Triangle), Triangle, IIF((x Is Circle), Circle, Unknown))) == 2)",
whereMapped.ToString()
);
#endif
}

[Fact]
Expand Down Expand Up @@ -66,11 +74,19 @@ public void Can_map_using_type_binary_expression_to_test_a_member_expression()

//assert
Assert.Single(list);
#if NET8_0_OR_GREATER
Assert.Equal
(
"x => (Convert(IIF((x.Shape Is Triangle), Triangle, IIF((x.Shape Is Circle), Circle, Unknown)), Int32) == 2)",
whereMapped.ToString()
);
#else
Assert.Equal
(
"x => (Convert(IIF((x.Shape Is Triangle), Triangle, IIF((x.Shape Is Circle), Circle, Unknown))) == 2)",
whereMapped.ToString()
);
#endif
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ public class CanMapMismatchedLiteralMemberExpressionsWithoutCustomExpressions
[InlineData(nameof(ProductModel.DateTime), typeof(DateTime))]
[InlineData(nameof(ProductModel.DateTimeOffset), typeof(DateTimeOffset))]
[InlineData(nameof(ProductModel.Date), typeof(Date))]
#if NET8_0_OR_GREATER
[InlineData(nameof(ProductModel.DateOnly), typeof(DateOnly))]
#endif
[InlineData(nameof(ProductModel.TimeSpan), typeof(TimeSpan))]
[InlineData(nameof(ProductModel.TimeOfDay), typeof(TimeOfDay))]
#if NET8_0_OR_GREATER
[InlineData(nameof(ProductModel.TimeOnly), typeof(TimeOnly))]
#endif
[InlineData(nameof(ProductModel.Guid), typeof(Guid))]
[InlineData(nameof(ProductModel.Decimal), typeof(decimal))]
[InlineData(nameof(ProductModel.Byte), typeof(byte))]
Expand Down Expand Up @@ -59,10 +63,14 @@ public void CanMapNonNullableToNullableWithoutCustomExpression(string memberName
[InlineData(nameof(Product.DateTime), typeof(DateTime?))]
[InlineData(nameof(Product.DateTimeOffset), typeof(DateTimeOffset?))]
[InlineData(nameof(Product.Date), typeof(Date?))]
#if NET8_0_OR_GREATER
[InlineData(nameof(Product.DateOnly), typeof(DateOnly?))]
#endif
[InlineData(nameof(Product.TimeSpan), typeof(TimeSpan?))]
[InlineData(nameof(Product.TimeOfDay), typeof(TimeOfDay?))]
#if NET8_0_OR_GREATER
[InlineData(nameof(Product.TimeOnly), typeof(TimeOnly?))]
#endif
[InlineData(nameof(Product.Guid), typeof(Guid?))]
[InlineData(nameof(Product.Decimal), typeof(decimal?))]
[InlineData(nameof(Product.Byte), typeof(byte?))]
Expand Down Expand Up @@ -106,10 +114,14 @@ public void CanMapNullableToNonNullableWithoutCustomExpression(string memberName
[InlineData(nameof(ProductModel.DateTime), typeof(DateTime))]
[InlineData(nameof(ProductModel.DateTimeOffset), typeof(DateTimeOffset))]
[InlineData(nameof(ProductModel.Date), typeof(Date))]
#if NET8_0_OR_GREATER
[InlineData(nameof(ProductModel.DateOnly), typeof(DateOnly))]
#endif
[InlineData(nameof(ProductModel.TimeSpan), typeof(TimeSpan))]
[InlineData(nameof(ProductModel.TimeOfDay), typeof(TimeOfDay))]
#if NET8_0_OR_GREATER
[InlineData(nameof(ProductModel.TimeOnly), typeof(TimeOnly))]
#endif
[InlineData(nameof(ProductModel.Guid), typeof(Guid))]
[InlineData(nameof(ProductModel.Decimal), typeof(decimal))]
[InlineData(nameof(ProductModel.Byte), typeof(byte))]
Expand Down Expand Up @@ -153,10 +165,14 @@ public void CanMapNonNullableSelectorToNullableelectorWithoutCustomExpression(st
[InlineData(nameof(Product.DateTime), typeof(DateTime?))]
[InlineData(nameof(Product.DateTimeOffset), typeof(DateTimeOffset?))]
[InlineData(nameof(Product.Date), typeof(Date?))]
#if NET8_0_OR_GREATER
[InlineData(nameof(Product.DateOnly), typeof(DateOnly?))]
#endif
[InlineData(nameof(Product.TimeSpan), typeof(TimeSpan?))]
[InlineData(nameof(Product.TimeOfDay), typeof(TimeOfDay?))]
#if NET8_0_OR_GREATER
[InlineData(nameof(Product.TimeOnly), typeof(TimeOnly?))]
#endif
[InlineData(nameof(Product.Guid), typeof(Guid?))]
[InlineData(nameof(Product.Decimal), typeof(decimal?))]
[InlineData(nameof(Product.Byte), typeof(byte?))]
Expand Down Expand Up @@ -222,10 +238,14 @@ class Product
public DateTimeOffset? DateTimeOffset { get; set; }
public DateTime? DateTime { get; set; }
public Date? Date { get; set; }
#if NET8_0_OR_GREATER
public DateOnly? DateOnly { get; set; }
#endif
public TimeSpan? TimeSpan { get; set; }
public TimeOfDay? TimeOfDay { get; set; }
#if NET8_0_OR_GREATER
public TimeOnly? TimeOnly { get; set; }
#endif
public Guid? Guid { get; set; }
public decimal? Decimal { get; set; }
public byte? Byte { get; set; }
Expand All @@ -247,10 +267,14 @@ class ProductModel
public DateTimeOffset DateTimeOffset { get; set; }
public DateTime DateTime { get; set; }
public Date Date { get; set; }
#if NET8_0_OR_GREATER
public DateOnly DateOnly { get; set; }
#endif
public TimeSpan TimeSpan { get; set; }
public TimeOfDay TimeOfDay { get; set; }
#if NET8_0_OR_GREATER
public TimeOnly TimeOnly { get; set; }
#endif
public Guid Guid { get; set; }
public decimal Decimal { get; set; }
public byte Byte { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ public class ShouldThrowInvalidOperationExceptionForUnmatchedLiterals
[InlineData(nameof(ProductModel.DateTime), typeof(DateTime?))]
[InlineData(nameof(ProductModel.DateTimeOffset), typeof(DateTimeOffset?))]
[InlineData(nameof(ProductModel.Date), typeof(Date?))]
#if NET8_0_OR_GREATER
[InlineData(nameof(ProductModel.DateOnly), typeof(DateOnly?))]
#endif
[InlineData(nameof(ProductModel.TimeSpan), typeof(TimeSpan?))]
[InlineData(nameof(ProductModel.TimeOfDay), typeof(TimeOfDay?))]
#if NET8_0_OR_GREATER
[InlineData(nameof(ProductModel.TimeOnly), typeof(TimeOnly?))]
#endif
[InlineData(nameof(ProductModel.Guid), typeof(Guid?))]
[InlineData(nameof(ProductModel.Decimal), typeof(decimal?))]
[InlineData(nameof(ProductModel.Byte), typeof(byte?))]
Expand Down Expand Up @@ -52,10 +56,14 @@ public void ThrowsCreatingBinaryExpressionCombiningNonNullableParameterWithNulla
[InlineData(nameof(Product.DateTime), typeof(DateTime))]
[InlineData(nameof(Product.DateTimeOffset), typeof(DateTimeOffset))]
[InlineData(nameof(Product.Date), typeof(Date))]
#if NET8_0_OR_GREATER
[InlineData(nameof(Product.DateOnly), typeof(DateOnly))]
#endif
[InlineData(nameof(Product.TimeSpan), typeof(TimeSpan))]
[InlineData(nameof(Product.TimeOfDay), typeof(TimeOfDay))]
#if NET8_0_OR_GREATER
[InlineData(nameof(Product.TimeOnly), typeof(TimeOnly))]
#endif
[InlineData(nameof(Product.Guid), typeof(Guid))]
[InlineData(nameof(Product.Decimal), typeof(decimal))]
[InlineData(nameof(Product.Byte), typeof(byte))]
Expand Down Expand Up @@ -93,10 +101,14 @@ class Product
public DateTimeOffset? DateTimeOffset { get; set; }
public DateTime? DateTime { get; set; }
public Date? Date { get; set; }
#if NET8_0_OR_GREATER
public DateOnly? DateOnly { get; set; }
#endif
public TimeSpan? TimeSpan { get; set; }
public TimeOfDay? TimeOfDay { get; set; }
#if NET8_0_OR_GREATER
public TimeOnly? TimeOnly { get; set; }
#endif
public Guid? Guid { get; set; }
public decimal? Decimal { get; set; }
public byte? Byte { get; set; }
Expand All @@ -118,10 +130,14 @@ class ProductModel
public DateTimeOffset DateTimeOffset { get; set; }
public DateTime DateTime { get; set; }
public Date Date { get; set; }
#if NET8_0_OR_GREATER
public DateOnly DateOnly { get; set; }
#endif
public TimeSpan TimeSpan { get; set; }
public TimeOfDay TimeOfDay { get; set; }
#if NET8_0_OR_GREATER
public TimeOnly TimeOnly { get; set; }
#endif
public Guid Guid { get; set; }
public decimal Decimal { get; set; }
public byte Byte { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public enum SimpleEnum

public record Entity
{
public int Id { get; init; }
public SimpleEnum SimpleEnum { get; init; }
public int Id { get; set; }
public SimpleEnum SimpleEnum { get; set; }
}

public enum SimpleEnumModel
Expand All @@ -57,8 +57,8 @@ public enum SimpleEnumModel

public record EntityModel
{
public int Id { get; init; }
public SimpleEnumModel SimpleEnum { get; init; }
public int Id { get; set; }
public SimpleEnumModel SimpleEnum { get; set; }
}

public class HasFlagVisitor : ExpressionVisitor
Expand Down