Soenneker.Extensions.Object 4.0.4306

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.Object --version 4.0.4306
                    
NuGet\Install-Package Soenneker.Extensions.Object -Version 4.0.4306
                    
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.Object" Version="4.0.4306" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.Object" Version="4.0.4306" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.Object" />
                    
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.Object --version 4.0.4306
                    
#r "nuget: Soenneker.Extensions.Object, 4.0.4306"
                    
#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.Object@4.0.4306
                    
#: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.Object&version=4.0.4306
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.Object&version=4.0.4306
                    
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.Object

Reflection-based object projection, query/form encoding, diagnostics, and JSON HttpContent creation.

Installation

dotnet add package Soenneker.Extensions.Object

Build a query string

using Soenneker.Extensions.Object;

string query = new SearchRequest
{
    Page = 2,
    IncludeArchived = false
}.ToQueryString();

// ?page=2&includeArchived=false

ToQueryString() 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.ToDictionary();

ToDictionary() 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.ToHttpContent();
using FormUrlEncodedContent form = request.ToFormUrlEncodedContent();

ToHttpContent() serializes with JsonUtil.WebOptions into application/json; null produces an empty JSON-typed body, not the literal null. ToHttpContentAndString() also returns the serialized text. The WithKey variants add x-api-key to the content headers. The caller owns and must dispose every returned content object.

TryToHttpContent(), TryToHttpContentAndString(), and TryToHttpContentWithKey() return null results and optionally log when conversion fails. They do not log the serialized body, but exception messages may still contain model details.

ToFormUrlEncodedContent() 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 and guards

  • IsObjectNumeric() recognizes the numeric CLR types defined by the companion type extension; null throws.
  • ThrowIfNull() throws ArgumentNullException and uses the calling member name unless a name is supplied.
  • LogNullProperties() reports top-level null public properties.
  • LogNullPropertiesRecursivelyAsJson() traverses application objects and collections, tracks reference cycles, and logs a JSON tree containing only null locations.
  • ToReadableString() 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 ToReadableString() 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 (3)

Showing the top 3 NuGet packages that depend on Soenneker.Extensions.Object:

Package Downloads
Soenneker.Extensions.HttpClient

A collection of helpful HttpClient extension methods, like retry and auto (de)serialization

Soenneker.Blazor.Utils.InteropEventListener

Manages the registration, removal, and disposal of .NET object references used for interop event listeners.

Soenneker.Blazor.ApiClient

A lightweight and efficient API client wrapper for Blazor applications, simplifying HTTP communication with support for asynchronous calls, cancellation tokens, and JSON serialization.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.4310 0 8/30/2026
4.0.4308 0 8/30/2026
4.0.4307 0 8/30/2026
4.0.4306 0 8/30/2026
4.0.4305 0 8/30/2026
4.0.4303 0 8/29/2026
4.0.4302 30 8/29/2026
4.0.4300 55 8/29/2026
4.0.4299 39 8/29/2026
4.0.4298 958 8/26/2026
4.0.4297 434 8/26/2026
4.0.4296 51 8/26/2026
4.0.4295 503 8/26/2026
4.0.4294 36 8/26/2026
4.0.4293 178 8/25/2026
4.0.4292 43 8/25/2026
4.0.4291 1,213 8/22/2026
4.0.4290 560 8/22/2026
4.0.4289 347 8/22/2026
4.0.4287 808 8/21/2026
Loading failed

Escape dynamic query property names