- 优化 XML 注释读取支持 interface;

This commit is contained in:
2881099 2022-06-11 20:15:51 +08:00
parent 8b43143eac
commit ab06417bee
3 changed files with 35 additions and 14 deletions

View File

@ -265,6 +265,18 @@ namespace base_entity
public string Name { get; set; } public string Name { get; set; }
} }
interface IDeleteSoft
{
/// <summary>
/// 软删除
/// </summary>
bool IsDeleted { get; set; }
}
class TestComment01 : IDeleteSoft
{
public bool IsDeleted { get; set; }
}
static void Main(string[] args) static void Main(string[] args)
{ {
#region IFreeSql #region IFreeSql
@ -313,6 +325,7 @@ namespace base_entity
BaseEntity.Initialization(fsql, () => _asyncUow.Value); BaseEntity.Initialization(fsql, () => _asyncUow.Value);
#endregion #endregion
fsql.CodeFirst.GetTableByEntity(typeof(TestComment01));
fsql.Select<TUserImg>(); fsql.Select<TUserImg>();

View File

@ -74,6 +74,11 @@
创建日期2 创建日期2
</summary> </summary>
</member> </member>
<member name="P:base_entity.Program.IDeleteSoft.IsDeleted">
<summary>
软删除
</summary>
</member>
<member name="T:EMSServerModel.Model.Role"> <member name="T:EMSServerModel.Model.Role">
<summary> <summary>
角色表 角色表

View File

@ -635,14 +635,16 @@ namespace FreeSql.Internal
if (string.IsNullOrEmpty(comment) == false) dic.Add("", comment); //class注释 if (string.IsNullOrEmpty(comment) == false) dic.Add("", comment); //class注释
} }
var props = localType.GetPropertiesDictIgnoreCase().Values; foreach (var entityType in localType.GetInterfaces().Concat(new[] { localType }))
{
var props = entityType.GetPropertiesDictIgnoreCase().Values;
foreach (var prop in props) foreach (var prop in props)
{ {
className = (prop.DeclaringType.IsNested ? $"{prop.DeclaringType.Namespace}.{prop.DeclaringType.DeclaringType.Name}.{prop.DeclaringType.Name}" : $"{prop.DeclaringType.Namespace}.{prop.DeclaringType.Name}").Trim('.'); className = (prop.DeclaringType.IsNested ? $"{prop.DeclaringType.Namespace}.{prop.DeclaringType.DeclaringType.Name}.{prop.DeclaringType.Name}" : $"{prop.DeclaringType.Namespace}.{prop.DeclaringType.Name}").Trim('.');
node = xmlNav.SelectSingleNode($"/doc/members/member[@name='P:{className}.{prop.Name}']/summary"); node = xmlNav.SelectSingleNode($"/doc/members/member[@name='P:{className}.{prop.Name}']/summary");
if (node == null) if (node == null)
{ {
if (level == 0 && prop.DeclaringType.Assembly != localType.Assembly) if (level == 0 && prop.DeclaringType.Assembly != entityType.Assembly)
{ {
var cbs = LocalGetComment(prop.DeclaringType, level + 1); var cbs = LocalGetComment(prop.DeclaringType, level + 1);
if (cbs != null && cbs.TryGetValue(prop.Name, out var otherComment) && string.IsNullOrEmpty(otherComment) == false) if (cbs != null && cbs.TryGetValue(prop.Name, out var otherComment) && string.IsNullOrEmpty(otherComment) == false)
@ -656,6 +658,7 @@ namespace FreeSql.Internal
dic.Add(prop.Name, comment); dic.Add(prop.Name, comment);
} }
} }
}
return dic; return dic;
} }
} }