From bccdc63e99c280ed388b14280ce09ae2c91260cc Mon Sep 17 00:00:00 2001 From: Blaise Taylor Date: Thu, 19 Feb 2026 13:25:39 -0500 Subject: [PATCH] Marking obsolete methods and classes. --- .../AutoMapper.Extensions.ExpressionMapping.csproj | 6 ++++-- .../MapIncludesVisitor.cs | 1 + .../MapperExtensions.cs | 9 +++++++++ .../Structures/MapperInfo.cs | 1 + .../XpressionMapperVisitor.cs | 9 +++++++++ ...oMapper.Extensions.ExpressionMapping.UnitTests.csproj | 6 +++--- 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/AutoMapper.Extensions.ExpressionMapping/AutoMapper.Extensions.ExpressionMapping.csproj b/src/AutoMapper.Extensions.ExpressionMapping/AutoMapper.Extensions.ExpressionMapping.csproj index 8ae2b3f..255dde4 100644 --- a/src/AutoMapper.Extensions.ExpressionMapping/AutoMapper.Extensions.ExpressionMapping.csproj +++ b/src/AutoMapper.Extensions.ExpressionMapping/AutoMapper.Extensions.ExpressionMapping.csproj @@ -10,6 +10,8 @@ true AutoMapper.Extensions.ExpressionMapping icon.png + README.md + Marking obsolete methods and classes. https://automapper.org MIT git @@ -30,11 +32,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/AutoMapper.Extensions.ExpressionMapping/MapIncludesVisitor.cs b/src/AutoMapper.Extensions.ExpressionMapping/MapIncludesVisitor.cs index 85898e3..20d04fb 100644 --- a/src/AutoMapper.Extensions.ExpressionMapping/MapIncludesVisitor.cs +++ b/src/AutoMapper.Extensions.ExpressionMapping/MapIncludesVisitor.cs @@ -7,6 +7,7 @@ namespace AutoMapper.Extensions.ExpressionMapping { + [Obsolete("This class is not intended for public use and may be removed in future versions.")] public class MapIncludesVisitor : XpressionMapperVisitor { public MapIncludesVisitor(IMapper mapper, IConfigurationProvider configurationProvider, Dictionary typeMappings) diff --git a/src/AutoMapper.Extensions.ExpressionMapping/MapperExtensions.cs b/src/AutoMapper.Extensions.ExpressionMapping/MapperExtensions.cs index 1c47e37..b64296a 100644 --- a/src/AutoMapper.Extensions.ExpressionMapping/MapperExtensions.cs +++ b/src/AutoMapper.Extensions.ExpressionMapping/MapperExtensions.cs @@ -39,6 +39,7 @@ private static TDestDelegate _MapExpression(this private static MethodInfo GetMapExpressionMethod(this string methodName) => typeof(MapperExtensions).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static); + [Obsolete("This method is obsolete. Use IMapper.Map(object source, Type sourceType, Type destinationType) instead.")] public static object MapObject(this IMapper mapper, object obj, Type sourceType, Type destType) => "_MapObject".GetMapObjectMethod().MakeGenericMethod ( @@ -153,6 +154,7 @@ public static TDestDelegate MapExpression(this I /// /// /// + [Obsolete("Use ProjectTo with expansions instead of IMapper.MapExpressionAsInclude.")] public static TDestDelegate MapExpressionAsInclude(this IMapper mapper, LambdaExpression expression) where TDestDelegate : LambdaExpression { @@ -175,6 +177,7 @@ public static TDestDelegate MapExpressionAsInclude(this IMapper m /// /// /// + [Obsolete("Use ProjectTo with expansions instead of IMapper.MapExpressionAsInclude.")] public static TDestDelegate MapExpressionAsInclude(this IMapper mapper, TSourceDelegate expression) where TSourceDelegate : LambdaExpression where TDestDelegate : LambdaExpression @@ -212,6 +215,7 @@ public static ICollection MapExpressionList(this I /// /// /// + [Obsolete("Use ProjectTo with expansions instead of IMapper.MapIncludesList.")] public static ICollection MapIncludesList(this IMapper mapper, ICollection collection) where TSourceDelegate : LambdaExpression where TDestDelegate : LambdaExpression @@ -224,6 +228,7 @@ public static ICollection MapIncludesList /// /// + [Obsolete("Use ProjectTo with expansions instead of IMapper.MapIncludesList.")] public static ICollection MapIncludesList(this IMapper mapper, IEnumerable collection) where TDestDelegate : LambdaExpression => collection?.Select(mapper.MapExpressionAsInclude).ToList(); @@ -235,6 +240,7 @@ public static ICollection MapIncludesList(this IMa /// /// /// + [Obsolete("This method will be moved to a public class meant for internal use.")] public static List GetDestinationParameterExpressions(this LambdaExpression expression, MapperInfoDictionary infoDictionary, Dictionary typeMappings) { foreach (var p in expression.Parameters.Where(p => !infoDictionary.ContainsKey(p))) @@ -253,6 +259,7 @@ public static List GetDestinationParameterExpressions(this /// /// /// + [Obsolete("This method is not being used and will be removed.")] public static Dictionary AddTypeMapping(this Dictionary typeMappings, IConfigurationProvider configurationProvider) => typeMappings == null ? throw new ArgumentException(Properties.Resources.typeMappingsDictionaryIsNull) @@ -293,6 +300,7 @@ private static void AddUnderlyingTypes(this Dictionary typeMappings, /// /// /// + [Obsolete("This method will be moved to a public class meant for internal use.")] public static Dictionary AddTypeMapping(this Dictionary typeMappings, IConfigurationProvider configurationProvider, Type sourceType, Type destType) { if (typeMappings == null) @@ -345,6 +353,7 @@ void AddTypeMaps(TypeMap typeMap) /// /// /// + [Obsolete("This method will be moved to a public class meant for internal use.")] public static Type ReplaceType(this Dictionary typeMappings, Type sourceType) { if (sourceType.IsArray) diff --git a/src/AutoMapper.Extensions.ExpressionMapping/Structures/MapperInfo.cs b/src/AutoMapper.Extensions.ExpressionMapping/Structures/MapperInfo.cs index 6b6849d..003f9f9 100644 --- a/src/AutoMapper.Extensions.ExpressionMapping/Structures/MapperInfo.cs +++ b/src/AutoMapper.Extensions.ExpressionMapping/Structures/MapperInfo.cs @@ -5,6 +5,7 @@ namespace AutoMapper.Extensions.ExpressionMapping.Structures { public class MapperInfo { + [Obsolete("Use MapperInfo(ParameterExpression newParameter, Type sourceType, Type destType).")] public MapperInfo() { diff --git a/src/AutoMapper.Extensions.ExpressionMapping/XpressionMapperVisitor.cs b/src/AutoMapper.Extensions.ExpressionMapping/XpressionMapperVisitor.cs index c59e4e4..0a96708 100644 --- a/src/AutoMapper.Extensions.ExpressionMapping/XpressionMapperVisitor.cs +++ b/src/AutoMapper.Extensions.ExpressionMapping/XpressionMapperVisitor.cs @@ -13,6 +13,7 @@ namespace AutoMapper.Extensions.ExpressionMapping { public class XpressionMapperVisitor : ExpressionVisitor { + [Obsolete("This constructor is obsolete. Use XpressionMapperVisitor(IMapper mapper, Dictionary typeMappings).")] public XpressionMapperVisitor(IMapper mapper, IConfigurationProvider configurationProvider, Dictionary typeMappings) { Mapper = mapper; @@ -21,6 +22,14 @@ public XpressionMapperVisitor(IMapper mapper, IConfigurationProvider configurati ConfigurationProvider = configurationProvider; } + public XpressionMapperVisitor(IMapper mapper, Dictionary typeMappings) + { + Mapper = mapper; + TypeMappings = typeMappings; + InfoDictionary = new MapperInfoDictionary(new ParameterExpressionEqualityComparer()); + ConfigurationProvider = mapper.ConfigurationProvider; + } + public MapperInfoDictionary InfoDictionary { get; } public Dictionary TypeMappings { get; } diff --git a/tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/AutoMapper.Extensions.ExpressionMapping.UnitTests.csproj b/tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/AutoMapper.Extensions.ExpressionMapping.UnitTests.csproj index 0c58195..ab6b9f5 100644 --- a/tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/AutoMapper.Extensions.ExpressionMapping.UnitTests.csproj +++ b/tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/AutoMapper.Extensions.ExpressionMapping.UnitTests.csproj @@ -3,15 +3,15 @@ net8.0;net10.0 net481;net8.0;net9.0;net10.0 - - false + Exe + false - + all runtime; build; native; contentfiles; analyzers; buildtransitive