By default, Haxe uses basic .NET 2.0 API provided by hxcs library (it ships mscorlib.dll and System.dll from the Mono project). We can specify different .NET version by providing
-D net-ver=xx define, where xx is major and minor digits of .NET version number, i.e.
-D net-ver=40 for setting .NET version to 4.0. Note that currently, hxcs library only ships DLL files for .NET 2.0 and 4.0.
We can make Haxe use a custom set of DLL files as standard .NET framework. To do that, we need to first learn about how Haxe finds standard .NET libraries. Haxe/C# looks for .DLL files in a directory path, constructed from three components:
-D net-ver=xx, defaults to
20as described above)
net, but could be changed using
-D net-target=xxx, where
compactor some other).
--net-stdoption, by default points to netlib directory inside hxcs library)
The resulting search path will be
<net_std_path>/<net_target>-<net_ver>/, taking in the consideration default values described above, without any specific configuration haxe will load all .NET DLL files found in
Now if we provide the following options:
-D net-target=micro -D net-ver=35 --net-std=/dotnet
Haxe will load all .NET DLL files found in
Haxe can directly load .NET assembly files (.DLL) and convert its type definitions for use as Haxe types. To load a .NET assembly, use
--net-lib library.dll compiler option. Haxe will then automatically parse types defined in that assembly file and make them available for import as Haxe types.
Some changes are performed to type naming of C# classes to make them fit into Haxe type system, namely:
Systemnamespace is also prefixed with
OuterClassName_InnerClassNameand placed into the
OuterClassNamemodule. So for example for an inner class
Binside a class
Ainside a namespace
Something, the full Haxe type path will be
something.A.A_B. Note however, that if you do
import something.A, both
A_Bclass will be available within your module as per standard Haxe import mechanism.