Skip to content
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 @@ -73,7 +73,7 @@ private static string GetMetadataName(INamedTypeSymbol symbol)
protected override string BuildNamespace() => _namedTypeSymbol.ContainingNamespace.GetFullyQualifiedNameFromDisplayString();

protected override IReadOnlyList<AttributeStatement> BuildAttributes()
=> [.._namedTypeSymbol.GetAttributes().Select(a => new AttributeStatement(a))];
=> [.. _namedTypeSymbol.GetAttributes().Select(a => new AttributeStatement(a))];

protected internal override CSharpType[] BuildImplements()
=> [.. _namedTypeSymbol.AllInterfaces.Select(i => i.GetCSharpType())];
Expand Down Expand Up @@ -961,7 +961,7 @@ private static XDocument ParseXml(ISymbol docsSymbol, string xmlDocumentation)
var paramElement = xmlDoc.Descendants("param")
.FirstOrDefault(e => e.Attribute("name")?.Value == parameterSymbol.Name);

return paramElement?.Value.Trim();
return paramElement is null ? null : ProcessXmlContent(paramElement);
}

private static MethodSignatureModifiers GetAccessModifier(Accessibility accessibility) => accessibility switch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ public void MixedContentWithSeeTagsProcessedCorrectly()
Assert.That(description, Contains.Substring("This property represents <see cref=\"System.String\"/> and returns a value."));
}

[Test]
public void ParameterSeeTagsProcessedCorrectly()
{
var model = new ParameterSeeTagsModel();
var compilation = CompilationHelper.LoadCompilation(new[] { model });
var symbol = CompilationHelper.GetSymbol(compilation.Assembly.Modules.First().GlobalNamespace, nameof(ParameterSeeTagsModel));

var provider = new NamedTypeSymbolProvider(symbol!, compilation);
var description = provider.Methods.Single().Signature.Parameters.Single().Description.ToString();

Assert.AreEqual("Works with <see cref=\"System.String\"/> and <see cref=\"System.Int32\"/> types.", description);
}

[Test]
public void InvalidParameterDocsThrows()
{
Expand Down Expand Up @@ -167,11 +180,24 @@ private class InvalidParameterDocsModel : TypeProvider

protected internal override MethodProvider[] BuildMethods()
{
var sig = new MethodSignature("Write", $"", MethodSignatureModifiers.Public, null, $"", [ new ParameterProvider("value", $"This is an invalid description because it is missing closing slash <see cref=\"Y\">", typeof(int)), new ParameterProvider("options", $"", typeof(string)) ]);
var sig = new MethodSignature("Write", $"", MethodSignatureModifiers.Public, null, $"", [new ParameterProvider("value", $"This is an invalid description because it is missing closing slash <see cref=\"Y\">", typeof(int)), new ParameterProvider("options", $"", typeof(string))]);
return [new MethodProvider(sig, Snippet.ThrowExpression(Snippet.Null), this, null)];
}
}

private class ParameterSeeTagsModel : TypeProvider
{
protected override string BuildRelativeFilePath() => ".";

protected override string BuildName() => nameof(ParameterSeeTagsModel);

protected internal override MethodProvider[] BuildMethods()
{
var signature = new MethodSignature("Write", $"", MethodSignatureModifiers.Public, null, $"", [new ParameterProvider("value", $"Works with <see cref=\"T:System.String\"/> and <see cref=\"T:System.Int32\"/> types", typeof(string))]);
return [new MethodProvider(signature, Snippet.ThrowExpression(Snippet.Null), this, null)];
}
}

private class ValidDocsModel : TypeProvider
{
protected override string BuildRelativeFilePath() => ".";
Expand Down
Loading