Skip to content

.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 TypeMapped Type
System.IDisposableGhul.Disposable
System.TypeSystem.Type2
System.ConsoleIO.Std
System.Collections.IEnumerableCollections.NonGenericIterable
System.Collections.Generic.IReadOnlyCollectionCollections.Bag
System.Collections.Generic.ICollectionCollections.MutableBag
System.Collections.IEnumeratorCollections.MoveNext
System.Collections.Generic.IEnumerableCollections.Iterable
System.Collections.Generic.IEnumeratorCollections.Iterator
System.Collections.Generic.IReadOnlyListCollections.List
System.Collections.Generic.IListCollections.MutableList
System.Collections.Generic.ListCollections.LIST
System.Collections.Generic.IReadOnlyDictionaryCollections.Map
System.Collections.Generic.IDictionaryCollections.MutableMap
System.Collections.Generic.DictionaryCollections.MAP
System.Collections.Generic.HashSetCollections.SET
System.Collections.Generic.StackCollections.STACK

primitive types

Original TypeMapped Type
System.VoidGhul.void
System.BooleanGhul.bool
System.CharGhul.char
System.ByteGhul.ubyte
System.SByteGhul.byte
System.UInt16Ghul.ushort
System.Int16Ghul.short
System.UInt32Ghul.uint
System.Int32Ghul.int
System.UInt64Ghul.ulong
System.Int64Ghul.long
System.UIntPtrGhul.uword
System.IntPtrGhul.word
System.SingleGhul.single
System.DoubleGhul.double
System.ObjectGhul.object
System.StringGhul.string