diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs index 4beb7438..436bb5dd 100644 --- a/src/Generator/Passes/CheckIgnoredDecls.cs +++ b/src/Generator/Passes/CheckIgnoredDecls.cs @@ -71,7 +71,7 @@ namespace CppSharp.Passes return true; } - if (decl.IsDependent) + if (decl.IsDependent && !decl.IsExplicitlyGenerated) { decl.GenerationKind = decl is Field ? GenerationKind.Internal : GenerationKind.None; Diagnostics.Debug("Decl '{0}' was ignored due to dependent context", diff --git a/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs b/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs index ed5e8dc6..2e61eca0 100644 --- a/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs +++ b/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs @@ -61,25 +61,8 @@ namespace CppSharp.Passes m.Parameters[0].Type.Desugar().IsPointerToPrimitiveType(PrimitiveType.Char) && !m.Parameters[1].Type.Desugar().IsPrimitiveType()); ctor.GenerationKind = GenerationKind.Generate; - foreach (var parameter in ctor.Parameters) - parameter.DefaultArgument = null; - } - foreach (var ctor in @class.Methods.Where(m => - { - if (!m.IsConstructor || m.Parameters.Count != 2) - return false; - for (int i = 0; i < m.Parameters.Count; i++) - { - var type = m.Parameters[i].Type.Desugar(); - var templateParameter = (type.GetFinalPointee() ?? type) as TemplateParameterType; - if (templateParameter == null || - @class.TemplateParameters.All(t => t.Name != templateParameter.Parameter.Name)) - return false; - } - return true; - })) - { - ctor.GenerationKind = GenerationKind.Generate; + ctor.InstantiatedFrom.GenerationKind = GenerationKind.Generate; + ctor.InstantiatedFrom.Namespace.GenerationKind = GenerationKind.Generate; foreach (var parameter in ctor.Parameters) parameter.DefaultArgument = null; } diff --git a/src/Generator/Passes/StripUnusedSystemTypesPass.cs b/src/Generator/Passes/StripUnusedSystemTypesPass.cs index 58e3d9c8..c18ca5b0 100644 --- a/src/Generator/Passes/StripUnusedSystemTypesPass.cs +++ b/src/Generator/Passes/StripUnusedSystemTypesPass.cs @@ -94,7 +94,8 @@ namespace CppSharp.Passes var nestedContext = declaration as Namespace; if (nestedContext != null) RemoveUnusedStdTypes(nestedContext); - else if (!this.usedStdTypes.Contains(declaration)) + else if (!this.usedStdTypes.Contains(declaration) && + !declaration.IsExplicitlyGenerated) context.Declarations.RemoveAt(i); } } diff --git a/tests/CSharp/CSharp.cpp b/tests/CSharp/CSharp.cpp index 2ccf6d71..cd621491 100644 --- a/tests/CSharp/CSharp.cpp +++ b/tests/CSharp/CSharp.cpp @@ -1350,3 +1350,7 @@ DLL_API int useDuplicateDeclaredStruct(DuplicateDeclaredStruct* s) { return s->i; } + +void useStdStringJustAsParameter(std::string s) +{ +} diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index 69c43b9d..9f030ec5 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -2,6 +2,7 @@ #include #include #include +#include #include "AnotherUnit.h" class DLL_API Foo @@ -1205,4 +1206,6 @@ int TestIndexedProperties::operator[](const int& key) return key; } -extern const ComplexArrayElement ArrayOfVariableSize[]; \ No newline at end of file +extern const ComplexArrayElement ArrayOfVariableSize[]; + +void useStdStringJustAsParameter(std::string s);