War3Net.CodeAnalysis.Transpilers 6.0.1

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

War3Net.CodeAnalysis.Transpilers

About

War3Net.CodeAnalysis.Transpilers is a .NET library for transpiling JASS (the scripting language used by Warcraft III) to C# or Lua. It is part of the War3Net modding library.

Key features

  • Transpile JASS source code to C#
  • Transpile JASS source code to Lua
  • Handle embedded Lua code in JASS scripts using polyglot transpilation
  • Optional CSharpLua template attribute generation for C# output
  • Configurable handling of comments and empty declarations

How to Use

Transpile JASS to C#

using Microsoft.CodeAnalysis.CSharp.Syntax;
using War3Net.CodeAnalysis.Jass;
using War3Net.CodeAnalysis.Transpilers;

// Parse JASS source code
string jassCode = File.ReadAllText("common.j");
var compilationUnit = JassSyntaxFactory.ParseCompilationUnit(jassCode);

// Transpile to C#
var transpiler = new JassToCSharpTranspiler();
IEnumerable<MemberDeclarationSyntax> members = transpiler.Transpile(compilationUnit);

Transpile JASS to Lua

using CSharpLua;
using War3Net.CodeAnalysis.Jass;
using War3Net.CodeAnalysis.Transpilers;

// Parse JASS source code
string jassCode = File.ReadAllText("war3map.j");
var compilationUnit = JassSyntaxFactory.ParseCompilationUnit(jassCode);

// Configure and use the transpiler
var transpiler = new JassToLuaTranspiler
{
    IgnoreComments = false,
    IgnoreEmptyDeclarations = true,
    KeepFunctionsSeparated = true,
};

// Register type information from native/common.j files
transpiler.RegisterJassFile(commonJCompilationUnit);
transpiler.RegisterJassFile(blizzardJCompilationUnit);

// Transpile to Lua
var luaCompilationUnit = transpiler.Transpile(compilationUnit);

// Render to file
using var fileStream = File.Create("war3map.lua");
using var writer = new StreamWriter(fileStream);

var rendererSettings = new LuaSyntaxGenerator.SettingInfo { Indent = 4 };
var renderer = new LuaRenderer(rendererSettings, writer);
renderer.RenderCompilationUnit(luaCompilationUnit);

Transpile polyglot JASS with embedded Lua

using CSharpLua;
using War3Net.CodeAnalysis.Transpilers;

// Create the transpiler and renderer
var transpiler = new JassToLuaTranspiler();
var rendererSettings = new LuaSyntaxGenerator.SettingInfo();
using var writer = new StringWriter();

var polyglotTranspiler = new PolyglotJassToLuaTranspiler(
    transpiler,
    rendererSettings,
    writer);

// Transpile JASS containing //! beginusercode and //! endusercode blocks
string polyglotJass = File.ReadAllText("war3map.j");
polyglotTranspiler.Transpile(polyglotJass);

string luaOutput = writer.ToString();

Main Types

The main types provided by this library are:

  • War3Net.CodeAnalysis.Transpilers.JassToCSharpTranspiler - Transpiles JASS syntax trees to C# syntax trees using Roslyn
  • War3Net.CodeAnalysis.Transpilers.JassToLuaTranspiler - Transpiles JASS syntax trees to Lua syntax trees
  • War3Net.CodeAnalysis.Transpilers.PolyglotJassToLuaTranspiler - Handles JASS files with embedded Lua code blocks

Feedback and contributing

War3Net.CodeAnalysis.Transpilers 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 (1)

Showing the top 1 NuGet packages that depend on War3Net.CodeAnalysis.Transpilers:

Package Downloads
War3Net.Build

Generate map scripts and MPQ archives from C#/vJass source code.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.1 0 2/1/2026
6.0.0 115 1/25/2026
5.8.0 655 9/6/2025
5.6.1 6,710 1/7/2023
5.6.0 771 12/20/2022
5.5.5 2,373 11/13/2022
5.5.3 737 10/29/2022
5.5.2 738 10/25/2022
5.5.0 1,577 8/20/2022
5.4.5 1,079 5/27/2022
5.4.1 2,185 2/13/2022
5.4.0 1,083 2/13/2022
5.2.8 1,276 4/8/2021
5.2.7 1,322 4/6/2021
5.2.6 765 3/6/2021
5.2.5 633 2/21/2021
5.2.3 656 2/20/2021
5.2.2 706 2/16/2021
5.2.1 803 2/14/2021
5.2.0 635 1/24/2021
5.1.1 743 12/24/2020
5.1.0 667 12/22/2020
5.0.0 622 12/15/2020