From 555c51589ee889e5399e1061b168ec60ae291a03 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Fri, 8 Dec 2017 19:09:38 +0200 Subject: [PATCH] Consistently declare classes/structs. Fixes issue where compilation error is produced due to file name containing constants matching class marked as value type. --- src/Generator/Generators/CSharp/CSharpSources.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 8da934c8..e0334a1e 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -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 public SymbolNotFoundException(string msg) : base(msg) {} } -} \ No newline at end of file +}