Skip to content

Commit 7fa9eb9

Browse files
authored
Supporting .NetStandard. (#184)
1 parent 322912d commit 7fa9eb9

8 files changed

+71
-14
lines changed

src/AutoMapper.Extensions.ExpressionMapping/AutoMapper.Extensions.ExpressionMapping.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Summary>Expression mapping (OData) extensions for AutoMapper</Summary>
55
<Description>Expression mapping (OData) extensions for AutoMapper</Description>
6-
<TargetFramework>net8.0</TargetFramework>
6+
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<AssemblyOriginatorKeyFile>..\..\AutoMapper.snk</AssemblyOriginatorKeyFile>
99
<SignAssembly>true</SignAssembly>
@@ -29,7 +29,7 @@
2929
</ItemGroup>
3030

3131
<ItemGroup>
32-
<PackageReference Include="AutoMapper" Version="[15.0.0,16.0.0)" />
32+
<PackageReference Include="AutoMapper" Version="[15.0.1,16.0.0)" />
3333
<PackageReference Include="MinVer" Version="6.0.0">
3434
<PrivateAssets>all</PrivateAssets>
3535
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/AutoMapper.Extensions.ExpressionMapping.UnitTests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework Condition=" '$(OS)' != 'Windows_NT' ">net8.0</TargetFramework>
5+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net481;net8.0</TargetFrameworks>
56

67
<IsPackable>false</IsPackable>
78
</PropertyGroup>
89

910
<ItemGroup>
1011
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
11-
<PackageReference Include="Microsoft.OData.Edm" Version="8.2.3" />
12+
<PackageReference Include="Microsoft.OData.Edm" Version="7.21.7" />
1213
<PackageReference Include="Shouldly" Version="4.3.0" />
1314
<PackageReference Include="xunit" Version="2.9.3" />
1415
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/CanMapExpressionWithListConstants.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ public enum SimpleEnum
169169

170170
public record Entity
171171
{
172-
public int Id { get; init; }
173-
public SimpleEnum SimpleEnum { get; init; }
172+
public int Id { get; set; }
173+
public SimpleEnum SimpleEnum { get; set; }
174174
}
175175

176176
public enum SimpleEnumModel
@@ -182,8 +182,8 @@ public enum SimpleEnumModel
182182

183183
public record EntityModel
184184
{
185-
public int Id { get; init; }
186-
public SimpleEnumModel SimpleEnum { get; init; }
185+
public int Id { get; set; }
186+
public SimpleEnumModel SimpleEnum { get; set; }
187187
}
188188
}
189189
}

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/CanMapExpressionWithLocalExpressionConstant.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public void Map_expression_wchich_includes_local_constant()
3838

3939
public record Entity
4040
{
41-
public int Id { get; init; }
41+
public int Id { get; set; }
4242
}
4343

4444
public record EntityModel
4545
{
46-
public int Id { get; init; }
46+
public int Id { get; set; }
4747
}
4848
}
4949
}

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/CanMapMemberFromTypeBinaryExpression.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,19 @@ public void Can_map_using_type_binary_expression_to_test_the_parameter_expressio
3030

3131
//assert
3232
Assert.Single(list);
33+
#if NET8_0_OR_GREATER
3334
Assert.Equal
3435
(
3536
"x => (Convert(IIF((x Is Triangle), Triangle, IIF((x Is Circle), Circle, Unknown)), Int32) == 2)",
3637
whereMapped.ToString()
3738
);
39+
#else
40+
Assert.Equal
41+
(
42+
"x => (Convert(IIF((x Is Triangle), Triangle, IIF((x Is Circle), Circle, Unknown))) == 2)",
43+
whereMapped.ToString()
44+
);
45+
#endif
3846
}
3947

4048
[Fact]
@@ -66,11 +74,19 @@ public void Can_map_using_type_binary_expression_to_test_a_member_expression()
6674

6775
//assert
6876
Assert.Single(list);
77+
#if NET8_0_OR_GREATER
6978
Assert.Equal
7079
(
7180
"x => (Convert(IIF((x.Shape Is Triangle), Triangle, IIF((x.Shape Is Circle), Circle, Unknown)), Int32) == 2)",
7281
whereMapped.ToString()
7382
);
83+
#else
84+
Assert.Equal
85+
(
86+
"x => (Convert(IIF((x.Shape Is Triangle), Triangle, IIF((x.Shape Is Circle), Circle, Unknown))) == 2)",
87+
whereMapped.ToString()
88+
);
89+
#endif
7490
}
7591

