<commit_before>namespace AutoMapper
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Context information regarding resolution of a destination value
    /// </summary>
    public class ResolutionContext : IEquatable<ResolutionContext>
    {
        private static readonly ResolutionContext Empty = new ResolutionContext();

        /// <summary>
        /// Mapping operation options
        /// </summary>
        public MappingOperationOptions Options { get; }

        /// <summary>
        /// Current type map
        /// </summary>
        public TypeMap TypeMap { get; }

        /// <summary>
        /// Current property map
        /// </summary>
        public PropertyMap PropertyMap { get; }

        /// <summary>
        /// Initial source type
        /// </summary>
        public Type InitialSourceType { get; }

        /// <summary>
        /// Initial destination type
        /// </summary>
        public Type InitialDestinationType { get; }

        /// <summary>
        /// Current source type
        /// </summary>
        public Type SourceType { get; }

        /// <summary>
        /// Current attempted destination type
        /// </summary>
        public Type DestinationType { get; }

        /// <summary>
        /// Index of current collection mapping
        /// </summary>
        public int? ArrayIndex { get; }

        /// <summary>
        /// Source value
        /// </summary>
        public object SourceValue { get; }

        /// <summary>
        /// Destination value
        /// </summary>
        public object DestinationValue { get; }

        /// <summary>
        /// Parent resolution context
        /// </summary>
        public ResolutionContext Parent { get; }

        /// <summary>
        /// Instance cache for resolving circular references
        /// </summary>
        public Dictionary<ResolutionContext, object> InstanceCache { get; }

        /// <summary>
        /// Current mapping engine
        /// </summary>
        public IMappingEngine Engine { get; }

        private ResolutionContext()
        {
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, object destinationValue, Type sourceType, 
            Type destinationType = null, TypeMap typeMap = null)
        {
            if(context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if(context != Empty)
            {
                Parent = context;
                ArrayIndex = context.ArrayIndex;
                PropertyMap = context.PropertyMap;
                DestinationType = context.DestinationType;
                InstanceCache = context.InstanceCache;
                Options = context.Options;
                Engine = context.Engine;
            }
            SourceValue = sourceValue;
            DestinationValue = destinationValue;
            InitialSourceType = sourceType;
            InitialDestinationType = destinationType;
            TypeMap = typeMap;
            if(typeMap != null)
            {
                SourceType = typeMap.SourceType;
                DestinationType = typeMap.DestinationType;
            }
            else
            {
                SourceType = sourceType;
                DestinationType = destinationType;
            }
        }

        public ResolutionContext(TypeMap typeMap, object source, Type sourceType, Type destinationType,
            MappingOperationOptions options, IMappingEngine engine)
            : this(typeMap, source, null, sourceType, destinationType, options, engine)
        {
        }

        public ResolutionContext(TypeMap typeMap, object source, object destination, Type sourceType,
            Type destinationType, MappingOperationOptions options, IMappingEngine engine)
            : this(Empty, source, destination, sourceType, destinationType, typeMap)
        {
            InstanceCache = new Dictionary<ResolutionContext, object>();
            Options = options;
            Engine = engine;
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, Type sourceType) : this(context, sourceValue, context.DestinationValue, sourceType)
        {
        }

        private ResolutionContext(ResolutionContext context, TypeMap memberTypeMap, object sourceValue,
            object destinationValue, Type sourceType, Type destinationType, int? arrayIndex = null) 
            : this(context, sourceValue, destinationValue, sourceType, destinationType, memberTypeMap)
        {
            ArrayIndex = arrayIndex;
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, object destinationValue,
            TypeMap memberTypeMap, PropertyMap propertyMap) : this(context, sourceValue, destinationValue, null, null, memberTypeMap)
        {
            if(memberTypeMap == null)
            {
                throw new ArgumentNullException(nameof(memberTypeMap));
            }
            PropertyMap = propertyMap;
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, object destinationValue,
            Type sourceType, PropertyMap propertyMap) : this(context, sourceValue, destinationValue, sourceType)
        {
            PropertyMap = propertyMap;
            var destinationMemberType = propertyMap.DestinationProperty.MemberType;
            DestinationType = destinationMemberType == typeof(object) ? sourceType : destinationMemberType;
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, TypeMap typeMap, Type sourceType,
            Type destinationType, int arrayIndex) : this(context, typeMap, sourceValue, null, sourceType, destinationType, arrayIndex)
        {
        }

        public string MemberName => PropertyMap == null
            ? string.Empty
            : (ArrayIndex == null
                ? PropertyMap.DestinationProperty.Name
                : PropertyMap.DestinationProperty.Name + ArrayIndex.Value);<commit_msg>cosmetic<commit_after>namespace AutoMapper
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Context information regarding resolution of a destination value
    /// </summary>
    public class ResolutionContext : IEquatable<ResolutionContext>
    {
        private static readonly ResolutionContext Empty = new ResolutionContext();

        /// <summary>
        /// Mapping operation options
        /// </summary>
        public MappingOperationOptions Options { get; }

        /// <summary>
        /// Current type map
        /// </summary>
        public TypeMap TypeMap { get; }

        /// <summary>
        /// Current property map
        /// </summary>
        public PropertyMap PropertyMap { get; }

        /// <summary>
        /// Initial source type
        /// </summary>
        public Type InitialSourceType { get; }

        /// <summary>
        /// Initial destination type
        /// </summary>
        public Type InitialDestinationType { get; }

        /// <summary>
        /// Current source type
        /// </summary>
        public Type SourceType { get; }

        /// <summary>
        /// Current attempted destination type
        /// </summary>
        public Type DestinationType { get; }

        /// <summary>
        /// Index of current collection mapping
        /// </summary>
        public int? ArrayIndex { get; }

        /// <summary>
        /// Source value
        /// </summary>
        public object SourceValue { get; }

        /// <summary>
        /// Destination value
        /// </summary>
        public object DestinationValue { get; }

        /// <summary>
        /// Parent resolution context
        /// </summary>
        public ResolutionContext Parent { get; }

        /// <summary>
        /// Instance cache for resolving circular references
        /// </summary>
        public Dictionary<ResolutionContext, object> InstanceCache { get; }

        /// <summary>
        /// Current mapping engine
        /// </summary>
        public IMappingEngine Engine { get; }

        private ResolutionContext()
        {
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, object destinationValue, Type sourceType, 
            Type destinationType = null, TypeMap typeMap = null)
        {
            if(context != Empty)
            {
                if(context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }
                Parent = context;
                ArrayIndex = context.ArrayIndex;
                PropertyMap = context.PropertyMap;
                DestinationType = context.DestinationType;
                InstanceCache = context.InstanceCache;
                Options = context.Options;
                Engine = context.Engine;
            }
            SourceValue = sourceValue;
            DestinationValue = destinationValue;
            InitialSourceType = sourceType;
            InitialDestinationType = destinationType;
            TypeMap = typeMap;
            if(typeMap != null)
            {
                SourceType = typeMap.SourceType;
                DestinationType = typeMap.DestinationType;
            }
            else
            {
                SourceType = sourceType;
                DestinationType = destinationType;
            }
        }

        public ResolutionContext(TypeMap typeMap, object source, Type sourceType, Type destinationType,
            MappingOperationOptions options, IMappingEngine engine)
            : this(typeMap, source, null, sourceType, destinationType, options, engine)
        {
        }

        public ResolutionContext(TypeMap typeMap, object source, object destination, Type sourceType,
            Type destinationType, MappingOperationOptions options, IMappingEngine engine)
            : this(Empty, source, destination, sourceType, destinationType, typeMap)
        {
            InstanceCache = new Dictionary<ResolutionContext, object>();
            Options = options;
            Engine = engine;
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, Type sourceType) : this(context, sourceValue, context.DestinationValue, sourceType)
        {
        }

        private ResolutionContext(ResolutionContext context, TypeMap memberTypeMap, object sourceValue,
            object destinationValue, Type sourceType, Type destinationType) 
            : this(context, sourceValue, destinationValue, sourceType, destinationType, memberTypeMap)
        {
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, object destinationValue,
            TypeMap memberTypeMap, PropertyMap propertyMap) : this(context, sourceValue, destinationValue, null, null, memberTypeMap)
        {
            if(memberTypeMap == null)
            {
                throw new ArgumentNullException(nameof(memberTypeMap));
            }
            PropertyMap = propertyMap;
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, object destinationValue,
            Type sourceType, PropertyMap propertyMap) : this(context, sourceValue, destinationValue, sourceType)
        {
            PropertyMap = propertyMap;
            var destinationMemberType = propertyMap.DestinationProperty.MemberType;
            DestinationType = destinationMemberType == typeof(object) ? sourceType : destinationMemberType;
        }

        private ResolutionContext(ResolutionContext context, object sourceValue, TypeMap typeMap, Type sourceType,
            Type destinationType, int arrayIndex) : this(context, sourceValue, null, sourceType, destinationType, typeMap)
        {
            ArrayIndex = arrayIndex;
        }

        public string MemberName => PropertyMap == null
            ? string.Empty
            : (ArrayIndex == null
                ? PropertyMap.DestinationProperty.Name
                : PropertyMap.DestinationProperty.Name + ArrayIndex.Value);
{'fraction_non_alphanumeric': 0.08398517908604364, 'fraction_numerical': 0.0, 'mean_word_length': 1.882297104888467, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4873971', 'n_tokens_mistral': 2735, 'n_tokens_neox': 2636, 'n_words': 739}