Skip to content

Commit cde43b5

Browse files
smbeckermichaelstaib
authored andcommitted
Fix xml method description when dictionary args present (#7765)
1 parent 09211ff commit cde43b5

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ private static MemberName GetMemberElementName(MemberInfo member)
405405
"(`[0-9]+)|(, .*?PublicKeyToken=[0-9a-z]*)",
406406
string.Empty)
407407
.Replace("[[", "{")
408-
.Replace("]]", "}"))
408+
.Replace("]]", "}")
409+
.Replace("],[", ","))
409410
.ToArray());
410411

411412
if (!string.IsNullOrEmpty(paramTypesList))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace HotChocolate.Types.Descriptors;
2+
3+
public class WithDictionaryArgs
4+
{
5+
/// <summary>
6+
/// This is a method description
7+
/// </summary>
8+
/// <param name="args">Args description</param>
9+
/// <returns></returns>
10+
public string Method(Dictionary<string, string>? args = null) => string.Empty;
11+
}

src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/XmlDocumentationProviderTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,4 +414,20 @@ public void When_method_has_no_returns_then_it_is_ignored()
414414
// assert
415415
methodDescription.MatchSnapshot();
416416
}
417+
418+
[Fact]
419+
public void When_method_has_dictionary_args_then_it_is_found()
420+
{
421+
// arrange
422+
var documentationProvider = new XmlDocumentationProvider(
423+
new XmlDocumentationFileResolver(),
424+
new NoOpStringBuilderPool());
425+
426+
// act
427+
var methodDescription = documentationProvider.GetDescription(
428+
typeof(WithDictionaryArgs).GetMethod(nameof(WithDictionaryArgs.Method))!);
429+
430+
// assert
431+
Assert.Equal("This is a method description", methodDescription);
432+
}
417433
}

0 commit comments

Comments
 (0)