Soenneker.Extensions.Objects.Reflection 4.0.4

Prefix Reserved
There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Extensions.Objects.Reflection" Version="4.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.Objects.Reflection" Version="4.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.Objects.Reflection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Extensions.Objects.Reflection --version 4.0.4
                    
#r "nuget: Soenneker.Extensions.Objects.Reflection, 4.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Extensions.Objects.Reflection@4.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Extensions.Objects.Reflection&version=4.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.Objects.Reflection&version=4.0.4
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.13 0 9/29/2026
4.0.12 0 9/29/2026
4.0.11 24 9/29/2026
4.0.10 24 9/29/2026
4.0.9 32 9/29/2026
4.0.8 29 9/29/2026
4.0.7 40 9/28/2026
4.0.6 43 9/28/2026
4.0.5 39 9/28/2026
4.0.4 39 9/28/2026