Soenneker.Extensions.Objects.Reflection
4.0.4
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Extensions.Objects.Reflection --version 4.0.4
NuGet\Install-Package Soenneker.Extensions.Objects.Reflection -Version 4.0.4
<PackageReference Include="Soenneker.Extensions.Objects.Reflection" Version="4.0.4" />
<PackageVersion Include="Soenneker.Extensions.Objects.Reflection" Version="4.0.4" />
<PackageReference Include="Soenneker.Extensions.Objects.Reflection" />
paket add Soenneker.Extensions.Objects.Reflection --version 4.0.4
#r "nuget: Soenneker.Extensions.Objects.Reflection, 4.0.4"
#:package Soenneker.Extensions.Objects.Reflection@4.0.4
#addin nuget:?package=Soenneker.Extensions.Objects.Reflection&version=4.0.4
#tool nuget:?package=Soenneker.Extensions.Objects.Reflection&version=4.0.4
Soenneker.Extensions.Objects.Reflection
Reflection-based object projection, query/form encoding, diagnostics, and JSON HttpContent creation.
Installation
dotnet add package Soenneker.Extensions.Objects.Reflection
Build a query string
using Soenneker.Extensions.Objects.Reflection;
string query = new SearchRequest
{
Page = 2,
IncludeArchived = false
}.ToQueryStringViaCachedReflection();
// ?page=2&includeArchived=false
ToQueryStringViaCachedReflection() uses readable public instance properties, [JsonPropertyName] or web-default camelCase names, and percent-escapes both names and values. It honors [JsonIgnore] conditions, formats scalar values invariantly, and JSON-formats other values before escaping. A null object or an object with no included values returns an empty string.
ToQueryStringViaReflection() is the simpler legacy path: it uses CLR property names, optionally lowercases them, calls ToString() under the current culture, skips nulls, and escapes names and values. Both methods prepend ? when at least one pair is emitted.
Project properties
Dictionary<string, object?> values = model.ToDictionaryViaReflection();
ToDictionaryViaReflection() includes only readable, non-indexed public properties declared directly on the runtime type. [JsonPropertyName] controls keys; inherited properties are excluded. Values are not serialized or cloned. A null source returns a new empty dictionary.
Create request bodies
using HttpContent json = request.ToHttpContentViaReflection();
using FormUrlEncodedContent form = request.ToFormUrlEncodedContentViaReflection();
ToHttpContentViaReflection() serializes with JsonUtil.WebOptions into application/json; null produces an empty JSON-typed body, not the literal null. The caller owns and must dispose every returned content object.
ToFormUrlEncodedContentViaReflection() includes readable public properties, honors [JsonPropertyName], skips nulls, formats IFormattable values invariantly, and lets FormUrlEncodedContent perform encoding. Nested objects and collections are converted through ToString() rather than flattened.
Diagnostics
LogNullPropertiesViaReflection()reports top-level null public properties.LogNullPropertiesRecursivelyAsJsonViaReflection()traverses application objects and collections, tracks reference cycles, and logs a JSON tree containing only null locations.ToReadableStringViaReflection()recursively renders public properties for human diagnostics.
Reflection getters and custom ToString() implementations can execute user code and throw. Diagnostic output can contain secrets or personal data, and ToReadableStringViaReflection() does not protect against reference cycles; use these helpers only with known model types and appropriate logging destinations.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Soenneker.Extensions.Enumerable.String (>= 4.0.1466)
- Soenneker.Extensions.String (>= 4.0.767)
- Soenneker.Utils.Json (>= 4.0.2725)
- Soenneker.Utils.PooledStringBuilders (>= 4.0.33)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.17 | 0 | 9/30/2026 |
| 4.0.16 | 0 | 9/30/2026 |
| 4.0.15 | 0 | 9/30/2026 |
| 4.0.14 | 0 | 9/30/2026 |
| 4.0.13 | 39 | 9/29/2026 |
| 4.0.12 | 28 | 9/29/2026 |
| 4.0.11 | 30 | 9/29/2026 |
| 4.0.10 | 29 | 9/29/2026 |
| 4.0.9 | 34 | 9/29/2026 |
| 4.0.8 | 32 | 9/29/2026 |
| 4.0.7 | 43 | 9/28/2026 |
| 4.0.6 | 44 | 9/28/2026 |
| 4.0.5 | 40 | 9/28/2026 |
| 4.0.4 | 40 | 9/28/2026 |