Skip to content

Commit dc735dd

Browse files
committed
fix #308 search sub-namespace
1 parent d0c9c70 commit dc735dd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Mapster.Core/Register/AdaptAttributeBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public AdaptAttributeBuilder ForAllTypesInNamespace(Assembly assembly, string @n
3131
{
3232
foreach (var type in assembly.GetTypes())
3333
{
34-
if (type.Namespace == @namespace && !this.TypeSettings.ContainsKey(type))
34+
if ((type.Namespace == @namespace || type.Namespace?.StartsWith(@namespace + '.') == true) && !this.TypeSettings.ContainsKey(type))
3535
this.TypeSettings.Add(type, new Dictionary<string, PropertySetting>());
3636
}
3737

src/Mapster.Core/Register/GenerateMapperAttributeBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public GenerateMapperAttributeBuilder ForTypes(params Type[] types)
2323

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

0 commit comments

Comments
 (0)