From 591ab6fd578f1653dad5d429f98c3e598948a662 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Tue, 28 Feb 2017 20:44:55 +0000 Subject: [PATCH] Refactor C# class prologue generation. --- .../Generators/CSharp/CSharpSources.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 4e357ee1..714f55af 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -554,20 +554,24 @@ namespace CppSharp.Generators.CSharp { // private classes must be visible to because the internal structs can be used in dependencies // the proper fix is InternalsVisibleTo - Write(@class.Access == AccessSpecifier.Protected ? "protected internal " : "public "); - Write("unsafe "); + var keywords = new List(); + + keywords.Add(@class.Access == AccessSpecifier.Protected ? "protected internal" : "public"); + keywords.Add("unsafe"); if (@class.IsAbstract) - Write("abstract "); + keywords.Add("abstract"); if (@class.IsStatic) - Write("static "); + keywords.Add("static"); // This token needs to directly precede the "class" token. - Write("partial "); + keywords.Add("partial"); + + keywords.Add(@class.IsInterface ? "interface" : (@class.IsValueType ? "struct" : "class")); + keywords.Add(SafeIdentifier(@class.Name)); - Write(@class.IsInterface ? "interface " : (@class.IsValueType ? "struct " : "class ")); - Write("{0}", SafeIdentifier(@class.Name)); + Write(string.Join(" ", keywords)); var bases = new List();