Visitar URL original
docs: document default values for Filters properties in XML docs by dualfroz · Pull Request #6275 · NLog/NLog · GitHub
Skip to content

docs: document default values for Filters properties in XML docs - #6275

Merged
snakefoot merged 1 commit into
NLog:devfrom
dualfroz:feat/filters-default-value-xml-docs-5917
Sep 5, 2026
Merged

snakefoot merged 1 commit into
NLog:devfrom
dualfroz:feat/filters-default-value-xml-docs-5917

Conversation

@dualfroz

@dualfroz dualfroz commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Base: NLog:dev <- dualfroz:feat/filters-default-value-xml-docs-5917

Refs #5917

Summary

#5917 asked for property default values to be visible in the generated XML
docs (Sandcastle docs / IntelliSense), not just in the source code. Three
PRs already landed for this (#5919 Targets and Layouts, #5922
LayoutRenderers, #5925 Target Wrappers), but the issue itself is still
open and the NLog.Filters namespace was never covered - none of its
properties document a default value.

This PR applies the same documented convention (<remarks>Default: ...,
and <b>[Required]</b> for properties a filter cannot function without)
to every settable property in NLog.Filters:

  • Filter.Action
  • ConditionBasedFilter.Condition
  • LayoutBasedFilter.Layout
  • WhenContainsFilter.IgnoreCase, .Substring
  • WhenEqualFilter.IgnoreCase, .CompareTo
  • WhenNotContainsFilter.Substring, .IgnoreCase
  • WhenNotEqualFilter.CompareTo, .IgnoreCase
  • WhenRepeatedFilter.TimeoutSeconds, .MaxLength, .IncludeFirst,
    .MaxFilterCacheSize, .DefaultFilterCacheSize,
    .FilterCountPropertyName, .FilterCountMessageAppendFormat,
    .OptimizeBufferDefaultLength

WhenRepeatedFilter.OptimizeBufferReuse is intentionally left alone -
it's [Obsolete] since NLog 5.0 and always returns true, so there is
no meaningful default left to document.

Regression test

FilterDefaultValueDocsTests.SettablePropertiesDocumentDefaultValue
loads the XML doc file generated alongside NLog.dll
(GenerateDocumentationFile is already on for the project), then
reflects over every public settable property under NLog.Filters and
asserts its doc entry contains Default:. It fails for any current or
future property in that namespace that skips documenting its default,
not just the ones touched here.

How to verify

dotnet test tests/NLog.UnitTests/NLog.UnitTests.csproj -f net8.0 -c Debug --filter "FullyQualifiedName~FilterDefaultValueDocsTests"

SDK: 9.0.317 (net8.0 runtime 8.0.30 installed alongside for the test host).

Result: 1/1 passed with the fix in place. Reverting the src/NLog/Filters/*.cs
changes (test file kept) makes the same test fail with 19 missing
properties reported, confirming it actually catches the regression.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 7e59b6c7-a201-4170-8dfb-35a9e6d05395

📥 Commits

Reviewing files that changed from the base of the PR and between a084ce2 and 0302a60.

📒 Files selected for processing (9)
  • src/NLog/Filters/ConditionBasedFilter.cs
  • src/NLog/Filters/Filter.cs
  • src/NLog/Filters/LayoutBasedFilter.cs
  • src/NLog/Filters/WhenContainsFilter.cs
  • src/NLog/Filters/WhenEqualFilter.cs
  • src/NLog/Filters/WhenNotContainsFilter.cs
  • src/NLog/Filters/WhenNotEqualFilter.cs
  • src/NLog/Filters/WhenRepeatedFilter.cs
  • tests/NLog.UnitTests/Filters/FilterDefaultValueDocsTests.cs

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


Walkthrough

The change adds default-value XML documentation to filter properties and introduces a unit test that verifies public, settable filter properties include this documentation.

Changes

Filter default documentation

Layer / File(s) Summary
Document filter property defaults
src/NLog/Filters/*.cs
Filter properties now document their default values and required settings.
Validate documented defaults
tests/NLog.UnitTests/Filters/FilterDefaultValueDocsTests.cs
A test checks generated XML documentation for default values on public, settable, non-obsolete filter properties.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 0302a

This change documents existing filter-property defaults and adds validation for that documentation without changing filter behavior. No current merge-blocking risk is identified.

Poem

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: documenting default values for filter properties in XML documentation.
Description check ✅ Passed The description is directly related to the changeset. It explains the XML documentation updates, required-property annotations, excluded obsolete property, regression test, and verification result.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Continues the work started for NLog#5917 (already covered Targets, Layouts,
LayoutRenderers and Target Wrappers), extending the same pattern to the
NLog.Filters namespace so default values show up in IntelliSense and the
generated API docs.

Adds a regression test that scans all settable NLog.Filters properties
against the generated XML documentation file and fails if any of them is
missing a documented default value.
@dualfroz
dualfroz force-pushed the feat/filters-default-value-xml-docs-5917 branch from 0302a60 to 2296440 Compare September 5, 2026 16:38
@pull-request-size pull-request-size Bot added size/S and removed size/L labels Sep 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

@snakefoot

Copy link
Copy Markdown
Contributor

Thank you so much for the contribution, very much appreciated.

Like your idea about having an unit-test to ensure future developments also includes minimum documentation.

@snakefoot
snakefoot merged commit e0b0613 into NLog:dev Sep 5, 2026
6 checks passed
@snakefoot snakefoot added this to the 6.2.1 milestone Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants