Skip to content

Commit

Permalink
feat: refactor, rename to MaxRecursiveDepth
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison committed Nov 9, 2023
1 parent 1b0a385 commit fc56f3c
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/Riok.Mapperly.Abstractions/MapperAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ public class MapperAttribute : Attribute
/// <summary>
/// Defines the maximum recursive depth that an IQueryable mapping will use.
/// </summary>
public int RecursiveDepth { get; set; } = 8;
public int MaxRecursiveDepth { get; set; } = 8;

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / sample

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / sample

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / package

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / package

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / SourceGeneratorBenchmarks

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / SourceGeneratorBenchmarks

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / MappingBenchmarks

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / MappingBenchmarks

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 104 in src/Riok.Mapperly.Abstractions/MapperAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MaxRecursiveDepth.set' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
}
22 changes: 22 additions & 0 deletions src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Riok.Mapperly.Abstractions;

/// <summary>
/// Defines the maximum recursive depth that an IQueryable mapping will use.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class MapperMaxRecursiveDepthAttribute : Attribute

Check warning on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / sample

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / package

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / SourceGeneratorBenchmarks

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / MappingBenchmarks

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 7 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
{
/// <summary>
/// Defines the maximum recursive depth that an IQueryable mapping will use.
/// </summary>
/// <param name="maxRecursiveDepth">The maximum recursive depth used when mapping IQueryable members.</param>
public MapperMaxRecursiveDepthAttribute(int maxRecursiveDepth)

Check warning on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / sample

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / package

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / SourceGeneratorBenchmarks

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / MappingBenchmarks

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 13 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MapperMaxRecursiveDepthAttribute' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
{
MaxRecursiveDepth = maxRecursiveDepth;
}

/// <summary>
/// The maximum recursive depth used when mapping IQueryable members.
/// </summary>
public int MaxRecursiveDepth { get; }

Check warning on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / sample

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / test

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / package

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / SourceGeneratorBenchmarks

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / MappingBenchmarks

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / build

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 21 in src/Riok.Mapperly.Abstractions/MapperMaxRecursiveDepthAttribute.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Symbol 'MaxRecursiveDepth.get' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
}
22 changes: 0 additions & 22 deletions src/Riok.Mapperly.Abstractions/MapperRecursiveDepth.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Riok.Mapperly/Configuration/MapperConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ public record MapperConfiguration
/// <summary>
/// Defines the maximum recursive depth that an IQueryable mapping will use.
/// </summary>
public int? RecursiveDepth { get; init; }
public int? MaxRecursiveDepth { get; init; }
}
3 changes: 2 additions & 1 deletion src/Riok.Mapperly/Configuration/MapperConfigurationMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public static MapperAttribute Merge(MapperConfiguration mapperConfiguration, Map
mapper.IncludedMembers =
mapperConfiguration.IncludedMembers ?? defaultMapperConfiguration.IncludedMembers ?? mapper.IncludedMembers;

mapper.RecursiveDepth = mapperConfiguration.RecursiveDepth ?? defaultMapperConfiguration.RecursiveDepth ?? mapper.RecursiveDepth;
mapper.MaxRecursiveDepth =
mapperConfiguration.MaxRecursiveDepth ?? defaultMapperConfiguration.MaxRecursiveDepth ?? mapper.MaxRecursiveDepth;

return mapper;
}
Expand Down
11 changes: 6 additions & 5 deletions src/Riok.Mapperly/Configuration/MapperConfigurationReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ MapperConfiguration defaultMapperConfiguration
Array.Empty<PropertyMappingConfiguration>(),
Mapper.IgnoreObsoleteMembersStrategy,
Mapper.RequiredMappingStrategy,
Mapper.RecursiveDepth
Mapper.MaxRecursiveDepth
),
Array.Empty<DerivedTypeMappingConfiguration>()
);
Expand Down Expand Up @@ -80,17 +80,18 @@ private PropertiesMappingConfiguration BuildPropertiesConfig(IMethodSymbol metho
var requiredMapping = _dataAccessor.Access<MapperRequiredMappingAttribute>(method).FirstOrDefault() is not { } methodWarnUnmapped
? _defaultConfiguration.Properties.RequiredMappingStrategy
: methodWarnUnmapped.RequiredMappingStrategy;
var recursiveDepth = _dataAccessor.Access<MapperRecursiveDepthAttribute>(method).FirstOrDefault() is not { } methodRecursiveDepth
? _defaultConfiguration.Properties.RecursiveDepth
: methodRecursiveDepth.RecursiveDepth;
var maxRecursiveDepth = _dataAccessor.Access<MapperMaxRecursiveDepthAttribute>(method).FirstOrDefault()
is not { } methodMaxRecursiveDepth
? _defaultConfiguration.Properties.MaxRecursiveDepth
: methodMaxRecursiveDepth.MaxRecursiveDepth;

return new PropertiesMappingConfiguration(
ignoredSourceProperties,
ignoredTargetProperties,
explicitMappings,
ignoreObsolete,
requiredMapping,
recursiveDepth
maxRecursiveDepth
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public record PropertiesMappingConfiguration(
IReadOnlyCollection<PropertyMappingConfiguration> ExplicitMappings,
IgnoreObsoleteMembersStrategy IgnoreObsoleteMembersStrategy,
RequiredMappingStrategy RequiredMappingStrategy,
int RecursiveDepth
int MaxRecursiveDepth
);
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class InlineExpressionMappingBuilderContext : MappingBuilderContext
{
private readonly MappingCollection _inlineExpressionMappings;
private readonly MappingBuilderContext _parentContext;
private readonly ImmutableDictionary<(ISymbol, ISymbol), int> _parentTypes;
private readonly ImmutableDictionary<TypeMappingKey, int> _parentTypes;

public InlineExpressionMappingBuilderContext(MappingBuilderContext ctx, ITypeSymbol sourceType, ITypeSymbol targetType)
: this(ctx, (ctx.FindMapping(sourceType, targetType) as IUserMapping)?.Method, sourceType, targetType) { }
Expand All @@ -34,13 +34,13 @@ ITypeSymbol target

_parentTypes = ctx is InlineExpressionMappingBuilderContext inlineCtx
? inlineCtx._parentTypes
: ImmutableDictionary.Create<(ISymbol, ISymbol), int>(new SymbolTupleEqualityComparer());
: ImmutableDictionary.Create<TypeMappingKey, int>();
}

private InlineExpressionMappingBuilderContext(
InlineExpressionMappingBuilderContext ctx,
IMethodSymbol? userSymbol,
ImmutableDictionary<(ISymbol, ISymbol), int> parentTypes,
ImmutableDictionary<TypeMappingKey, int> parentTypes,
ITypeSymbol source,
ITypeSymbol target,
bool clearDerivedTypes
Expand Down Expand Up @@ -73,9 +73,9 @@ conversionType is not MappingConversionType.EnumToString and not MappingConversi
public override INewInstanceMapping? FindMapping(ITypeSymbol sourceType, ITypeSymbol targetType)
{
// check for recursive loop returning null to prevent a loop or default when recursive limit is reached.
if (_parentTypes.TryGetValue((sourceType, targetType), out var count))
if (_parentTypes.TryGetValue(new(sourceType, targetType), out var count))
{
return count >= Configuration.Properties.RecursiveDepth ? new DefaultMemberMapping(sourceType, targetType) : null;
return count >= Configuration.Properties.MaxRecursiveDepth ? new DefaultMemberMapping(sourceType, targetType) : null;
}

if (_inlineExpressionMappings.Find(sourceType, targetType) is { } mapping)
Expand Down Expand Up @@ -170,9 +170,8 @@ protected override MappingBuilderContext ContextForMapping(
MappingBuildingOptions options
)
{
var newParentTypes = _parentTypes.TryGetValue((sourceType, targetType), out var count)
? _parentTypes.SetItem((sourceType, targetType), count + 1)
: _parentTypes.SetItem((sourceType, targetType), 1);
var mappingRecursionCount = _parentTypes.GetValueOrDefault(new(sourceType, targetType));
var newParentTypes = _parentTypes.SetItem(new(sourceType, targetType), mappingRecursionCount + 1);
return new InlineExpressionMappingBuilderContext(
this,
userSymbol,
Expand Down
19 changes: 0 additions & 19 deletions src/Riok.Mapperly/Helpers/SymbolTupleEqualityComparer.cs

This file was deleted.

0 comments on commit fc56f3c

Please sign in to comment.