War3Net.Common 6.0.1

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

War3Net.Common

About

War3Net.Common provides shared utilities for the War3Net modding library. It contains extension methods, encoding providers, and type conversion utilities commonly used when working with Warcraft III binary file formats.

Key features

  • Extension methods for BinaryReader and BinaryWriter to handle Warcraft III-specific data types
  • Rawcode conversion between 4-character strings and 32-bit integers
  • Type-safe enum conversion with validation for binary data parsing
  • Stream utilities for efficient copying and reading operations
  • Color format conversions (RGBA, BGRA)
  • Pre-configured UTF-8 encoding providers without byte order marks

How to Use

Convert rawcodes

Warcraft III uses 4-character "rawcodes" to identify units, abilities, and other objects. These are stored as 32-bit integers in binary files.

using War3Net.Common.Extensions;

// Convert a rawcode string to integer
int unitId = "hpea".FromRawcode(); // Human Peasant

// Convert an integer back to rawcode string
string rawcode = unitId.ToRawcode(); // "hpea"

Read binary data with extension methods

using System.IO;
using War3Net.Common.Extensions;

using var reader = new BinaryReader(stream);

// Read a null-terminated UTF-8 string
string name = reader.ReadChars();

// Read a fixed-length string
string fixedString = reader.ReadString(32);

// Read a 32-bit boolean (0 or 1)
bool enabled = reader.ReadBool();

// Read color values
Color rgbaColor = reader.ReadColorRgba();
Color bgraColor = reader.ReadColorBgra();

// Read typed enum values
MyEnum value = reader.ReadInt32<MyEnum>();

Type-safe enum conversion

using War3Net.Common;

// Convert raw binary values to enums with validation
var myEnum = EnumConvert<MyEnum>.FromInt32(value);

// Use raw conversion when validation is not needed
var rawEnum = EnumConvert<MyEnum>.FromInt32Raw(value);

Use UTF-8 encoding without BOM

using War3Net.Common.Providers;

// Lenient encoding (does not throw on invalid bytes)
Encoding utf8 = UTF8EncodingProvider.UTF8;

// Strict encoding (throws on invalid bytes)
Encoding strictUtf8 = UTF8EncodingProvider.StrictUTF8;

Main Types

The main types provided by this library are:

  • War3Net.Common.EnumConvert<TEnum> - Type-safe conversion from primitive types to enums with validation
  • War3Net.Common.Extensions.BinaryReaderExtensions - Extension methods for reading Warcraft III data types
  • War3Net.Common.Extensions.BinaryWriterExtensions - Extension methods for writing Warcraft III data types
  • War3Net.Common.Extensions.StreamExtensions - Extension methods for stream operations
  • War3Net.Common.Extensions.Int32Extensions - Rawcode and color conversion from integers
  • War3Net.Common.Extensions.StringExtensions - Rawcode conversion from strings
  • War3Net.Common.Providers.UTF8EncodingProvider - Pre-configured UTF-8 encodings

Feedback and contributing

War3Net.Common is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Disclaimer

This README was generated with the assistance of AI and may contain inaccuracies. Please verify the information and consult the source code for authoritative details.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (4)

Showing the top 4 NuGet packages that depend on War3Net.Common:

Package Downloads
War3Net.CodeAnalysis.Jass

Parse and render JASS source files.

War3Net.IO.Compression

Compression algorithms for MPQ archives.

War3Net.IO.Slk

Read and write SLK data files.

War3Net.Drawing.Blp

Read and write BLP texture files.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.1 359 2/1/2026
6.0.0 373 1/25/2026
5.8.0 2,126 9/6/2025
5.6.1 8,686 1/7/2023
5.6.0 1,699 12/20/2022
5.5.5 3,837 11/13/2022
5.5.3 2,208 10/29/2022
5.5.2 2,068 10/25/2022
5.5.0 3,148 8/20/2022
5.4.5 2,451 5/27/2022
5.4.0 5,901 2/13/2022
5.0.2 5,791 2/14/2021
5.0.1 1,619 12/25/2020
5.0.0 1,764 12/14/2020
0.3.2 2,373 11/11/2020
0.3.1 1,002 10/29/2020
0.3.0 1,646 10/27/2020
0.2.0 1,577 9/14/2020
0.1.3 2,399 6/21/2020
0.1.2 1,496 4/25/2020
Loading failed