Browse Source

Consistently declare classes/structs. Fixes issue where compilation error is produced due to file name containing constants matching class marked as value type.

pull/1022/head
Rokas Kupstys 8 years ago
parent
commit
555c51589e
  1. 6
      src/Generator/Generators/CSharp/CSharpSources.cs

6
src/Generator/Generators/CSharp/CSharpSources.cs

@ -213,7 +213,9 @@ namespace CppSharp.Generators.CSharp @@ -213,7 +213,9 @@ namespace CppSharp.Generators.CSharp
PushBlock(BlockKind.Functions);
var parentName = SafeIdentifier(context.TranslationUnit.FileNameWithoutExtension);
WriteLine("public unsafe partial class {0}", parentName);
var @class = context.Classes.Find(c => c.Name == parentName);
var keyword = @class != null && @class.IsValueType ? "struct" : "class";
WriteLine($"public unsafe partial {keyword} {parentName}");
WriteStartBraceIndent();
PushBlock(BlockKind.InternalsClass);
@ -3233,4 +3235,4 @@ namespace CppSharp.Generators.CSharp @@ -3233,4 +3235,4 @@ namespace CppSharp.Generators.CSharp
public SymbolNotFoundException(string msg) : base(msg)
{}
}
}
}

Loading…
Cancel
Save