Skip to content

Commit ef7eef1

Browse files
authored
Marking obsolete methods and classes. (#189)
1 parent 9808a0d commit ef7eef1

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
1111
<PackageId>AutoMapper.Extensions.ExpressionMapping</PackageId>
1212
<PackageIcon>icon.png</PackageIcon>
13+
<PackageReadmeFile>README.md</PackageReadmeFile>
14+
<PackageReleaseNotes>Marking obsolete methods and classes.</PackageReleaseNotes>
1315
<PackageProjectUrl>https://automapper.org</PackageProjectUrl>
1416
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1517
<RepositoryType>git</RepositoryType>
@@ -30,11 +32,11 @@
3032

3133
<ItemGroup>
3234
<PackageReference Include="AutoMapper" Version="[16.0.0,17.0.0)" />
33-
<PackageReference Include="MinVer" Version="6.0.0">
35+
<PackageReference Include="MinVer" Version="7.0.0">
3436
<PrivateAssets>all</PrivateAssets>
3537
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3638
</PackageReference>
37-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
39+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.103" PrivateAssets="All" />
3840
</ItemGroup>
3941

4042
<ItemGroup>

src/AutoMapper.Extensions.ExpressionMapping/MapIncludesVisitor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace AutoMapper.Extensions.ExpressionMapping
99
{
10+
[Obsolete("This class is not intended for public use and may be removed in future versions.")]
1011
public class MapIncludesVisitor : XpressionMapperVisitor
1112
{
1213
public MapIncludesVisitor(IMapper mapper, IConfigurationProvider configurationProvider, Dictionary<Type, Type> typeMappings)

src/AutoMapper.Extensions.ExpressionMapping/MapperExtensions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ private static TDestDelegate _MapExpression<TSourceDelegate, TDestDelegate>(this
3939
private static MethodInfo GetMapExpressionMethod(this string methodName)
4040
=> typeof(MapperExtensions).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static);
4141

42+
[Obsolete("This method is obsolete. Use IMapper.Map(object source, Type sourceType, Type destinationType) instead.")]
4243
public static object MapObject(this IMapper mapper, object obj, Type sourceType, Type destType)
4344
=> "_MapObject".GetMapObjectMethod().MakeGenericMethod
4445
(
@@ -153,6 +154,7 @@ public static TDestDelegate MapExpression<TSourceDelegate, TDestDelegate>(this I
153154
/// <param name="mapper"></param>
154155
/// <param name="expression"></param>
155156
/// <returns></returns>
157+
[Obsolete("Use ProjectTo with expansions instead of IMapper.MapExpressionAsInclude.")]
156158
public static TDestDelegate MapExpressionAsInclude<TDestDelegate>(this IMapper mapper, LambdaExpression expression)
157159
where TDestDelegate : LambdaExpression
158160
{
@@ -175,6 +177,7 @@ public static TDestDelegate MapExpressionAsInclude<TDestDelegate>(this IMapper m
175177
/// <param name="mapper"></param>
176178
/// <param name="expression"></param>
177179
/// <returns></returns>
180+
[Obsolete("Use ProjectTo with expansions instead of IMapper.MapExpressionAsInclude.")]
178181
public static TDestDelegate MapExpressionAsInclude<TSourceDelegate, TDestDelegate>(this IMapper mapper, TSourceDelegate expression)
179182
where TSourceDelegate : LambdaExpression
180183
where TDestDelegate : LambdaExpression
@@ -212,6 +215,7 @@ public static ICollection<TDestDelegate> MapExpressionList<TDestDelegate>(this I
212215
/// <param name="mapper"></param>
213216
/// <param name="collection"></param>
214217
/// <returns></returns>
218+
[Obsolete("Use ProjectTo with expansions instead of IMapper.MapIncludesList.")]
215219
public static ICollection<TDestDelegate> MapIncludesList<TSourceDelegate, TDestDelegate>(this IMapper mapper, ICollection<TSourceDelegate> collection)
216220
where TSourceDelegate : LambdaExpression
217221
where TDestDelegate : LambdaExpression
@@ -224,6 +228,7 @@ public static ICollection<TDestDelegate> MapIncludesList<TSourceDelegate, TDestD
224228
/// <param name="mapper"></param>
225229
/// <param name="collection"></param>
226230
/// <returns></returns>
231+
[Obsolete("Use ProjectTo with expansions instead of IMapper.MapIncludesList.")]
227232
public static ICollection<TDestDelegate> MapIncludesList<TDestDelegate>(this IMapper mapper, IEnumerable<LambdaExpression> collection)
228233
where TDestDelegate : LambdaExpression
229234
=> collection?.Select(mapper.MapExpressionAsInclude<TDestDelegate>).ToList();
@@ -235,6 +240,7 @@ public static ICollection<TDestDelegate> MapIncludesList<TDestDelegate>(this IMa
235240
/// <param name="infoDictionary"></param>
236241
/// <param name="typeMappings"></param>
237242
/// <returns></returns>
243+
[Obsolete("This method will be moved to a public class meant for internal use.")]
238244
public static List<ParameterExpression> GetDestinationParameterExpressions(this LambdaExpression expression, MapperInfoDictionary infoDictionary, Dictionary<Type, Type> typeMappings)
239245
{
240246
foreach (var p in expression.Parameters.Where(p => !infoDictionary.ContainsKey(p)))
@@ -253,6 +259,7 @@ public static List<ParameterExpression> GetDestinationParameterExpressions(this
253259
/// <param name="typeMappings"></param>
254260
/// <param name="configurationProvider"></param>
255261
/// <returns></returns>
262+
[Obsolete("This method is not being used and will be removed.")]
256263
public static Dictionary<Type, Type> AddTypeMapping<TSource, TDest>(this Dictionary<Type, Type> typeMappings, IConfigurationProvider configurationProvider)
257264
=> typeMappings == null
258265
? throw new ArgumentException(Properties.Resources.typeMappingsDictionaryIsNull)
@@ -293,6 +300,7 @@ private static void AddUnderlyingTypes(this Dictionary<Type, Type> typeMappings,
293300
/// <param name="sourceType"></param>
294301
/// <param name="destType"></param>
295302
/// <returns></returns>
303+
[Obsolete("This method will be moved to a public class meant for internal use.")]
296304
public static Dictionary<Type, Type> AddTypeMapping(this Dictionary<Type, Type> typeMappings, IConfigurationProvider configurationProvider, Type sourceType, Type destType)
297305
{
298306
if (typeMappings == null)
@@ -345,6 +353,7 @@ void AddTypeMaps(TypeMap typeMap)
345353
/// <param name="typeMappings"></param>
346354
/// <param name="sourceType"></param>
347355
/// <returns></returns>
356+
[Obsolete("This method will be moved to a public class meant for internal use.")]
348357
public static Type ReplaceType(this Dictionary<Type, Type> typeMappings, Type sourceType)
349358
{
350359
if (sourceType.IsArray)

src/AutoMapper.Extensions.ExpressionMapping/Structures/MapperInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace AutoMapper.Extensions.ExpressionMapping.Structures
55
{
66
public class MapperInfo
77
{
8+
[Obsolete("Use MapperInfo(ParameterExpression newParameter, Type sourceType, Type destType).")]
89
public MapperInfo()
910
{
1011

src/AutoMapper.Extensions.ExpressionMapping/XpressionMapperVisitor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace AutoMapper.Extensions.ExpressionMapping
1313
{
1414
public class XpressionMapperVisitor : ExpressionVisitor
1515
{
16+
[Obsolete("This constructor is obsolete. Use XpressionMapperVisitor(IMapper mapper, Dictionary<Type, Type> typeMappings).")]
1617
public XpressionMapperVisitor(IMapper mapper, IConfigurationProvider configurationProvider, Dictionary<Type, Type> typeMappings)
1718
{
1819
Mapper = mapper;
@@ -21,6 +22,14 @@ public XpressionMapperVisitor(IMapper mapper, IConfigurationProvider configurati
2122
ConfigurationProvider = configurationProvider;
2223
}
2324

25+
public XpressionMapperVisitor(IMapper mapper, Dictionary<Type, Type> typeMappings)
26+
{
27+
Mapper = mapper;
28+
TypeMappings = typeMappings;
29+
InfoDictionary = new MapperInfoDictionary(new ParameterExpressionEqualityComparer());
30+
ConfigurationProvider = mapper.ConfigurationProvider;
31+
}
32+
2433
public MapperInfoDictionary InfoDictionary { get; }
2534

2635
public Dictionary<Type, Type> TypeMappings { get; }

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<PropertyGroup>
44
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net8.0;net10.0</TargetFrameworks>
55
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net481;net8.0;net9.0;net10.0</TargetFrameworks>
6-
7-
<IsPackable>false</IsPackable>
6+
<OutputType>Exe</OutputType>
7+
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99

1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1212
<PackageReference Include="Microsoft.OData.Edm" Version="7.22.0" />
1313
<PackageReference Include="Shouldly" Version="4.3.0" />
14-
<PackageReference Include="xunit" Version="2.9.3" />
14+
<PackageReference Include="xunit.v3" Version="3.2.2" />
1515
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)