diff --git a/src/Generator/Passes/SymbolsCodeGenerator.cs b/src/Generator/Passes/SymbolsCodeGenerator.cs index 1adfb430..ff986ae3 100644 --- a/src/Generator/Passes/SymbolsCodeGenerator.cs +++ b/src/Generator/Passes/SymbolsCodeGenerator.cs @@ -153,25 +153,21 @@ namespace CppSharp.Passes Context.ParserOptions.IsItaniumLikeAbi).Select( p => cppTypePrinter.VisitParameter(p))); - string @namespace = method.Namespace.Visit(cppTypePrinter); - Class @class = (Class) method.Namespace; - bool needSubclass = method.Access == AccessSpecifier.Protected || @class.IsAbstract; - if (needSubclass) + if (method.Access != AccessSpecifier.Protected) + Write("extern \"C\" "); + Write($"{GetExporting()}void {wrapper}({signature}) "); + + if (method.Access == AccessSpecifier.Protected || + ((Class) method.Namespace).IsAbstract) { - Write($"extern \"C\" {GetExporting()}void {wrapper}({signature}) "); - WriteLine($"{{ ::new ({Helpers.InstanceField}) {wrapper}{method.Namespace.Name}({@params}); }}"); + Write($@"{{ ::new ({Helpers.InstanceField}) { + wrapper}{method.Namespace.Name}({@params}); }}"); + WriteLine(method.Access == AccessSpecifier.Protected ? " };" : string.Empty); } else { - Write("extern \"C\" "); - if (needSubclass) - Write($@"class {wrapper}{method.Namespace.Namespace.Name} : public { - method.Namespace.Namespace.Visit(cppTypePrinter)} {{ "); - Write($"{GetExporting()}void {wrapper}({signature}) "); - Write($"{{ ::new ({Helpers.InstanceField}) {@namespace}({@params}); }}"); - if (needSubclass) - Write("; }"); - NewLine(); + string @namespace = method.Namespace.Visit(cppTypePrinter); + WriteLine($"{{ ::new ({Helpers.InstanceField}) {@namespace}({@params}); }}"); } foreach (var param in method.Parameters.Where(p => diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index fb241ba1..e794cc3b 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -1502,10 +1502,11 @@ struct DLL_API ClassMicrosoftObjectAlignment : ClassMicrosoftObjectAlignmentBase bool boolean; }; -class DLL_API ProtectedDestructor +class DLL_API ProtectedConstructorDestructor { protected: - ~ProtectedDestructor() {} + ProtectedConstructorDestructor() {} + ~ProtectedConstructorDestructor() {} }; DLL_API extern const unsigned ClassCustomTypeAlignmentOffsets[5];