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
@@ -0,0 +1,29 @@
codeunit 50100 MyCodeunit
{
/// <summary>
/// Param tag without name attribute on procedure with parameters.
/// </summary>
/// [|<param></param>|]
procedure WithParameter([|Value: Boolean|])
begin

end;

/// <summary>
/// Param tag without name attribute on procedure without parameters.
/// </summary>
/// [|<param></param>|]
procedure WithoutParameter()
begin

end;

/// <summary>
/// Param tag without name attribute on procedure with parameters.
/// </summary>
/// [|<param>|]
procedure WithParameterAlsoInvalid([|Value: Boolean|])
begin

end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void Setup()
[TestCase("DuplicateParameter")]
[TestCase("DuplicateReturns")]
[TestCase("TryFunction")]
[TestCase("ParamWithoutNameAttribute")]
public async Task HasDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCasePath, nameof(HasDiagnostic), $"{testCase}.al"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private void AnalyzeDocumentationComments(SyntaxNodeAnalysisContext ctx)
return;

var docCommentTrivia = methodDeclarationSyntax.GetLeadingTrivia().FirstOrDefault(trivia => trivia.Kind == EnumProvider.SyntaxKind.SingleLineDocumentationCommentTrivia);

if (docCommentTrivia.IsKind(EnumProvider.SyntaxKind.None))
return; // no documentation comment exists

Expand All @@ -41,8 +42,17 @@ private void AnalyzeDocumentationComments(SyntaxNodeAnalysisContext ctx)
switch (element.StartTag.Name.LocalName.Text.ToLowerInvariant())
{
case "param":
var nameAttribute = (XmlNameAttributeSyntax)element.StartTag.Attributes.First(att => att.IsKind(EnumProvider.SyntaxKind.XmlNameAttribute));
var nameAttributeSyntax = element.StartTag.Attributes.FirstOrDefault(att => att.IsKind(EnumProvider.SyntaxKind.XmlNameAttribute));

if (nameAttributeSyntax is null)
{
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.XmlDocumentationProcedureConsistency, element.GetLocation()));
break;
}

var nameAttribute = (XmlNameAttributeSyntax)nameAttributeSyntax;
var parameterName = nameAttribute.Identifier.GetText().ToString();

if (!docCommentParameters.ContainsKey(parameterName))
docCommentParameters.Add(parameterName, element);
else
Expand All @@ -53,6 +63,7 @@ private void AnalyzeDocumentationComments(SyntaxNodeAnalysisContext ctx)
if (docCommentReturns is not null)
// report diagnostic for duplicate returns documentation
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.XmlDocumentationProcedureConsistency, element.GetLocation()));

docCommentReturns = element;
break;
}
Expand Down
Loading