budul.LazyDataWriter 2.0.0

dotnet add package budul.LazyDataWriter --version 2.0.0
                    
NuGet\Install-Package budul.LazyDataWriter -Version 2.0.0
                    
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="budul.LazyDataWriter" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="budul.LazyDataWriter" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="budul.LazyDataWriter" />
                    
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 budul.LazyDataWriter --version 2.0.0
                    
#r "nuget: budul.LazyDataWriter, 2.0.0"
                    
#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 budul.LazyDataWriter@2.0.0
                    
#: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=budul.LazyDataWriter&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=budul.LazyDataWriter&version=2.0.0
                    
Install as a Cake Tool

LazyDataWriter

NuGet License: MIT

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.0 and netstandard2.1 were dropped, the package targets net10.0 only. Stay on 1.12.x for older runtimes.
  • AddNamespace called after the first Write throws an InvalidOperationException. 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 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.
  • 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.

Version Downloads Last Updated
2.0.0 67 11/30/2026
1.12.0 759 4/11/2021
1.11.0 616 11/16/2020
1.10.0 647 10/16/2020
1.9.0 691 10/15/2020
1.8.0 638 10/15/2020
1.7.0 614 10/1/2020
1.6.0 634 10/1/2020
1.5.0 602 10/1/2020
1.4.0 682 10/1/2020
1.3.0 620 9/17/2020
1.2.0 677 9/17/2020