-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve fullnameof and allow namespaced and nested types
- Loading branch information
Showing
24 changed files
with
299 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Riok.Mapperly/Configuration/IMemberPathConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Riok.Mapperly.Configuration; | ||
|
||
/// <summary> | ||
/// A user-configured member path. | ||
/// </summary> | ||
public interface IMemberPathConfiguration | ||
{ | ||
/// <summary> | ||
/// The name of the root member. | ||
/// </summary> | ||
string RootName { get; } | ||
|
||
/// <summary> | ||
/// The full name e.g. A.B.C | ||
/// </summary> | ||
string FullName { get; } | ||
|
||
/// <summary> | ||
/// The number of path segments in this path. | ||
/// </summary> | ||
int PathCount { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Riok.Mapperly.Configuration; | ||
|
||
internal static class MemberPathConstants | ||
{ | ||
public const char MemberAccessSeparator = '.'; | ||
public const string MemberAccessSeparatorString = "."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Riok.Mapperly/Configuration/NestedMembersMappingConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
namespace Riok.Mapperly.Configuration; | ||
|
||
public record NestedMembersMappingConfiguration(StringMemberPath Source); | ||
public record NestedMembersMappingConfiguration(IMemberPathConfiguration Source); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Riok.Mapperly.Helpers; | ||
|
||
namespace Riok.Mapperly.Configuration; | ||
|
||
/// <summary> | ||
/// A configured member path consisting of resolved symbols. | ||
/// </summary> | ||
/// <param name="Path">The path.</param> | ||
public record SymbolMemberPath(ImmutableEquatableArray<ISymbol> Path) : IMemberPathConfiguration | ||
{ | ||
private string? _fullName; | ||
|
||
public string RootName => Path[0].Name; | ||
public string FullName => _fullName ??= string.Join(MemberPathConstants.MemberAccessSeparatorString, Path.Select(x => x.Name)); | ||
public int PathCount => Path.Count; | ||
|
||
public override string ToString() => FullName; | ||
|
||
public StringMemberPath ToStringMemberPath() => new(Path.Select(x => x.Name)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.