Skip to content

Commit

Permalink
Fix xml method description when dictionary args present (#7765)
Browse files Browse the repository at this point in the history
  • Loading branch information
smbecker authored and michaelstaib committed Nov 29, 2024
1 parent 09211ff commit cde43b5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace HotChocolate.Types.Descriptors;

public class WithDictionaryArgs
{
/// <summary>
/// This is a method description
/// </summary>
/// <param name="args">Args description</param>
/// <returns></returns>
public string Method(Dictionary<string, string>? args = null) => string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit cde43b5

Please sign in to comment.