From cde43b5b118c5cf5de8b60013f22fb83664a1c56 Mon Sep 17 00:00:00 2001 From: Shaun Becker Date: Wed, 27 Nov 2024 06:52:47 -0500 Subject: [PATCH] Fix xml method description when dictionary args present (#7765) --- .../Conventions/XmlDocumentationProvider.cs | 3 ++- .../WithDictionaryArgs.cs | 11 +++++++++++ .../Conventions/XmlDocumentationProviderTests.cs | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/HotChocolate/Core/test/Types.Tests.Documentation/WithDictionaryArgs.cs diff --git a/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs b/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs index e8bf71564a1..0aa7b82a01a 100644 --- a/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs +++ b/src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/XmlDocumentationProvider.cs @@ -405,7 +405,8 @@ private static MemberName GetMemberElementName(MemberInfo member) "(`[0-9]+)|(, .*?PublicKeyToken=[0-9a-z]*)", string.Empty) .Replace("[[", "{") - .Replace("]]", "}")) + .Replace("]]", "}") + .Replace("],[", ",")) .ToArray()); if (!string.IsNullOrEmpty(paramTypesList)) diff --git a/src/HotChocolate/Core/test/Types.Tests.Documentation/WithDictionaryArgs.cs b/src/HotChocolate/Core/test/Types.Tests.Documentation/WithDictionaryArgs.cs new file mode 100644 index 00000000000..31b24e49656 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Tests.Documentation/WithDictionaryArgs.cs @@ -0,0 +1,11 @@ +namespace HotChocolate.Types.Descriptors; + +public class WithDictionaryArgs +{ + /// + /// This is a method description + /// + /// Args description + /// + public string Method(Dictionary? args = null) => string.Empty; +} diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/XmlDocumentationProviderTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/XmlDocumentationProviderTests.cs index 8f8788622dd..7b9fbc52f91 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/XmlDocumentationProviderTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/Conventions/XmlDocumentationProviderTests.cs @@ -414,4 +414,20 @@ public void When_method_has_no_returns_then_it_is_ignored() // assert methodDescription.MatchSnapshot(); } + + [Fact] + public void When_method_has_dictionary_args_then_it_is_found() + { + // arrange + var documentationProvider = new XmlDocumentationProvider( + new XmlDocumentationFileResolver(), + new NoOpStringBuilderPool()); + + // act + var methodDescription = documentationProvider.GetDescription( + typeof(WithDictionaryArgs).GetMethod(nameof(WithDictionaryArgs.Method))!); + + // assert + Assert.Equal("This is a method description", methodDescription); + } }