Skip to content

fix(annotations): format generic arguments with curly braces in doc cref - #2592

Open
reginaldalfret wants to merge 1 commit into
aws:masterfrom
reginaldalfret:fix/issue-2587-escape-generic-cref
Open

reginaldalfret wants to merge 1 commit into
aws:masterfrom
reginaldalfret:fix/issue-2587-escape-generic-cref

Conversation

@reginaldalfret

Copy link
Copy Markdown

Description

In Amazon.Lambda.Annotations.SourceGenerator, XML documentation comments generated on the Lambda function handler class and method use <see cref="..." referencing the containing type and method signature with parameter types.

When a parameter type or containing type is generic (e.g. IEnumerable<string>, IList<IList<int>>, SqsBatchProcessor<Payload, Handler>), the type name was previously emitted with angle brackets < and > into the XML attribute cref="...". This produces unescaped XML inside an attribute value, leading to CS1570, CS1584, and CS1658 compiler warnings whenever consuming projects have <GenerateDocumentationFile>true</GenerateDocumentationFile> enabled.

In C# XML documentation comments, generic type arguments in cref attributes must use curly braces {...} (e.g. IEnumerable{string}).

Changes

  • In LambdaFunctionTemplateCode.cs, added FormatCrefType(string typeName) which replaces < and > with { and } for types formatted in cref attributes.
  • Updated generator snapshots that include generic parameter types to reflect {} in cref comments.

Fixes #2587

Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
@reginaldalfret
reginaldalfret requested review from a team as code owners October 9, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated XML doc cref contains unescaped generic arguments: CS1584 / CS1658 / CS1570 warnings

1 participant