Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for paramref elements in the XmlDocumentationProvider #6855

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
private const string _cref = "cref";
private const string _href = "href";
private const string _code = "code";
private const string _paramref = "paramref";
private const string _name = "name";

private readonly IXmlDocumentationFileResolver _fileResolver;
private readonly ObjectPool<StringBuilder> _stringBuilderPool;
Expand Down Expand Up @@ -164,6 +166,17 @@
continue;
}

if (currentElement.Name == _paramref)
{

Check warning on line 170 in src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs

View check run for this annotation

Codecov / codecov/patch

src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs#L169-L170

Added lines #L169 - L170 were not covered by tests
var nameAttribute = currentElement.Attribute(_name);

if (nameAttribute != null)
{
description.Append(nameAttribute.Value);
continue;
}

Check warning on line 177 in src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs

View check run for this annotation

Codecov / codecov/patch

src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs#L173-L177

Added lines #L173 - L177 were not covered by tests
}

if (currentElement.Name != _see)
{
description.Append(currentElement.Value);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HotChocolate.Types.Descriptors
{
public class WithParamrefTagInXmlDoc
{
/// <summary>
/// This is a parameter reference to <paramref name="id"/>.
/// </summary>
public int Foo(int id) => id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ public void When_description_has_see_tag_then_it_is_converted()
description);
}

[Fact]
public void When_description_has_paramref_tag_then_it_is_converted()
{
// arrange
var documentationProvider = new XmlDocumentationProvider(
new XmlDocumentationFileResolver(),
new NoOpStringBuilderPool());

// act
var description = documentationProvider.GetDescription(
typeof(WithParamrefTagInXmlDoc)
.GetMethod(nameof(WithParamrefTagInXmlDoc.Foo))!);

// assert
Assert.Equal(
"This is a parameter reference to id.",
description);
}

[Fact]
public void When_description_has_generic_tags_then_it_is_converted()
{
Expand Down
Loading