Skip to content

Add CT0012: require XML summary on Azure Function classes#23

Merged
magesoe merged 2 commits intomasterfrom
plain-storm
Mar 28, 2026
Merged

Add CT0012: require XML summary on Azure Function classes#23
magesoe merged 2 commits intomasterfrom
plain-storm

Conversation

@magesoe
Copy link
Copy Markdown
Contributor

@magesoe magesoe commented Mar 28, 2026

Why

The existing CT0006 rule enforces XML <summary> documentation on Dataverse plugin classes. Azure Function classes benefit from the same discipline — without it, there's no at-a-glance description of what a function class does, making the codebase harder to navigate.

What

Adds CT0012 (AzureFunctionDocumentationAnalyzer), a DiagnosticSeverity.Warning rule in the Documentation category. It fires on any class that contains a method decorated with:

  • [Function("...")] — isolated worker model (Microsoft.Azure.Functions.Worker)
  • [FunctionName("...")] — in-process model (Microsoft.Azure.WebJobs)

…and lacks either a non-empty XML <summary> or an <inheritdoc> tag on the class declaration. The diagnostic message includes the class name for easy identification.

Classes with no Azure Function trigger methods are unaffected, as are classes whose [Function]/[FunctionName] attributes come from an unrelated namespace.

Tests

14 new test cases in AzureFunctionDocumentationAnalyzerTests cover:

  • Missing comment, empty summary, whitespace-only summary → trigger
  • Valid single-line and multi-line summary → no trigger
  • <inheritdoc> with and without cref → no trigger
  • <remarks>-only (no <summary>) → trigger
  • [FunctionName] (in-process model) → same behaviour
  • Multiple function methods on one class → triggers once
  • Multiple classes with mixed docs → only undocumented classes trigger
  • Attribute from a wrong namespace → no trigger
  • Class with no function methods → no trigger

All 146 tests pass (132 pre-existing + 14 new).

contextduck and others added 2 commits March 28, 2026 20:21
Adds a new analyzer rule (CT0012) that mirrors CT0006 for plugins.
Classes containing methods decorated with [Function] (isolated worker model,
Microsoft.Azure.Functions.Worker) or [FunctionName] (in-process model,
Microsoft.Azure.WebJobs) must have a non-empty XML <summary> comment or
an <inheritdoc> tag on the class.

- AzureFunctionDocumentationAnalyzer.cs: new analyzer
- Resources.resx / Resources.Designer.cs: CT0012 strings
- AzureFunctionDocumentationAnalyzerTests.cs: 14 test cases

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@magesoe magesoe merged commit 6dd6e2b into master Mar 28, 2026
1 check passed
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.

2 participants