War3Net.Common
6.0.1
dotnet add package War3Net.Common --version 6.0.1
NuGet\Install-Package War3Net.Common -Version 6.0.1
<PackageReference Include="War3Net.Common" Version="6.0.1" />
<PackageVersion Include="War3Net.Common" Version="6.0.1" />
<PackageReference Include="War3Net.Common" />
paket add War3Net.Common --version 6.0.1
#r "nuget: War3Net.Common, 6.0.1"
#:package War3Net.Common@6.0.1
#addin nuget:?package=War3Net.Common&version=6.0.1
#tool nuget:?package=War3Net.Common&version=6.0.1
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
BinaryReaderandBinaryWriterto 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 validationWar3Net.Common.Extensions.BinaryReaderExtensions- Extension methods for reading Warcraft III data typesWar3Net.Common.Extensions.BinaryWriterExtensions- Extension methods for writing Warcraft III data typesWar3Net.Common.Extensions.StreamExtensions- Extension methods for stream operationsWar3Net.Common.Extensions.Int32Extensions- Rawcode and color conversion from integersWar3Net.Common.Extensions.StringExtensions- Rawcode conversion from stringsWar3Net.Common.Providers.UTF8EncodingProvider- Pre-configured UTF-8 encodings
Related Packages
- War3Net.Build.Core - Parsers and serializers for war3map files
- War3Net.IO.Mpq - Read and write MPQ archives
- War3Net.IO.Slk - Read and write SLK files
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 | Versions 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. |
-
net5.0
- System.Drawing.Common (>= 6.0.0)
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 |