diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 89c330a3..39bcd7af 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -744,7 +744,7 @@ namespace CppSharp.Generators.CSharp var bases = new List(); - var needsBase = @class.HasGeneratedBase; + var needsBase = @class.HasGeneratedBase && @class.IsGenerated; if (needsBase) { diff --git a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs index 70ecfc9b..9bd526e9 100644 --- a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs +++ b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs @@ -123,6 +123,12 @@ namespace CppSharp.Passes return base.VisitTypedefDecl(typedef); } + public override bool VisitVariableDecl(Variable variable) + { + variable.Name = CheckName(variable.Name); + return base.VisitVariableDecl(variable); + } + private static void CheckEnumName(Enumeration @enum) { // If we still do not have a valid name, then try to guess one diff --git a/tests/CSharpTemp/CSharpTemp.cs b/tests/CSharpTemp/CSharpTemp.cs index 2efe4a09..6119a9e5 100644 --- a/tests/CSharpTemp/CSharpTemp.cs +++ b/tests/CSharpTemp/CSharpTemp.cs @@ -82,6 +82,8 @@ namespace CppSharp.Tests { ctx.SetClassAsValueType("TestCopyConstructorVal"); ctx.SetClassAsValueType("QGenericArgument"); + + ctx.IgnoreClassWithName("IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor"); } public override void Postprocess(Driver driver, ASTContext ctx) diff --git a/tests/CSharpTemp/CSharpTemp.h b/tests/CSharpTemp/CSharpTemp.h index c16c148d..969ea700 100644 --- a/tests/CSharpTemp/CSharpTemp.h +++ b/tests/CSharpTemp/CSharpTemp.h @@ -10,6 +10,8 @@ public: int& operator[](int i); int A; + static int null; + protected: int P; }; @@ -20,6 +22,7 @@ public: Qux(); Qux(Foo foo); int farAwayFunc() const; + int array[3]; void obsolete(); }; @@ -253,6 +256,10 @@ class DLL_API IgnoredType { }; +class DLL_API IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor : public P +{ +}; + class DLL_API PropertyWithIgnoredType { public: @@ -260,4 +267,4 @@ public: void setIgnoredType(const IgnoredType& value); private: IgnoredType _ignoredType; -}; \ No newline at end of file +};