Skip to content

Commit 555c515

Browse files
committed
Consistently declare classes/structs. Fixes issue where compilation error is produced due to file name containing constants matching class marked as value type.
1 parent e8e727d commit 555c515

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Generator/Generators/CSharp/CSharpSources.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ void GenerateNamespaceFunctionsAndVariables(DeclarationContext context)
213213

214214
PushBlock(BlockKind.Functions);
215215
var parentName = SafeIdentifier(context.TranslationUnit.FileNameWithoutExtension);
216-
WriteLine("public unsafe partial class {0}", parentName);
216+
var @class = context.Classes.Find(c => c.Name == parentName);
217+
var keyword = @class != null && @class.IsValueType ? "struct" : "class";
218+
WriteLine($"public unsafe partial {keyword} {parentName}");
217219
WriteStartBraceIndent();
218220

219221
PushBlock(BlockKind.InternalsClass);
@@ -3233,4 +3235,4 @@ internal class SymbolNotFoundException : Exception
32333235
public SymbolNotFoundException(string msg) : base(msg)
32343236
{}
32353237
}
3236-
}
3238+
}

0 commit comments

Comments
 (0)