7692
[Fact]

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/CanMapMismatchedLiteralMemberExpressionsWithoutCustomExpressions.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ public class CanMapMismatchedLiteralMemberExpressionsWithoutCustomExpressions
1212
[InlineData(nameof(ProductModel.DateTime), typeof(DateTime))]
1313
[InlineData(nameof(ProductModel.DateTimeOffset), typeof(DateTimeOffset))]
1414
[InlineData(nameof(ProductModel.Date), typeof(Date))]
15+
#if NET8_0_OR_GREATER
1516
[InlineData(nameof(ProductModel.DateOnly), typeof(DateOnly))]
17+
#endif
1618
[InlineData(nameof(ProductModel.TimeSpan), typeof(TimeSpan))]
1719
[InlineData(nameof(ProductModel.TimeOfDay), typeof(TimeOfDay))]
20+
#if NET8_0_OR_GREATER
1821
[InlineData(nameof(ProductModel.TimeOnly), typeof(TimeOnly))]
22+
#endif
1923
[InlineData(nameof(ProductModel.Guid), typeof(Guid))]
2024
[InlineData(nameof(ProductModel.Decimal), typeof(decimal))]
2125
[InlineData(nameof(ProductModel.Byte), typeof(byte))]
@@ -59,10 +63,14 @@ public void CanMapNonNullableToNullableWithoutCustomExpression(string memberName
5963
[InlineData(nameof(Product.DateTime), typeof(DateTime?))]
6064
[InlineData(nameof(Product.DateTimeOffset), typeof(DateTimeOffset?))]
6165
[InlineData(nameof(Product.Date), typeof(Date?))]
66+
#if NET8_0_OR_GREATER
6267
[InlineData(nameof(Product.DateOnly), typeof(DateOnly?))]
68+
#endif
6369
[InlineData(nameof(Product.TimeSpan), typeof(TimeSpan?))]
6470
[InlineData(nameof(Product.TimeOfDay), typeof(TimeOfDay?))]
71+
#if NET8_0_OR_GREATER
6572
[InlineData(nameof(Product.TimeOnly), typeof(TimeOnly?))]
73+
#endif
6674
[InlineData(nameof(Product.Guid), typeof(Guid?))]
6775
[InlineData(nameof(Product.Decimal), typeof(decimal?))]
6876
[InlineData(nameof(Product.Byte), typeof(byte?))]
@@ -106,10 +114,14 @@ public void CanMapNullableToNonNullableWithoutCustomExpression(string memberName
106114
[InlineData(nameof(ProductModel.DateTime), typeof(DateTime))]
107115
[InlineData(nameof(ProductModel.DateTimeOffset), typeof(DateTimeOffset))]
108116
[InlineData(nameof(ProductModel.Date), typeof(Date))]
117+
#if NET8_0_OR_GREATER
109118
[InlineData(nameof(ProductModel.DateOnly), typeof(DateOnly))]
119+
#endif
110120
[InlineData(nameof(ProductModel.TimeSpan), typeof(TimeSpan))]
111121
[InlineData(nameof(ProductModel.TimeOfDay), typeof(TimeOfDay))]
122+
#if NET8_0_OR_GREATER
112123
[InlineData(nameof(ProductModel.TimeOnly), typeof(TimeOnly))]
124+
#endif
113125
[InlineData(nameof(ProductModel.Guid), typeof(Guid))]
114126
[InlineData(nameof(ProductModel.Decimal), typeof(decimal))]
115127
[InlineData(nameof(ProductModel.Byte), typeof(byte))]
@@ -153,10 +165,14 @@ public void CanMapNonNullableSelectorToNullableelectorWithoutCustomExpression(st
153165
[InlineData(nameof(Product.DateTime), typeof(DateTime?))]
154166
[InlineData(nameof(Product.DateTimeOffset), typeof(DateTimeOffset?))]
155167
[InlineData(nameof(Product.Date), typeof(Date?))]
168+
#if NET8_0_OR_GREATER
156169
[InlineData(nameof(Product.DateOnly), typeof(DateOnly?))]
170+
#endif
157171
[InlineData(nameof(Product.TimeSpan), typeof(TimeSpan?))]
158172
[InlineData(nameof(Product.TimeOfDay), typeof(TimeOfDay?))]
173+
#if NET8_0_OR_GREATER
159174
[InlineData(nameof(Product.TimeOnly), typeof(TimeOnly?))]
175+
#endif
160176
[InlineData(nameof(Product.Guid), typeof(Guid?))]
161177
[InlineData(nameof(Product.Decimal), typeof(decimal?))]
162178
[InlineData(nameof(Product.Byte), typeof(byte?))]
@@ -222,10 +238,14 @@ class Product
222238
public DateTimeOffset? DateTimeOffset { get; set; }
223239
public DateTime? DateTime { get; set; }
224240
public Date? Date { get; set; }
241+
#if NET8_0_OR_GREATER
225242
public DateOnly? DateOnly { get; set; }
243+
#endif
226244
public TimeSpan? TimeSpan { get; set; }
227245
public TimeOfDay? TimeOfDay { get; set; }
246+
#if NET8_0_OR_GREATER
228247
public TimeOnly? TimeOnly { get; set; }
248+
#endif
229249
public Guid? Guid { get; set; }
230250
public decimal? Decimal { get; set; }
231251
public byte? Byte { get; set; }
@@ -247,10 +267,14 @@ class ProductModel
247267
public DateTimeOffset DateTimeOffset { get; set; }
248268
public DateTime DateTime { get; set; }
249269
public Date Date { get; set; }
270+
#if NET8_0_OR_GREATER
250271
public DateOnly DateOnly { get; set; }
272+
#endif
251273
public TimeSpan TimeSpan { get; set; }
252274
public TimeOfDay TimeOfDay { get; set; }
275+
#if NET8_0_OR_GREATER
253276
public TimeOnly TimeOnly { get; set; }
277+
#endif
254278
public Guid Guid { get; set; }
255279
public decimal Decimal { get; set; }
256280
public byte Byte { get; set; }

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/ShouldThrowInvalidOperationExceptionForUnmatchedLiterals.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ public class ShouldThrowInvalidOperationExceptionForUnmatchedLiterals
1212
[InlineData(nameof(ProductModel.DateTime), typeof(DateTime?))]
1313
[InlineData(nameof(ProductModel.DateTimeOffset), typeof(DateTimeOffset?))]
1414
[InlineData(nameof(ProductModel.Date), typeof(Date?))]
15+
#if NET8_0_OR_GREATER
1516
[InlineData(nameof(ProductModel.DateOnly), typeof(DateOnly?))]
17+
#endif
1618
[InlineData(nameof(ProductModel.TimeSpan), typeof(TimeSpan?))]
1719
[InlineData(nameof(ProductModel.TimeOfDay), typeof(TimeOfDay?))]
20+
#if NET8_0_OR_GREATER
1821
[InlineData(nameof(ProductModel.TimeOnly), typeof(TimeOnly?))]
22+
#endif
1923
[InlineData(nameof(ProductModel.Guid), typeof(Guid?))]
2024
[InlineData(nameof(ProductModel.Decimal), typeof(decimal?))]
2125
[InlineData(nameof(ProductModel.Byte), typeof(byte?))]
@@ -52,10 +56,14 @@ public void ThrowsCreatingBinaryExpressionCombiningNonNullableParameterWithNulla
5256
[InlineData(nameof(Product.DateTime), typeof(DateTime))]
5357
[InlineData(nameof(Product.DateTimeOffset), typeof(DateTimeOffset))]
5458
[InlineData(nameof(Product.Date), typeof(Date))]
59+
#if NET8_0_OR_GREATER
5560
[InlineData(nameof(Product.DateOnly), typeof(DateOnly))]
61+
#endif
5662
[InlineData(nameof(Product.TimeSpan), typeof(TimeSpan))]
5763
[InlineData(nameof(Product.TimeOfDay), typeof(TimeOfDay))]
64+
#if NET8_0_OR_GREATER
5865
[InlineData(nameof(Product.TimeOnly), typeof(TimeOnly))]
66+
#endif
5967
[InlineData(nameof(Product.Guid), typeof(Guid))]
6068
[InlineData(nameof(Product.Decimal), typeof(decimal))]
6169
[InlineData(nameof(Product.Byte), typeof(byte))]
@@ -93,10 +101,14 @@ class Product
93101
public DateTimeOffset? DateTimeOffset { get; set; }
94102
public DateTime? DateTime { get; set; }
95103
public Date? Date { get; set; }
104+
#if NET8_0_OR_GREATER
96105
public DateOnly? DateOnly { get; set; }
106+
#endif
97107
public TimeSpan? TimeSpan { get; set; }
98108
public TimeOfDay? TimeOfDay { get; set; }
109+
#if NET8_0_OR_GREATER
99110
public TimeOnly? TimeOnly { get; set; }
111+
#endif
100112
public Guid? Guid { get; set; }
101113
public decimal? Decimal { get; set; }
102114
public byte? Byte { get; set; }
@@ -118,10 +130,14 @@ class ProductModel
118130
public DateTimeOffset DateTimeOffset { get; set; }
119131
public DateTime DateTime { get; set; }
120132
public Date Date { get; set; }
133+
#if NET8_0_OR_GREATER
121134
public DateOnly DateOnly { get; set; }
135+
#endif
122136
public TimeSpan TimeSpan { get; set; }
123137
public TimeOfDay TimeOfDay { get; set; }
138+
#if NET8_0_OR_GREATER
124139
public TimeOnly TimeOnly { get; set; }
140+
#endif
125141
public Guid Guid { get; set; }
126142
public decimal Decimal { get; set; }
127143
public byte Byte { get; set; }

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/ShouldUseDeclaringTypeForInstanceMethodCalls.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public enum SimpleEnum
4444

4545
public record Entity
4646
{
47-
public int Id { get; init; }
48-
public SimpleEnum SimpleEnum { get; init; }
47+
public int Id { get; set; }
48+
public SimpleEnum SimpleEnum { get; set; }
4949
}
5050

5151
public enum SimpleEnumModel
@@ -57,8 +57,8 @@ public enum SimpleEnumModel
5757

5858
public record EntityModel
5959
{
60-
public int Id { get; init; }
61-
public SimpleEnumModel SimpleEnum { get; init; }
60+
public int Id { get; set; }
61+
public SimpleEnumModel SimpleEnum { get; set; }
6262
}
6363

6464
public class HasFlagVisitor : ExpressionVisitor

0 commit comments

Comments
 (0)