LILAC
Language to language Interop LAyer Compiler
Loading...
Searching...
No Matches
EnumExporter.cs
Go to the documentation of this file.
1using System.CodeDom.Compiler;
2using Microsoft.CodeAnalysis;
3
5
6public class EnumExporter(INamedTypeSymbol symbol) : IExporter
7{
8 public void GenerateUnmanagedCode(IndentedTextWriter source, IndentedTextWriter header)
9 {
10 header.WriteLine($"namespace {symbol.ContainingNamespace.ToDisplayString().Replace(".", "::")}");
11 header.WriteLine("{");
12 header.Indent++;
13 header.WriteLine($"enum {symbol.Name} : {symbol.EnumUnderlyingType!.ToDisplayString()}");
14 header.WriteLine("{");
15 header.Indent++;
16
17 foreach (var entry in symbol.GetMembers().OfType<IFieldSymbol>())
18 header.WriteLine($"{entry.Name} = {entry.ConstantValue!}");
19
20 header.Indent--;
21 header.WriteLine("};");
22 header.Indent--;
23 header.WriteLine("}");
24 }
25
26 public void GenerateManagedCode(IndentedTextWriter builder)
27 {
28 }
29}