Soenneker.Extensions.Object
4.0.4307
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Extensions.Object --version 4.0.4307
NuGet\Install-Package Soenneker.Extensions.Object -Version 4.0.4307
<PackageReference Include="Soenneker.Extensions.Object" Version="4.0.4307" />
<PackageVersion Include="Soenneker.Extensions.Object" Version="4.0.4307" />
<PackageReference Include="Soenneker.Extensions.Object" />
paket add Soenneker.Extensions.Object --version 4.0.4307
#r "nuget: Soenneker.Extensions.Object, 4.0.4307"
#:package Soenneker.Extensions.Object@4.0.4307
#addin nuget:?package=Soenneker.Extensions.Object&version=4.0.4307
#tool nuget:?package=Soenneker.Extensions.Object&version=4.0.4307
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()throwsArgumentNullExceptionand 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 | 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.Constants.Auth (>= 4.0.619)
- Soenneker.Extensions.Enumerable.String (>= 4.0.1421)
- Soenneker.Extensions.Type (>= 4.0.693)
- Soenneker.Utils.Json (>= 4.0.2652)
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 |
Update dependency Soenneker.Extensions.Enumerable.String to 4.0.1418 (#5436)