# .NET integration

ghūl is hosted on and targets .NET 8 and can consume most types in .NET assemblies built with C#.

# projects

The ghūl compiler is driven by MSBuild and leverages the .NET SDK targets for most of the build process. Provided you reference the ghūl runtime library package, things should work as you'd expect for any other .NET SDK project. You can add package references, build assemblies and pack NuGet packages etc. all using the normal dotnet command line tools.

# name mangling

When consuming C# code the ghūl compiler transforms symbol names to better match ghūl conventions:

  • Class, struct and trait (=interface) names are left unchanged
  • Any generic type argument count suffix is left as-is (for example KeyValuePair`2)
  • Enum names and enum member names are transformed to MACRO_CASE
  • Method, property and field names are transformed to snake_case
  • Names that conflict with ghūl keywords are prefixed with `

# namespace and type name re-mapping

Some commonly used namespace and type names are re-mapped in line with ghūl conventions

# namespaces

  • System.Collections.Generic is mapped to Collections
  • System.IO is mapped to IO

# framework and collection types

Original Type Mapped Type
System.IDisposable Ghul.Disposable
System.Type System.Type2
System.Console IO.Std
System.Collections.IEnumerable Collections.NonGenericIterable
System.Collections.Generic.IReadOnlyCollection Collections.Bag
System.Collections.Generic.ICollection Collections.MutableBag
System.Collections.IEnumerator Collections.MoveNext
System.Collections.Generic.IEnumerable Collections.Iterable
System.Collections.Generic.IEnumerator Collections.Iterator
System.Collections.Generic.IReadOnlyList Collections.List
System.Collections.Generic.IList Collections.MutableList
System.Collections.Generic.List Collections.LIST
System.Collections.Generic.IReadOnlyDictionary Collections.Map
System.Collections.Generic.IDictionary Collections.MutableMap
System.Collections.Generic.Dictionary Collections.MAP
System.Collections.Generic.HashSet Collections.SET
System.Collections.Generic.Stack Collections.STACK

# primitive types

Original Type Mapped Type
System.Void Ghul.void
System.Boolean Ghul.bool
System.Char Ghul.char
System.Byte Ghul.ubyte
System.SByte Ghul.byte
System.UInt16 Ghul.ushort
System.Int16 Ghul.short
System.UInt32 Ghul.uint
System.Int32 Ghul.int
System.UInt64 Ghul.ulong
System.Int64 Ghul.long
System.UIntPtr Ghul.uword
System.IntPtr Ghul.word
System.Single Ghul.single
System.Double Ghul.double
System.Object Ghul.object
System.String Ghul.string