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

View File

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

View File

@ -635,25 +635,28 @@ namespace FreeSql.Internal
if (string.IsNullOrEmpty(comment) == false) dic.Add("", comment); //class注释
}
var props = localType.GetPropertiesDictIgnoreCase().Values;
foreach (var prop in props)
foreach (var entityType in localType.GetInterfaces().Concat(new[] { localType }))
{
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");
if (node == null)
var props = entityType.GetPropertiesDictIgnoreCase().Values;
foreach (var prop in props)
{
if (level == 0 && prop.DeclaringType.Assembly != localType.Assembly)
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");
if (node == null)
{
var cbs = LocalGetComment(prop.DeclaringType, level + 1);
if (cbs != null && cbs.TryGetValue(prop.Name, out var otherComment) && string.IsNullOrEmpty(otherComment) == false)
dic.Add(prop.Name, otherComment);
if (level == 0 && prop.DeclaringType.Assembly != entityType.Assembly)
{
var cbs = LocalGetComment(prop.DeclaringType, level + 1);
if (cbs != null && cbs.TryGetValue(prop.Name, out var otherComment) && string.IsNullOrEmpty(otherComment) == false)
dic.Add(prop.Name, otherComment);
}
continue;
}
continue;
}
var comment = node.InnerXml.Trim(' ', '\r', '\n', '\t');
if (string.IsNullOrEmpty(comment)) continue;
var comment = node.InnerXml.Trim(' ', '\r', '\n', '\t');
if (string.IsNullOrEmpty(comment)) continue;
dic.Add(prop.Name, comment);
dic.Add(prop.Name, comment);
}
}
}
return dic;