Skip to content

Commit

Permalink
fix MapsterMapper#308 search sub-namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
chaowlert committed Feb 24, 2021
1 parent d0c9c70 commit dc735dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Mapster.Core/Register/AdaptAttributeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AdaptAttributeBuilder ForAllTypesInNamespace(Assembly assembly, string @n
{
foreach (var type in assembly.GetTypes())
{
if (type.Namespace == @namespace && !this.TypeSettings.ContainsKey(type))
if ((type.Namespace == @namespace || type.Namespace?.StartsWith(@namespace + '.') == true) && !this.TypeSettings.ContainsKey(type))
this.TypeSettings.Add(type, new Dictionary<string, PropertySetting>());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public GenerateMapperAttributeBuilder ForTypes(params Type[] types)

public GenerateMapperAttributeBuilder ForAllTypesInNamespace(Assembly assembly, string @namespace)
{
this.Types.UnionWith(assembly.GetTypes().Where(it => it.Namespace == @namespace));
this.Types.UnionWith(assembly.GetTypes().Where(it => it.Namespace == @namespace || it.Namespace?.StartsWith(@namespace + '.') == true));
return this;
}

Expand Down

0 comments on commit dc735dd

Please sign in to comment.