feat: add IncludePublicFields option to JsonSerializeOptions

Allow the JSON serializer to include public instance fields in the
output in addition to public properties, controlled by the new
JsonSerializeOptions.IncludePublicFields flag (default false to keep
existing behaviour). Field metadata is cached per type like enum and
property reflection lookups.

Closes #3920
This commit is contained in:
dualfroz committed 2026-09-06 02:00:33 +02:00
1 parent b78676e244
commit 209a7d0707
4 files changed
+274 -16

No files matched your search

+6
View File
@@ -104,5 +104,11 @@ namespace NLog.Targets
/// </summary>
/// <remarks>Default: <see langword="10"/></remarks>
public int MaxRecursionLimit { get; set; } = 10;
/// <summary>
/// Should public fields be included in the JSON output, in addition to public properties.
/// </summary>
/// <remarks>Default: <see langword="false"/></remarks>
public bool IncludePublicFields { get; set; }
}
}