Skip to content

Commit

Permalink
Fixed issue with multi-line documentation. (#3529)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored and tobias-tengler committed Apr 19, 2021
1 parent f9aeac0 commit b1a484d
Show file tree
Hide file tree
Showing 4 changed files with 531 additions and 4 deletions.
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using StrawberryShake.CodeGeneration.CSharp.Builders;
using StrawberryShake.CodeGeneration.CSharp.Extensions;
using StrawberryShake.CodeGeneration.Descriptors;
Expand Down Expand Up @@ -366,10 +367,10 @@ private TryCatchBuilder CreateBuildDataSerialization()
string exception = "ex")
{
string dict = TypeNames.Dictionary.WithGeneric(
TypeNames.String,
TypeNames.String,
TypeNames.Object.MakeNullable());
string body = "response.Body?.ToString()";

string body = "response.Body?.RootElement.ToString()";

MethodCallBuilder createClientError =
MethodCallBuilder
Expand Down
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down Expand Up @@ -85,7 +86,20 @@ public static class SyntaxExtensions
{
if (value is { Length: > 0 })
{
return member.AddSimple(XmlSummaryElement(XmlText(value)));
using var reader = new StringReader(value);
var list = new List<XmlNodeSyntax>();
string? line;

do
{
line = reader.ReadLine();
if(line is not null);
{
list.Add(XmlText(line));
}
} while (line is not null);

return member.AddSimple(XmlSummaryElement(list.ToArray()));
}

return member;
Expand Down
Expand Up @@ -415,5 +415,21 @@ enum Amenity {
}",
"extend schema @key(fields: \"id\")");
}

[Fact]
public void MultiLineDocumentation()
{
AssertResult(
@"query Foo {
abc
}",
@"type Query {
""""""
ABC
DEF
""""""
abc: String
}");
}
}
}

0 comments on commit b1a484d

Please sign in to comment.