Skip to content

Commit 590979f

Browse files
committed
Fix cref. Update renderer.
1 parent 35c2306 commit 590979f

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

src/BitzArt.XDoc/Models/Cref.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Cref(string cref)
1919
switch (Prefix)
2020
{
2121
case "T:":
22-
Type = cref.Substring(lastIndexOf + 1, cref.Length - lastIndexOf - 1);
22+
Type = cref.Substring(2, cref.Length - 2);
2323
Member = null;
2424
break;
2525
case "M:" or "P:" or "F:":

src/BitzArt.XDoc/Models/DocumentationReference.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ public class DocumentationReference
2929
/// <param name="target"></param>
3030
/// <param name="crefValue"></param>
3131
public DocumentationReference(XmlNode requirementNode, MemberDocumentation? target, string? crefValue)
32+
: this(requirementNode, target, Cref.TryCreate(crefValue, out var cref) ? cref : null)
33+
{
34+
}
35+
36+
37+
public DocumentationReference(XmlNode requirementNode, MemberDocumentation? target, Cref? cref)
3238
{
3339
Target = target;
3440
RequirementNode = requirementNode;
35-
Cref = Cref.TryCreate(crefValue, out var cref) ? cref : null;
41+
Cref = cref;
3642
}
3743
}

src/BitzArt.XDoc/Models/Members/!TypeMemberDocumentation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public abstract class TypeMemberDocumentation<TMember> : MemberDocumentation
2020
/// <summary>
2121
/// The <see cref="Type"/> that declares the member.
2222
/// </summary>
23-
internal Type DeclaringType => _declaringTypeDocumentation.Type;
23+
public Type DeclaringType => _declaringTypeDocumentation.Type;
2424

2525
/// <summary>
2626
/// Name of the member.

src/EntityFrameworkCore/BitzArt.XDoc.EntityFrameworkCore/Extensions/PropertyBuilderExtensions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public static class PropertyBuilderExtensions
1515
/// Adds a comment to a property being configured, using documentation from XDoc.
1616
/// The comment is extracted from a property defined in the provided expression.
1717
/// </summary>
18-
/// <typeparam name="TEntity">The entity type being configured</typeparam>
19-
/// <typeparam name="TProperty">The type of the property being configured</typeparam>
2018
/// <typeparam name="TCommentTargetEntity">The entity type containing the property whose documentation will be used</typeparam>
2119
/// <typeparam name="TCommentTargetProperty">The type of the property whose documentation will be used</typeparam>
2220
/// <param name="propertyBuilder">The builder for the property</param>
@@ -31,7 +29,7 @@ public static PropertyBuilder HasComment<TCommentTargetEntity, TCommentTargetPro
3129
Expression<Func<TCommentTargetEntity, TCommentTargetProperty>> commentTargetPropertyExpression)
3230
where TCommentTargetEntity : class
3331
{
34-
var comment = xdoc.Get(commentTargetPropertyExpression).ToPlainText();;
32+
var comment = xdoc.Get(commentTargetPropertyExpression).ToPlainText(forceSingleLine: true);
3533

3634
return propertyBuilder.HasComment(comment);
3735
}
@@ -53,7 +51,7 @@ public static PropertyBuilder<TProperty> HasComment<TProperty, TCommentTargetEnt
5351
Expression<Func<TCommentTargetEntity, TCommentTargetProperty>> commentTargetPropertyExpression)
5452
where TCommentTargetEntity : class
5553
{
56-
var comment = xdoc.Get(commentTargetPropertyExpression).ToPlainText();
54+
var comment = xdoc.Get(commentTargetPropertyExpression).ToPlainText(forceSingleLine: true);
5755

5856
return propertyBuilder.HasComment(comment);
5957
}

src/Render/BitzArt.XDoc.PlainText/PlainTextRenderer.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Reflection;
12
using System.Text;
23
using System.Xml;
34

@@ -182,15 +183,26 @@ private string RenderDocumentationReference(DocumentationReference documentation
182183
var text = documentationReference.Target switch
183184
{
184185
TypeDocumentation typeDocumentation => typeDocumentation.Type.Name,
185-
FieldDocumentation fieldDocumentation => fieldDocumentation.MemberName,
186-
PropertyDocumentation propertyDocumentation => propertyDocumentation.MemberName,
187-
MethodDocumentation methodDocumentation => methodDocumentation.MemberName,
186+
FieldDocumentation fieldDocumentation => RenderMember(fieldDocumentation),
187+
PropertyDocumentation propertyDocumentation => RenderMember(propertyDocumentation),
188+
MethodDocumentation methodDocumentation => RenderMember(methodDocumentation),
188189
_ => string.Empty
189190
};
190191

191192
return text;
192193
}
193194

195+
private string RenderMember<T>(TypeMemberDocumentation<T> documentation)
196+
where T : MemberInfo
197+
{
198+
if (_options.UseShortTypeNames)
199+
{
200+
return $"{documentation.DeclaringType.Name}.{documentation.MemberName}";
201+
}
202+
203+
return $"{documentation.DeclaringType.FullName}.{documentation.MemberName}";
204+
}
205+
194206
/// <summary>
195207
/// Renders the content of an XML text node to plain text.
196208
/// </summary>

0 commit comments

Comments
 (0)