budul.LazyDataWriter
2.0.0
dotnet add package budul.LazyDataWriter --version 2.0.0
NuGet\Install-Package budul.LazyDataWriter -Version 2.0.0
<PackageReference Include="budul.LazyDataWriter" Version="2.0.0" />
<PackageVersion Include="budul.LazyDataWriter" Version="2.0.0" />
<PackageReference Include="budul.LazyDataWriter" />
paket add budul.LazyDataWriter --version 2.0.0
#r "nuget: budul.LazyDataWriter, 2.0.0"
#:package budul.LazyDataWriter@2.0.0
#addin nuget:?package=budul.LazyDataWriter&version=2.0.0
#tool nuget:?package=budul.LazyDataWriter&version=2.0.0
LazyDataWriter
File writer for simple data serialization. Serializes plain .NET objects to XML or to SOAP 1.1 envelopes, with optional root element, namespaces, encoding and without XML declaration.
Installation
dotnet add package budul.LazyDataWriter
The package targets net10.0.
Usage
XML
using LazyDataWriter;
var writer = new XmlWriter<Customer>();
string xml = writer.Write(customer);
Constructor variants:
// Custom root element and root namespace
var writer = new XmlWriter<Customer>("customer", "http://example.org/customer");
// Root namespace only, the root element name comes from the type or its XmlRoot attribute
var writer = new XmlWriter<Customer>(rootNamespace: "http://example.org/customer");
// Without XML declaration (the output is indented in this mode)
var writer = new XmlWriter<Customer>(withoutXmlHeader: true);
// Encoding used in the XML declaration, UTF-8 by default
var writer = new XmlWriter<Customer>(encoding: Encoding.GetEncoding("ISO-8859-1"));
Additional namespace prefixes must be registered before the first call of Write:
writer.AddNamespace("http://example.org/extra", "ex");
Code pages beyond UTF-8 and ISO-8859-1 (for example Windows-1252) require CodePagesEncodingProvider to be registered by the caller.
SOAP
var writer = new SoapWriter<TrafficNetworkImportRequest>();
string soap = writer.Write(request);
The content is wrapped in a SOAP 1.1 envelope (soap prefix) with an empty header and the content as body. SoapWriter<T> supports withoutXmlHeader and AddNamespace like XmlWriter<T>.
Migration to 2.0.0
- The target frameworks
netstandard2.0andnetstandard2.1were dropped, the package targetsnet10.0only. Stay on 1.12.x for older runtimes. AddNamespacecalled after the firstWritethrows anInvalidOperationException. Before, the call was silently ignored.- Serializers are cached and writers are safe to use from multiple threads.
Build and test
Requires Visual Studio 2026 and the .NET 10 SDK (see global.json).
dotnet build
dotnet test
Tests use xUnit v3 on Microsoft.Testing.Platform.
License
MIT, see LICENSE.
| 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
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.