Skip to content

Commit 42f38ec

Browse files
committed
Generate valid C# for constants in namespaceless modules
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 9c52ada commit 42f38ec

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Generator/Generators/CSharp/CSharpSources.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ private string GeneratePointerTo(Variable var)
967967
var libraryPath = GetLibraryOf(var);
968968

969969
if (!LibrarySymbols.TryGetValue(libraryPath, out var lib))
970-
LibrarySymbols[libraryPath] = lib = new LibrarySymbolInfo(libraryPath, Module.OutputNamespace + ".__Symbols");
970+
LibrarySymbols[libraryPath] = lib = new LibrarySymbolInfo(libraryPath, Module.OutputNamespace);
971971

972972
var location = lib.GetFullVariablePath(var.Mangled);
973973

@@ -976,9 +976,9 @@ private string GeneratePointerTo(Variable var)
976976
if (arrayType != null)
977977
{
978978
if (arrayType.Type.IsPrimitiveType(PrimitiveType.Char) && arrayType.SizeType != ArrayType.ArraySize.Constant)
979-
WriteLine($@"var {ptr} = {location};");
979+
WriteLine($"var {ptr} = {location};");
980980
else
981-
WriteLine($@"var {ptr} = ({arrayType.Type.Visit(TypePrinter)}*){location};");
981+
WriteLine($"var {ptr} = ({arrayType.Type.Visit(TypePrinter)}*){location};");
982982
}
983983
else
984984
{
@@ -3567,9 +3567,9 @@ class LibrarySymbolInfo : TextGenerator
35673567

35683568
public LibrarySymbolInfo(string path, string @namespace)
35693569
{
3570-
this.path = path;
3571-
this.@namespace = @namespace;
3570+
this.path = path;
35723571
@class = identifierCleanerRegex.Replace(path, "_");
3572+
this.@namespace = (!string.IsNullOrEmpty(@namespace) ? @namespace : @class) + ".__Symbols";
35733573
}
35743574

35753575
public string Generate()

0 commit comments

Comments
 (0)