From 6432d910fae1d504ae073564f33e41d8a5d20e7a Mon Sep 17 00:00:00 2001
From: Dimitar Dobrev <dpldobrev@yahoo.com>
Date: Sat, 15 Aug 2015 05:48:23 +0300
Subject: [PATCH] Removed the memory leak in the AST converter.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
---
 src/Core/Parser/ASTConverter.cs               |  98 +-
 src/CppParser/AST.cpp                         |   1 +
 src/CppParser/AST.h                           |   1 +
 src/CppParser/Bindings/CLI/AST.cpp            | 865 +++++++++++++++---
 src/CppParser/Bindings/CLI/AST.h              | 115 ++-
 src/CppParser/Bindings/CLI/CppParser.cpp      |  52 +-
 src/CppParser/Bindings/CLI/CppParser.h        |  12 +-
 src/CppParser/Bindings/CLI/Target.cpp         |  13 +-
 src/CppParser/Bindings/CLI/Target.h           |   3 +-
 .../CSharp/i686-apple-darwin12.4.0/AST.cs     | 450 ++++-----
 .../i686-apple-darwin12.4.0/CppParser.cs      |  24 +-
 .../CSharp/i686-apple-darwin12.4.0/Target.cs  |   6 +-
 .../Bindings/CSharp/i686-pc-win32-msvc/AST.cs | 450 ++++-----
 .../CSharp/i686-pc-win32-msvc/CppParser.cs    |  24 +-
 .../CSharp/i686-pc-win32-msvc/Target.cs       |   6 +-
 .../CSharp/x86_64-apple-darwin12.4.0/AST.cs   | 450 ++++-----
 .../x86_64-apple-darwin12.4.0/CppParser.cs    |  24 +-
 .../x86_64-apple-darwin12.4.0/Target.cs       |   6 +-
 .../Bindings/CSharp/x86_64-linux-gnu/AST.cs   | 450 ++++-----
 .../CSharp/x86_64-linux-gnu/CppParser.cs      |  24 +-
 .../CSharp/x86_64-linux-gnu/Target.cs         |   6 +-
 .../Generators/CLI/CLIHeadersTemplate.cs      |  19 +-
 .../Generators/CLI/CLISourcesTemplate.cs      |  51 +-
 .../Generators/CSharp/CSharpTextTemplate.cs   |  12 +-
 24 files changed, 1989 insertions(+), 1173 deletions(-)

diff --git a/src/Core/Parser/ASTConverter.cs b/src/Core/Parser/ASTConverter.cs
index cf12b0e9..0cd50239 100644
--- a/src/Core/Parser/ASTConverter.cs
+++ b/src/Core/Parser/ASTConverter.cs
@@ -36,77 +36,77 @@ namespace CppSharp
             {
                 case TypeKind.Tag:
                 {
-                    var _type = TagType.__CreateInstance(type.__Instance);
+                    var _type = TagType.__CreateInstance(type.__Instance, true);
                     return VisitTag(_type);
                 }
                 case TypeKind.Array:
                 {
-                    var _type = ArrayType.__CreateInstance(type.__Instance);
+                    var _type = ArrayType.__CreateInstance(type.__Instance, true);
                     return VisitArray(_type);
                 }
                 case TypeKind.Function:
                 {
-                    var _type = FunctionType.__CreateInstance(type.__Instance);
+                    var _type = FunctionType.__CreateInstance(type.__Instance, true);
                     return VisitFunction(_type);
                 }
                 case TypeKind.Pointer:
                 {
-                    var _type = PointerType.__CreateInstance(type.__Instance);
+                    var _type = PointerType.__CreateInstance(type.__Instance, true);
                     return VisitPointer(_type);
                 }
                 case TypeKind.MemberPointer:
                 {
-                    var _type = MemberPointerType.__CreateInstance(type.__Instance);
+                    var _type = MemberPointerType.__CreateInstance(type.__Instance, true);
                     return VisitMemberPointer(_type);
                 }
                 case TypeKind.Typedef:
                 {
-                    var _type = TypedefType.__CreateInstance(type.__Instance);
+                    var _type = TypedefType.__CreateInstance(type.__Instance, true);
                     return VisitTypedef(_type);
                 }
                 case TypeKind.Attributed:
                 {
-                    var _type = AttributedType.__CreateInstance(type.__Instance);
+                    var _type = AttributedType.__CreateInstance(type.__Instance, true);
                     return VisitAttributed(_type);
                 }
                 case TypeKind.Decayed:
                 {
-                    var _type = DecayedType.__CreateInstance(type.__Instance);
+                    var _type = DecayedType.__CreateInstance(type.__Instance, true);
                     return VisitDecayed(_type);
                 }
                 case TypeKind.TemplateSpecialization:
                 {
-                    var _type = TemplateSpecializationType.__CreateInstance(type.__Instance);
+                    var _type = TemplateSpecializationType.__CreateInstance(type.__Instance, true);
                     return VisitTemplateSpecialization(_type);
                 }
                 case TypeKind.TemplateParameter:
                 {
-                    var _type = TemplateParameterType.__CreateInstance(type.__Instance);
+                    var _type = TemplateParameterType.__CreateInstance(type.__Instance, true);
                     return VisitTemplateParameter(_type);
                 }
                 case TypeKind.TemplateParameterSubstitution:
                 {
-                    var _type = TemplateParameterSubstitutionType.__CreateInstance(type.__Instance);
+                    var _type = TemplateParameterSubstitutionType.__CreateInstance(type.__Instance, true);
                     return VisitTemplateParameterSubstitution(_type);
                 }
                 case TypeKind.InjectedClassName:
                 {
-                    var _type = InjectedClassNameType.__CreateInstance(type.__Instance);
+                    var _type = InjectedClassNameType.__CreateInstance(type.__Instance, true);
                     return VisitInjectedClassName(_type);
                 }
                 case TypeKind.DependentName:
                 {
-                    var _type = DependentNameType.__CreateInstance(type.__Instance);
+                    var _type = DependentNameType.__CreateInstance(type.__Instance, true);
                     return VisitDependentName(_type);
                 }
                 case TypeKind.Builtin:
                 {
-                    var _type = BuiltinType.__CreateInstance(type.__Instance);
+                    var _type = BuiltinType.__CreateInstance(type.__Instance, true);
                     return VisitBuiltin(_type);
                 }
                 case TypeKind.PackExpansion:
                 {
-                    var _type = PackExpansionType.__CreateInstance(type.__Instance);
+                    var _type = PackExpansionType.__CreateInstance(type.__Instance, true);
                     return VisitPackExpansion(_type);
                 }
             }
@@ -148,97 +148,97 @@ namespace CppSharp
             {
                 case DeclarationKind.TranslationUnit:
                     {
-                        var _decl = TranslationUnit.__CreateInstance(decl.__Instance);
+                        var _decl = TranslationUnit.__CreateInstance(decl.__Instance, true);
                         return VisitTranslationUnit(_decl);
                     }
                 case DeclarationKind.Namespace:
                     {
-                        var _decl = Namespace.__CreateInstance(decl.__Instance);
+                        var _decl = Namespace.__CreateInstance(decl.__Instance, true);
                         return VisitNamespace(_decl);
                     }
                 case DeclarationKind.Typedef:
                     {
-                        var _decl = TypedefDecl.__CreateInstance(decl.__Instance);
+                        var _decl = TypedefDecl.__CreateInstance(decl.__Instance, true);
                         return VisitTypedef(_decl);
                     }
                 case DeclarationKind.Parameter:
                     {
-                        var _decl = Parameter.__CreateInstance(decl.__Instance);
+                        var _decl = Parameter.__CreateInstance(decl.__Instance, true);
                         return VisitParameter(_decl);
                     }
                 case DeclarationKind.Function:
                     {
-                        var _decl = Function.__CreateInstance(decl.__Instance);
+                        var _decl = Function.__CreateInstance(decl.__Instance, true);
                         return VisitFunction(_decl);
                     }
                 case DeclarationKind.Method:
                     {
-                        var _decl = Method.__CreateInstance(decl.__Instance);
+                        var _decl = Method.__CreateInstance(decl.__Instance, true);
                         return VisitMethod(_decl);
                     }
                 case DeclarationKind.Enumeration:
                     {
-                        var _decl = Enumeration.__CreateInstance(decl.__Instance);
+                        var _decl = Enumeration.__CreateInstance(decl.__Instance, true);
                         return VisitEnumeration(_decl);
                     }
                 case DeclarationKind.EnumerationItem:
                     {
-                        var _decl = Enumeration.Item.__CreateInstance(decl.__Instance);
+                        var _decl = Enumeration.Item.__CreateInstance(decl.__Instance, true);
                         return VisitEnumerationItem(_decl);
                     }
                 case DeclarationKind.Variable:
                     {
-                        var _decl = Variable.__CreateInstance(decl.__Instance);
+                        var _decl = Variable.__CreateInstance(decl.__Instance, true);
                         return VisitVariable(_decl);
                     }
                 case DeclarationKind.Friend:
                     {
-                        var _decl = Friend.__CreateInstance(decl.__Instance);
+                        var _decl = Friend.__CreateInstance(decl.__Instance, true);
                         return VisitFriend(_decl);
                     }
                 case DeclarationKind.Field:
                     {
-                        var _decl = Field.__CreateInstance(decl.__Instance);
+                        var _decl = Field.__CreateInstance(decl.__Instance, true);
                         return VisitField(_decl);
                     }
                 case DeclarationKind.AccessSpecifier:
                     {
-                        var _decl = AccessSpecifierDecl.__CreateInstance(decl.__Instance);
+                        var _decl = AccessSpecifierDecl.__CreateInstance(decl.__Instance, true);
                         return VisitAccessSpecifier(_decl);
                     }
                 case DeclarationKind.Class:
                     {
-                        var _decl = Class.__CreateInstance(decl.__Instance);
+                        var _decl = Class.__CreateInstance(decl.__Instance, true);
                         return VisitClass(_decl);
                     }
                 case DeclarationKind.ClassTemplate:
                     {
-                        var _decl = ClassTemplate.__CreateInstance(decl.__Instance);
+                        var _decl = ClassTemplate.__CreateInstance(decl.__Instance, true);
                         return VisitClassTemplate(_decl);
                     }
                 case DeclarationKind.ClassTemplateSpecialization:
                     {
-                        var _decl = ClassTemplateSpecialization.__CreateInstance(decl.__Instance);
+                        var _decl = ClassTemplateSpecialization.__CreateInstance(decl.__Instance, true);
                         return VisitClassTemplateSpecialization(_decl);
                     }
                 case DeclarationKind.ClassTemplatePartialSpecialization:
                     {
-                        var _decl = ClassTemplatePartialSpecialization.__CreateInstance(decl.__Instance);
+                        var _decl = ClassTemplatePartialSpecialization.__CreateInstance(decl.__Instance, true);
                         return VisitClassTemplatePartialSpecialization(_decl);
                     }
                 case DeclarationKind.FunctionTemplate:
                     {
-                        var _decl = FunctionTemplate.__CreateInstance(decl.__Instance);
+                        var _decl = FunctionTemplate.__CreateInstance(decl.__Instance, true);
                         return VisitFunctionTemplate(_decl);
                     }
                 case DeclarationKind.MacroDefinition:
                     {
-                        var _decl = MacroDefinition.__CreateInstance(decl.__Instance);
+                        var _decl = MacroDefinition.__CreateInstance(decl.__Instance, true);
                         return VisitMacroDefinition(_decl);
                     }
                 case DeclarationKind.MacroExpansion:
                     {
-                        var _decl = MacroExpansion.__CreateInstance(decl.__Instance);
+                        var _decl = MacroExpansion.__CreateInstance(decl.__Instance, true);
                         return VisitMacroExpansion(_decl);
                     }
             }
@@ -345,6 +345,12 @@ namespace CppSharp
                 _ctx.TranslationUnits.Add(_unit);
             }
 
+            foreach (var nativeObject in typeConverter.NativeObjects)
+                nativeObject.Dispose();
+
+            foreach (var nativeObject in declConverter.NativeObjects)
+                nativeObject.Dispose();
+
             return _ctx;
         }
     }
@@ -353,6 +359,13 @@ namespace CppSharp
     {
         internal DeclConverter declConverter;
 
+        public TypeConverter()
+        {
+            NativeObjects = new HashSet<IDisposable>();
+        }
+
+        public HashSet<IDisposable> NativeObjects { get; private set; }
+
         public AST.QualifiedType VisitQualified(QualifiedType qualType)
         {
             var _qualType = new AST.QualifiedType
@@ -389,6 +402,7 @@ namespace CppSharp
         void VisitType(Parser.AST.Type origType, CppSharp.AST.Type type)
         {
             type.IsDependent = origType.IsDependent;
+            NativeObjects.Add(origType);
         }
 
         public override AST.Type VisitTag(TagType type)
@@ -650,11 +664,14 @@ namespace CppSharp
 
         public DeclConverter(TypeConverter type, CommentConverter comment)
         {
+            NativeObjects = new HashSet<IDisposable>();
             typeConverter = type;
             commentConverter = comment;
             Declarations = new Dictionary<IntPtr, AST.Declaration>();
         }
 
+        public HashSet<IDisposable> NativeObjects { get; private set; }
+
         public override AST.Declaration Visit(Parser.AST.Declaration decl)
         {
             if (decl == null)
@@ -785,6 +802,8 @@ namespace CppSharp
             }
 
             _decl.OriginalPtr = originalPtr;
+
+            NativeObjects.Add(decl);
         }
 
         void VisitDeclContext(DeclarationContext ctx, AST.DeclarationContext _ctx)
@@ -936,6 +955,9 @@ namespace CppSharp
             }
             expression.Declaration = typeConverter.declConverter.Visit(statement.Decl);
             expression.String = statement.String;
+
+            NativeObjects.Add(statement);
+
             return expression;
         }
 
@@ -1291,6 +1313,8 @@ namespace CppSharp
                 _layout.VFTables.Add(_vftableInfo);
             }
 
+            NativeObjects.Add(layout);
+
             return _layout;
         }
 
@@ -1323,6 +1347,8 @@ namespace CppSharp
                 Layout = VisitVTableLayout(vftableInfo.Layout)
             };
 
+            NativeObjects.Add(vftableInfo);
+
             return _vftableInfo;
         }
 
@@ -1337,6 +1363,8 @@ namespace CppSharp
                 _layout.Components.Add(_component);
             }
 
+            NativeObjects.Add(layout);
+
             return _layout;
         }
 
@@ -1349,6 +1377,8 @@ namespace CppSharp
                 Declaration = Visit(component.Declaration)
             };
 
+            NativeObjects.Add(component);
+
             return _component;
         }
 
diff --git a/src/CppParser/AST.cpp b/src/CppParser/AST.cpp
index 932f9463..64f0eef3 100644
--- a/src/CppParser/AST.cpp
+++ b/src/CppParser/AST.cpp
@@ -129,6 +129,7 @@ VTableComponent::VTableComponent() : Offset(0), Declaration(0) {}
 // VTableLayout
 VTableLayout::VTableLayout() {}
 VTableLayout::VTableLayout(const VTableLayout& rhs) : Components(rhs.Components) {}
+VTableLayout::~VTableLayout() {}
 
 DEF_VECTOR(VTableLayout, VTableComponent, Components)
 
diff --git a/src/CppParser/AST.h b/src/CppParser/AST.h
index a87670da..bf4f4f0e 100644
--- a/src/CppParser/AST.h
+++ b/src/CppParser/AST.h
@@ -310,6 +310,7 @@ struct CS_API VTableLayout
 {
     VTableLayout();
     VTableLayout(const VTableLayout&);
+    ~VTableLayout();
     VECTOR(VTableComponent, Components)
 };
 
diff --git a/src/CppParser/Bindings/CLI/AST.cpp b/src/CppParser/Bindings/CLI/AST.cpp
index efc5fd83..342c2818 100644
--- a/src/CppParser/Bindings/CLI/AST.cpp
+++ b/src/CppParser/Bindings/CLI/AST.cpp
@@ -11,7 +11,14 @@ CppSharp::Parser::AST::Type::Type(::CppSharp::CppParser::AST::Type* native)
 
 CppSharp::Parser::AST::Type^ CppSharp::Parser::AST::Type::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Type::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Type^ CppSharp::Parser::AST::Type::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Type^ result = gcnew ::CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Type::~Type()
@@ -21,15 +28,15 @@ CppSharp::Parser::AST::Type::~Type()
 }
 
 CppSharp::Parser::AST::Type::Type(CppSharp::Parser::AST::TypeKind kind)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::TypeKind)kind;
     NativePtr = new ::CppSharp::CppParser::AST::Type(arg0);
 }
 
 CppSharp::Parser::AST::Type::Type(CppSharp::Parser::AST::Type^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Type*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Type(arg0);
 }
@@ -72,7 +79,14 @@ CppSharp::Parser::AST::TypeQualifiers::TypeQualifiers(::CppSharp::CppParser::AST
 
 CppSharp::Parser::AST::TypeQualifiers^ CppSharp::Parser::AST::TypeQualifiers::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TypeQualifiers((::CppSharp::CppParser::AST::TypeQualifiers*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TypeQualifiers::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TypeQualifiers^ CppSharp::Parser::AST::TypeQualifiers::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TypeQualifiers^ result = gcnew ::CppSharp::Parser::AST::TypeQualifiers((::CppSharp::CppParser::AST::TypeQualifiers*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TypeQualifiers::~TypeQualifiers()
@@ -82,15 +96,15 @@ CppSharp::Parser::AST::TypeQualifiers::~TypeQualifiers()
 }
 
 CppSharp::Parser::AST::TypeQualifiers::TypeQualifiers(CppSharp::Parser::AST::TypeQualifiers^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TypeQualifiers*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TypeQualifiers(arg0);
 }
 
 CppSharp::Parser::AST::TypeQualifiers::TypeQualifiers()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TypeQualifiers();
 }
 
@@ -142,7 +156,14 @@ CppSharp::Parser::AST::QualifiedType::QualifiedType(::CppSharp::CppParser::AST::
 
 CppSharp::Parser::AST::QualifiedType^ CppSharp::Parser::AST::QualifiedType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::QualifiedType((::CppSharp::CppParser::AST::QualifiedType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::QualifiedType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::QualifiedType^ CppSharp::Parser::AST::QualifiedType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::QualifiedType^ result = gcnew ::CppSharp::Parser::AST::QualifiedType((::CppSharp::CppParser::AST::QualifiedType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::QualifiedType::~QualifiedType()
@@ -152,14 +173,14 @@ CppSharp::Parser::AST::QualifiedType::~QualifiedType()
 }
 
 CppSharp::Parser::AST::QualifiedType::QualifiedType()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::QualifiedType();
 }
 
 CppSharp::Parser::AST::QualifiedType::QualifiedType(CppSharp::Parser::AST::QualifiedType^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::QualifiedType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::QualifiedType(arg0);
 }
@@ -201,7 +222,14 @@ CppSharp::Parser::AST::TagType::TagType(::CppSharp::CppParser::AST::TagType* nat
 
 CppSharp::Parser::AST::TagType^ CppSharp::Parser::AST::TagType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TagType((::CppSharp::CppParser::AST::TagType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TagType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TagType^ CppSharp::Parser::AST::TagType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TagType^ result = gcnew ::CppSharp::Parser::AST::TagType((::CppSharp::CppParser::AST::TagType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TagType::~TagType()
@@ -211,12 +239,14 @@ CppSharp::Parser::AST::TagType::~TagType()
 CppSharp::Parser::AST::TagType::TagType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TagType();
 }
 
 CppSharp::Parser::AST::TagType::TagType(CppSharp::Parser::AST::TagType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TagType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TagType(arg0);
 }
@@ -238,7 +268,14 @@ CppSharp::Parser::AST::ArrayType::ArrayType(::CppSharp::CppParser::AST::ArrayTyp
 
 CppSharp::Parser::AST::ArrayType^ CppSharp::Parser::AST::ArrayType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::ArrayType((::CppSharp::CppParser::AST::ArrayType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::ArrayType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::ArrayType^ CppSharp::Parser::AST::ArrayType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::ArrayType^ result = gcnew ::CppSharp::Parser::AST::ArrayType((::CppSharp::CppParser::AST::ArrayType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::ArrayType::~ArrayType()
@@ -248,12 +285,14 @@ CppSharp::Parser::AST::ArrayType::~ArrayType()
 CppSharp::Parser::AST::ArrayType::ArrayType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::ArrayType();
 }
 
 CppSharp::Parser::AST::ArrayType::ArrayType(CppSharp::Parser::AST::ArrayType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::ArrayType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::ArrayType(arg0);
 }
@@ -295,7 +334,14 @@ CppSharp::Parser::AST::FunctionType::FunctionType(::CppSharp::CppParser::AST::Fu
 
 CppSharp::Parser::AST::FunctionType^ CppSharp::Parser::AST::FunctionType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::FunctionType((::CppSharp::CppParser::AST::FunctionType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::FunctionType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::FunctionType^ CppSharp::Parser::AST::FunctionType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::FunctionType^ result = gcnew ::CppSharp::Parser::AST::FunctionType((::CppSharp::CppParser::AST::FunctionType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::FunctionType::~FunctionType()
@@ -305,6 +351,7 @@ CppSharp::Parser::AST::FunctionType::~FunctionType()
 CppSharp::Parser::AST::FunctionType::FunctionType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::FunctionType();
 }
 
@@ -329,6 +376,7 @@ void CppSharp::Parser::AST::FunctionType::clearParameters()
 CppSharp::Parser::AST::FunctionType::FunctionType(CppSharp::Parser::AST::FunctionType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::FunctionType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::FunctionType(arg0);
 }
@@ -366,7 +414,14 @@ CppSharp::Parser::AST::PointerType::PointerType(::CppSharp::CppParser::AST::Poin
 
 CppSharp::Parser::AST::PointerType^ CppSharp::Parser::AST::PointerType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::PointerType((::CppSharp::CppParser::AST::PointerType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::PointerType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::PointerType^ CppSharp::Parser::AST::PointerType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::PointerType^ result = gcnew ::CppSharp::Parser::AST::PointerType((::CppSharp::CppParser::AST::PointerType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::PointerType::~PointerType()
@@ -376,12 +431,14 @@ CppSharp::Parser::AST::PointerType::~PointerType()
 CppSharp::Parser::AST::PointerType::PointerType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::PointerType();
 }
 
 CppSharp::Parser::AST::PointerType::PointerType(CppSharp::Parser::AST::PointerType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::PointerType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::PointerType(arg0);
 }
@@ -413,7 +470,14 @@ CppSharp::Parser::AST::MemberPointerType::MemberPointerType(::CppSharp::CppParse
 
 CppSharp::Parser::AST::MemberPointerType^ CppSharp::Parser::AST::MemberPointerType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::MemberPointerType((::CppSharp::CppParser::AST::MemberPointerType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::MemberPointerType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::MemberPointerType^ CppSharp::Parser::AST::MemberPointerType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::MemberPointerType^ result = gcnew ::CppSharp::Parser::AST::MemberPointerType((::CppSharp::CppParser::AST::MemberPointerType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::MemberPointerType::~MemberPointerType()
@@ -423,12 +487,14 @@ CppSharp::Parser::AST::MemberPointerType::~MemberPointerType()
 CppSharp::Parser::AST::MemberPointerType::MemberPointerType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::MemberPointerType();
 }
 
 CppSharp::Parser::AST::MemberPointerType::MemberPointerType(CppSharp::Parser::AST::MemberPointerType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::MemberPointerType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::MemberPointerType(arg0);
 }
@@ -450,7 +516,14 @@ CppSharp::Parser::AST::TypedefType::TypedefType(::CppSharp::CppParser::AST::Type
 
 CppSharp::Parser::AST::TypedefType^ CppSharp::Parser::AST::TypedefType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TypedefType((::CppSharp::CppParser::AST::TypedefType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TypedefType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TypedefType^ CppSharp::Parser::AST::TypedefType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TypedefType^ result = gcnew ::CppSharp::Parser::AST::TypedefType((::CppSharp::CppParser::AST::TypedefType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TypedefType::~TypedefType()
@@ -460,12 +533,14 @@ CppSharp::Parser::AST::TypedefType::~TypedefType()
 CppSharp::Parser::AST::TypedefType::TypedefType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TypedefType();
 }
 
 CppSharp::Parser::AST::TypedefType::TypedefType(CppSharp::Parser::AST::TypedefType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TypedefType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TypedefType(arg0);
 }
@@ -487,7 +562,14 @@ CppSharp::Parser::AST::AttributedType::AttributedType(::CppSharp::CppParser::AST
 
 CppSharp::Parser::AST::AttributedType^ CppSharp::Parser::AST::AttributedType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::AttributedType((::CppSharp::CppParser::AST::AttributedType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::AttributedType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::AttributedType^ CppSharp::Parser::AST::AttributedType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::AttributedType^ result = gcnew ::CppSharp::Parser::AST::AttributedType((::CppSharp::CppParser::AST::AttributedType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::AttributedType::~AttributedType()
@@ -497,12 +579,14 @@ CppSharp::Parser::AST::AttributedType::~AttributedType()
 CppSharp::Parser::AST::AttributedType::AttributedType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::AttributedType();
 }
 
 CppSharp::Parser::AST::AttributedType::AttributedType(CppSharp::Parser::AST::AttributedType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::AttributedType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::AttributedType(arg0);
 }
@@ -534,7 +618,14 @@ CppSharp::Parser::AST::DecayedType::DecayedType(::CppSharp::CppParser::AST::Deca
 
 CppSharp::Parser::AST::DecayedType^ CppSharp::Parser::AST::DecayedType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::DecayedType((::CppSharp::CppParser::AST::DecayedType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::DecayedType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::DecayedType^ CppSharp::Parser::AST::DecayedType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::DecayedType^ result = gcnew ::CppSharp::Parser::AST::DecayedType((::CppSharp::CppParser::AST::DecayedType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::DecayedType::~DecayedType()
@@ -544,12 +635,14 @@ CppSharp::Parser::AST::DecayedType::~DecayedType()
 CppSharp::Parser::AST::DecayedType::DecayedType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::DecayedType();
 }
 
 CppSharp::Parser::AST::DecayedType::DecayedType(CppSharp::Parser::AST::DecayedType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::DecayedType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::DecayedType(arg0);
 }
@@ -592,7 +685,14 @@ CppSharp::Parser::AST::TemplateArgument::TemplateArgument(::CppSharp::CppParser:
 
 CppSharp::Parser::AST::TemplateArgument^ CppSharp::Parser::AST::TemplateArgument::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TemplateArgument((::CppSharp::CppParser::AST::TemplateArgument*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TemplateArgument::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TemplateArgument^ CppSharp::Parser::AST::TemplateArgument::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TemplateArgument^ result = gcnew ::CppSharp::Parser::AST::TemplateArgument((::CppSharp::CppParser::AST::TemplateArgument*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TemplateArgument::~TemplateArgument()
@@ -602,14 +702,14 @@ CppSharp::Parser::AST::TemplateArgument::~TemplateArgument()
 }
 
 CppSharp::Parser::AST::TemplateArgument::TemplateArgument()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateArgument();
 }
 
 CppSharp::Parser::AST::TemplateArgument::TemplateArgument(CppSharp::Parser::AST::TemplateArgument^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TemplateArgument*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateArgument(arg0);
 }
@@ -671,7 +771,14 @@ CppSharp::Parser::AST::TemplateSpecializationType::TemplateSpecializationType(::
 
 CppSharp::Parser::AST::TemplateSpecializationType^ CppSharp::Parser::AST::TemplateSpecializationType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TemplateSpecializationType((::CppSharp::CppParser::AST::TemplateSpecializationType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TemplateSpecializationType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TemplateSpecializationType^ CppSharp::Parser::AST::TemplateSpecializationType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TemplateSpecializationType^ result = gcnew ::CppSharp::Parser::AST::TemplateSpecializationType((::CppSharp::CppParser::AST::TemplateSpecializationType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TemplateSpecializationType::~TemplateSpecializationType()
@@ -681,12 +788,14 @@ CppSharp::Parser::AST::TemplateSpecializationType::~TemplateSpecializationType()
 CppSharp::Parser::AST::TemplateSpecializationType::TemplateSpecializationType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateSpecializationType();
 }
 
 CppSharp::Parser::AST::TemplateSpecializationType::TemplateSpecializationType(CppSharp::Parser::AST::TemplateSpecializationType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TemplateSpecializationType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateSpecializationType(arg0);
 }
@@ -743,7 +852,14 @@ CppSharp::Parser::AST::TemplateParameter::TemplateParameter(::CppSharp::CppParse
 
 CppSharp::Parser::AST::TemplateParameter^ CppSharp::Parser::AST::TemplateParameter::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TemplateParameter((::CppSharp::CppParser::AST::TemplateParameter*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TemplateParameter::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TemplateParameter^ CppSharp::Parser::AST::TemplateParameter::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TemplateParameter^ result = gcnew ::CppSharp::Parser::AST::TemplateParameter((::CppSharp::CppParser::AST::TemplateParameter*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TemplateParameter::~TemplateParameter()
@@ -753,14 +869,14 @@ CppSharp::Parser::AST::TemplateParameter::~TemplateParameter()
 }
 
 CppSharp::Parser::AST::TemplateParameter::TemplateParameter()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateParameter();
 }
 
 CppSharp::Parser::AST::TemplateParameter::TemplateParameter(CppSharp::Parser::AST::TemplateParameter^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TemplateParameter*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateParameter(arg0);
 }
@@ -819,7 +935,14 @@ CppSharp::Parser::AST::TemplateParameterType::TemplateParameterType(::CppSharp::
 
 CppSharp::Parser::AST::TemplateParameterType^ CppSharp::Parser::AST::TemplateParameterType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TemplateParameterType((::CppSharp::CppParser::AST::TemplateParameterType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TemplateParameterType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TemplateParameterType^ CppSharp::Parser::AST::TemplateParameterType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TemplateParameterType^ result = gcnew ::CppSharp::Parser::AST::TemplateParameterType((::CppSharp::CppParser::AST::TemplateParameterType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TemplateParameterType::~TemplateParameterType()
@@ -829,12 +952,14 @@ CppSharp::Parser::AST::TemplateParameterType::~TemplateParameterType()
 CppSharp::Parser::AST::TemplateParameterType::TemplateParameterType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateParameterType();
 }
 
 CppSharp::Parser::AST::TemplateParameterType::TemplateParameterType(CppSharp::Parser::AST::TemplateParameterType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TemplateParameterType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateParameterType(arg0);
 }
@@ -886,7 +1011,14 @@ CppSharp::Parser::AST::TemplateParameterSubstitutionType::TemplateParameterSubst
 
 CppSharp::Parser::AST::TemplateParameterSubstitutionType^ CppSharp::Parser::AST::TemplateParameterSubstitutionType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TemplateParameterSubstitutionType((::CppSharp::CppParser::AST::TemplateParameterSubstitutionType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TemplateParameterSubstitutionType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TemplateParameterSubstitutionType^ CppSharp::Parser::AST::TemplateParameterSubstitutionType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TemplateParameterSubstitutionType^ result = gcnew ::CppSharp::Parser::AST::TemplateParameterSubstitutionType((::CppSharp::CppParser::AST::TemplateParameterSubstitutionType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TemplateParameterSubstitutionType::~TemplateParameterSubstitutionType()
@@ -896,12 +1028,14 @@ CppSharp::Parser::AST::TemplateParameterSubstitutionType::~TemplateParameterSubs
 CppSharp::Parser::AST::TemplateParameterSubstitutionType::TemplateParameterSubstitutionType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateParameterSubstitutionType();
 }
 
 CppSharp::Parser::AST::TemplateParameterSubstitutionType::TemplateParameterSubstitutionType(CppSharp::Parser::AST::TemplateParameterSubstitutionType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TemplateParameterSubstitutionType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TemplateParameterSubstitutionType(arg0);
 }
@@ -923,7 +1057,14 @@ CppSharp::Parser::AST::InjectedClassNameType::InjectedClassNameType(::CppSharp::
 
 CppSharp::Parser::AST::InjectedClassNameType^ CppSharp::Parser::AST::InjectedClassNameType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::InjectedClassNameType((::CppSharp::CppParser::AST::InjectedClassNameType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::InjectedClassNameType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::InjectedClassNameType^ CppSharp::Parser::AST::InjectedClassNameType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::InjectedClassNameType^ result = gcnew ::CppSharp::Parser::AST::InjectedClassNameType((::CppSharp::CppParser::AST::InjectedClassNameType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::InjectedClassNameType::~InjectedClassNameType()
@@ -933,12 +1074,14 @@ CppSharp::Parser::AST::InjectedClassNameType::~InjectedClassNameType()
 CppSharp::Parser::AST::InjectedClassNameType::InjectedClassNameType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::InjectedClassNameType();
 }
 
 CppSharp::Parser::AST::InjectedClassNameType::InjectedClassNameType(CppSharp::Parser::AST::InjectedClassNameType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::InjectedClassNameType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::InjectedClassNameType(arg0);
 }
@@ -970,7 +1113,14 @@ CppSharp::Parser::AST::DependentNameType::DependentNameType(::CppSharp::CppParse
 
 CppSharp::Parser::AST::DependentNameType^ CppSharp::Parser::AST::DependentNameType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::DependentNameType((::CppSharp::CppParser::AST::DependentNameType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::DependentNameType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::DependentNameType^ CppSharp::Parser::AST::DependentNameType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::DependentNameType^ result = gcnew ::CppSharp::Parser::AST::DependentNameType((::CppSharp::CppParser::AST::DependentNameType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::DependentNameType::~DependentNameType()
@@ -980,12 +1130,14 @@ CppSharp::Parser::AST::DependentNameType::~DependentNameType()
 CppSharp::Parser::AST::DependentNameType::DependentNameType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::DependentNameType();
 }
 
 CppSharp::Parser::AST::DependentNameType::DependentNameType(CppSharp::Parser::AST::DependentNameType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::DependentNameType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::DependentNameType(arg0);
 }
@@ -997,7 +1149,14 @@ CppSharp::Parser::AST::PackExpansionType::PackExpansionType(::CppSharp::CppParse
 
 CppSharp::Parser::AST::PackExpansionType^ CppSharp::Parser::AST::PackExpansionType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::PackExpansionType((::CppSharp::CppParser::AST::PackExpansionType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::PackExpansionType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::PackExpansionType^ CppSharp::Parser::AST::PackExpansionType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::PackExpansionType^ result = gcnew ::CppSharp::Parser::AST::PackExpansionType((::CppSharp::CppParser::AST::PackExpansionType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::PackExpansionType::~PackExpansionType()
@@ -1007,12 +1166,14 @@ CppSharp::Parser::AST::PackExpansionType::~PackExpansionType()
 CppSharp::Parser::AST::PackExpansionType::PackExpansionType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::PackExpansionType();
 }
 
 CppSharp::Parser::AST::PackExpansionType::PackExpansionType(CppSharp::Parser::AST::PackExpansionType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::PackExpansionType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::PackExpansionType(arg0);
 }
@@ -1024,7 +1185,14 @@ CppSharp::Parser::AST::BuiltinType::BuiltinType(::CppSharp::CppParser::AST::Buil
 
 CppSharp::Parser::AST::BuiltinType^ CppSharp::Parser::AST::BuiltinType::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::BuiltinType((::CppSharp::CppParser::AST::BuiltinType*) native.ToPointer());
+    return ::CppSharp::Parser::AST::BuiltinType::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::BuiltinType^ CppSharp::Parser::AST::BuiltinType::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::BuiltinType^ result = gcnew ::CppSharp::Parser::AST::BuiltinType((::CppSharp::CppParser::AST::BuiltinType*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::BuiltinType::~BuiltinType()
@@ -1034,12 +1202,14 @@ CppSharp::Parser::AST::BuiltinType::~BuiltinType()
 CppSharp::Parser::AST::BuiltinType::BuiltinType()
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::BuiltinType();
 }
 
 CppSharp::Parser::AST::BuiltinType::BuiltinType(CppSharp::Parser::AST::BuiltinType^ _0)
     : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::BuiltinType*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::BuiltinType(arg0);
 }
@@ -1062,7 +1232,14 @@ CppSharp::Parser::AST::VTableComponent::VTableComponent(::CppSharp::CppParser::A
 
 CppSharp::Parser::AST::VTableComponent^ CppSharp::Parser::AST::VTableComponent::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::VTableComponent((::CppSharp::CppParser::AST::VTableComponent*) native.ToPointer());
+    return ::CppSharp::Parser::AST::VTableComponent::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::VTableComponent^ CppSharp::Parser::AST::VTableComponent::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::VTableComponent^ result = gcnew ::CppSharp::Parser::AST::VTableComponent((::CppSharp::CppParser::AST::VTableComponent*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::VTableComponent::~VTableComponent()
@@ -1072,14 +1249,14 @@ CppSharp::Parser::AST::VTableComponent::~VTableComponent()
 }
 
 CppSharp::Parser::AST::VTableComponent::VTableComponent()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::VTableComponent();
 }
 
 CppSharp::Parser::AST::VTableComponent::VTableComponent(CppSharp::Parser::AST::VTableComponent^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::VTableComponent*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::VTableComponent(arg0);
 }
@@ -1132,7 +1309,14 @@ CppSharp::Parser::AST::VTableLayout::VTableLayout(::CppSharp::CppParser::AST::VT
 
 CppSharp::Parser::AST::VTableLayout^ CppSharp::Parser::AST::VTableLayout::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::VTableLayout((::CppSharp::CppParser::AST::VTableLayout*) native.ToPointer());
+    return ::CppSharp::Parser::AST::VTableLayout::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::VTableLayout^ CppSharp::Parser::AST::VTableLayout::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::VTableLayout^ result = gcnew ::CppSharp::Parser::AST::VTableLayout((::CppSharp::CppParser::AST::VTableLayout*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::VTableLayout::~VTableLayout()
@@ -1142,14 +1326,14 @@ CppSharp::Parser::AST::VTableLayout::~VTableLayout()
 }
 
 CppSharp::Parser::AST::VTableLayout::VTableLayout()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::VTableLayout();
 }
 
 CppSharp::Parser::AST::VTableLayout::VTableLayout(CppSharp::Parser::AST::VTableLayout^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::VTableLayout*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::VTableLayout(arg0);
 }
@@ -1196,7 +1380,14 @@ CppSharp::Parser::AST::VFTableInfo::VFTableInfo(::CppSharp::CppParser::AST::VFTa
 
 CppSharp::Parser::AST::VFTableInfo^ CppSharp::Parser::AST::VFTableInfo::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::VFTableInfo((::CppSharp::CppParser::AST::VFTableInfo*) native.ToPointer());
+    return ::CppSharp::Parser::AST::VFTableInfo::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::VFTableInfo^ CppSharp::Parser::AST::VFTableInfo::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::VFTableInfo^ result = gcnew ::CppSharp::Parser::AST::VFTableInfo((::CppSharp::CppParser::AST::VFTableInfo*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::VFTableInfo::~VFTableInfo()
@@ -1206,14 +1397,14 @@ CppSharp::Parser::AST::VFTableInfo::~VFTableInfo()
 }
 
 CppSharp::Parser::AST::VFTableInfo::VFTableInfo()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::VFTableInfo();
 }
 
 CppSharp::Parser::AST::VFTableInfo::VFTableInfo(CppSharp::Parser::AST::VFTableInfo^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::VFTableInfo*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::VFTableInfo(arg0);
 }
@@ -1276,7 +1467,14 @@ CppSharp::Parser::AST::ClassLayout::ClassLayout(::CppSharp::CppParser::AST::Clas
 
 CppSharp::Parser::AST::ClassLayout^ CppSharp::Parser::AST::ClassLayout::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::ClassLayout((::CppSharp::CppParser::AST::ClassLayout*) native.ToPointer());
+    return ::CppSharp::Parser::AST::ClassLayout::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::ClassLayout^ CppSharp::Parser::AST::ClassLayout::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::ClassLayout^ result = gcnew ::CppSharp::Parser::AST::ClassLayout((::CppSharp::CppParser::AST::ClassLayout*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::ClassLayout::~ClassLayout()
@@ -1286,8 +1484,8 @@ CppSharp::Parser::AST::ClassLayout::~ClassLayout()
 }
 
 CppSharp::Parser::AST::ClassLayout::ClassLayout()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::ClassLayout();
 }
 
@@ -1310,8 +1508,8 @@ void CppSharp::Parser::AST::ClassLayout::clearVFTables()
 }
 
 CppSharp::Parser::AST::ClassLayout::ClassLayout(CppSharp::Parser::AST::ClassLayout^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::ClassLayout*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::ClassLayout(arg0);
 }
@@ -1410,7 +1608,14 @@ CppSharp::Parser::AST::Declaration::Declaration(::CppSharp::CppParser::AST::Decl
 
 CppSharp::Parser::AST::Declaration^ CppSharp::Parser::AST::Declaration::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Declaration::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Declaration^ CppSharp::Parser::AST::Declaration::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Declaration^ result = gcnew ::CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Declaration::~Declaration()
@@ -1420,15 +1625,15 @@ CppSharp::Parser::AST::Declaration::~Declaration()
 }
 
 CppSharp::Parser::AST::Declaration::Declaration(CppSharp::Parser::AST::DeclarationKind kind)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::DeclarationKind)kind;
     NativePtr = new ::CppSharp::CppParser::AST::Declaration(arg0);
 }
 
 CppSharp::Parser::AST::Declaration::Declaration(CppSharp::Parser::AST::Declaration^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Declaration*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Declaration(arg0);
 }
@@ -1624,7 +1829,14 @@ CppSharp::Parser::AST::DeclarationContext::DeclarationContext(::CppSharp::CppPar
 
 CppSharp::Parser::AST::DeclarationContext^ CppSharp::Parser::AST::DeclarationContext::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*) native.ToPointer());
+    return ::CppSharp::Parser::AST::DeclarationContext::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::DeclarationContext^ CppSharp::Parser::AST::DeclarationContext::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::DeclarationContext^ result = gcnew ::CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::DeclarationContext::~DeclarationContext()
@@ -1634,6 +1846,7 @@ CppSharp::Parser::AST::DeclarationContext::~DeclarationContext()
 CppSharp::Parser::AST::DeclarationContext::DeclarationContext(CppSharp::Parser::AST::DeclarationKind kind)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::DeclarationKind)kind;
     NativePtr = new ::CppSharp::CppParser::AST::DeclarationContext(arg0);
 }
@@ -1785,6 +1998,7 @@ void CppSharp::Parser::AST::DeclarationContext::clearFriends()
 CppSharp::Parser::AST::DeclarationContext::DeclarationContext(CppSharp::Parser::AST::DeclarationContext^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::DeclarationContext*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::DeclarationContext(arg0);
 }
@@ -1854,7 +2068,14 @@ CppSharp::Parser::AST::TypedefDecl::TypedefDecl(::CppSharp::CppParser::AST::Type
 
 CppSharp::Parser::AST::TypedefDecl^ CppSharp::Parser::AST::TypedefDecl::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TypedefDecl((::CppSharp::CppParser::AST::TypedefDecl*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TypedefDecl::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TypedefDecl^ CppSharp::Parser::AST::TypedefDecl::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TypedefDecl^ result = gcnew ::CppSharp::Parser::AST::TypedefDecl((::CppSharp::CppParser::AST::TypedefDecl*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TypedefDecl::~TypedefDecl()
@@ -1864,12 +2085,14 @@ CppSharp::Parser::AST::TypedefDecl::~TypedefDecl()
 CppSharp::Parser::AST::TypedefDecl::TypedefDecl()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TypedefDecl();
 }
 
 CppSharp::Parser::AST::TypedefDecl::TypedefDecl(CppSharp::Parser::AST::TypedefDecl^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TypedefDecl*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TypedefDecl(arg0);
 }
@@ -1891,7 +2114,14 @@ CppSharp::Parser::AST::Friend::Friend(::CppSharp::CppParser::AST::Friend* native
 
 CppSharp::Parser::AST::Friend^ CppSharp::Parser::AST::Friend::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Friend((::CppSharp::CppParser::AST::Friend*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Friend::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Friend^ CppSharp::Parser::AST::Friend::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Friend^ result = gcnew ::CppSharp::Parser::AST::Friend((::CppSharp::CppParser::AST::Friend*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Friend::~Friend()
@@ -1901,12 +2131,14 @@ CppSharp::Parser::AST::Friend::~Friend()
 CppSharp::Parser::AST::Friend::Friend()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Friend();
 }
 
 CppSharp::Parser::AST::Friend::Friend(CppSharp::Parser::AST::Friend^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Friend*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Friend(arg0);
 }
@@ -1929,7 +2161,14 @@ CppSharp::Parser::AST::Statement::Statement(::CppSharp::CppParser::AST::Statemen
 
 CppSharp::Parser::AST::Statement^ CppSharp::Parser::AST::Statement::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Statement((::CppSharp::CppParser::AST::Statement*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Statement::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Statement^ CppSharp::Parser::AST::Statement::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Statement^ result = gcnew ::CppSharp::Parser::AST::Statement((::CppSharp::CppParser::AST::Statement*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Statement::~Statement()
@@ -1939,8 +2178,8 @@ CppSharp::Parser::AST::Statement::~Statement()
 }
 
 CppSharp::Parser::AST::Statement::Statement(CppSharp::Parser::AST::Statement^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Statement*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Statement(arg0);
 }
@@ -1996,7 +2235,14 @@ CppSharp::Parser::AST::Expression::Expression(::CppSharp::CppParser::AST::Expres
 
 CppSharp::Parser::AST::Expression^ CppSharp::Parser::AST::Expression::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Expression((::CppSharp::CppParser::AST::Expression*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Expression::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Expression^ CppSharp::Parser::AST::Expression::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Expression^ result = gcnew ::CppSharp::Parser::AST::Expression((::CppSharp::CppParser::AST::Expression*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Expression::~Expression()
@@ -2006,6 +2252,7 @@ CppSharp::Parser::AST::Expression::~Expression()
 CppSharp::Parser::AST::Expression::Expression(CppSharp::Parser::AST::Expression^ _0)
     : CppSharp::Parser::AST::Statement((::CppSharp::CppParser::AST::Statement*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Expression*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Expression(arg0);
 }
@@ -2017,7 +2264,14 @@ CppSharp::Parser::AST::BinaryOperator::BinaryOperator(::CppSharp::CppParser::AST
 
 CppSharp::Parser::AST::BinaryOperator^ CppSharp::Parser::AST::BinaryOperator::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::BinaryOperator((::CppSharp::CppParser::AST::BinaryOperator*) native.ToPointer());
+    return ::CppSharp::Parser::AST::BinaryOperator::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::BinaryOperator^ CppSharp::Parser::AST::BinaryOperator::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::BinaryOperator^ result = gcnew ::CppSharp::Parser::AST::BinaryOperator((::CppSharp::CppParser::AST::BinaryOperator*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::BinaryOperator::~BinaryOperator()
@@ -2027,6 +2281,7 @@ CppSharp::Parser::AST::BinaryOperator::~BinaryOperator()
 CppSharp::Parser::AST::BinaryOperator::BinaryOperator(CppSharp::Parser::AST::BinaryOperator^ _0)
     : CppSharp::Parser::AST::Expression((::CppSharp::CppParser::AST::Expression*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::BinaryOperator*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::BinaryOperator(arg0);
 }
@@ -2072,7 +2327,14 @@ CppSharp::Parser::AST::CXXConstructExpr::CXXConstructExpr(::CppSharp::CppParser:
 
 CppSharp::Parser::AST::CXXConstructExpr^ CppSharp::Parser::AST::CXXConstructExpr::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::CXXConstructExpr((::CppSharp::CppParser::AST::CXXConstructExpr*) native.ToPointer());
+    return ::CppSharp::Parser::AST::CXXConstructExpr::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::CXXConstructExpr^ CppSharp::Parser::AST::CXXConstructExpr::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::CXXConstructExpr^ result = gcnew ::CppSharp::Parser::AST::CXXConstructExpr((::CppSharp::CppParser::AST::CXXConstructExpr*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::CXXConstructExpr::~CXXConstructExpr()
@@ -2100,6 +2362,7 @@ void CppSharp::Parser::AST::CXXConstructExpr::clearArguments()
 CppSharp::Parser::AST::CXXConstructExpr::CXXConstructExpr(CppSharp::Parser::AST::CXXConstructExpr^ _0)
     : CppSharp::Parser::AST::Expression((::CppSharp::CppParser::AST::Expression*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::CXXConstructExpr*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::CXXConstructExpr(arg0);
 }
@@ -2117,7 +2380,14 @@ CppSharp::Parser::AST::Parameter::Parameter(::CppSharp::CppParser::AST::Paramete
 
 CppSharp::Parser::AST::Parameter^ CppSharp::Parser::AST::Parameter::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Parameter((::CppSharp::CppParser::AST::Parameter*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Parameter::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Parameter^ CppSharp::Parser::AST::Parameter::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Parameter^ result = gcnew ::CppSharp::Parser::AST::Parameter((::CppSharp::CppParser::AST::Parameter*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Parameter::~Parameter()
@@ -2127,12 +2397,14 @@ CppSharp::Parser::AST::Parameter::~Parameter()
 CppSharp::Parser::AST::Parameter::Parameter()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Parameter();
 }
 
 CppSharp::Parser::AST::Parameter::Parameter(CppSharp::Parser::AST::Parameter^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Parameter*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Parameter(arg0);
 }
@@ -2194,7 +2466,14 @@ CppSharp::Parser::AST::Function::Function(::CppSharp::CppParser::AST::Function*
 
 CppSharp::Parser::AST::Function^ CppSharp::Parser::AST::Function::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Function((::CppSharp::CppParser::AST::Function*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Function::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Function^ CppSharp::Parser::AST::Function::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Function^ result = gcnew ::CppSharp::Parser::AST::Function((::CppSharp::CppParser::AST::Function*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Function::~Function()
@@ -2204,6 +2483,7 @@ CppSharp::Parser::AST::Function::~Function()
 CppSharp::Parser::AST::Function::Function()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Function();
 }
 
@@ -2228,6 +2508,7 @@ void CppSharp::Parser::AST::Function::clearParameters()
 CppSharp::Parser::AST::Function::Function(CppSharp::Parser::AST::Function^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Function*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Function(arg0);
 }
@@ -2373,7 +2654,14 @@ CppSharp::Parser::AST::Method::Method(::CppSharp::CppParser::AST::Method* native
 
 CppSharp::Parser::AST::Method^ CppSharp::Parser::AST::Method::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Method((::CppSharp::CppParser::AST::Method*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Method::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Method^ CppSharp::Parser::AST::Method::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Method^ result = gcnew ::CppSharp::Parser::AST::Method((::CppSharp::CppParser::AST::Method*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Method::~Method()
@@ -2383,12 +2671,14 @@ CppSharp::Parser::AST::Method::~Method()
 CppSharp::Parser::AST::Method::Method()
     : CppSharp::Parser::AST::Function((::CppSharp::CppParser::AST::Function*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Method();
 }
 
 CppSharp::Parser::AST::Method::Method(CppSharp::Parser::AST::Method^ _0)
     : CppSharp::Parser::AST::Function((::CppSharp::CppParser::AST::Function*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Method*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Method(arg0);
 }
@@ -2520,7 +2810,14 @@ CppSharp::Parser::AST::Enumeration::Item::Item(::CppSharp::CppParser::AST::Enume
 
 CppSharp::Parser::AST::Enumeration::Item^ CppSharp::Parser::AST::Enumeration::Item::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Enumeration::Item((::CppSharp::CppParser::AST::Enumeration::Item*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Enumeration::Item::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Enumeration::Item^ CppSharp::Parser::AST::Enumeration::Item::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Enumeration::Item^ result = gcnew ::CppSharp::Parser::AST::Enumeration::Item((::CppSharp::CppParser::AST::Enumeration::Item*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Enumeration::Item::~Item()
@@ -2530,12 +2827,14 @@ CppSharp::Parser::AST::Enumeration::Item::~Item()
 CppSharp::Parser::AST::Enumeration::Item::Item()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Enumeration::Item();
 }
 
 CppSharp::Parser::AST::Enumeration::Item::Item(CppSharp::Parser::AST::Enumeration::Item^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Enumeration::Item*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Enumeration::Item(arg0);
 }
@@ -2571,7 +2870,14 @@ CppSharp::Parser::AST::Enumeration::Enumeration(::CppSharp::CppParser::AST::Enum
 
 CppSharp::Parser::AST::Enumeration^ CppSharp::Parser::AST::Enumeration::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Enumeration((::CppSharp::CppParser::AST::Enumeration*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Enumeration::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Enumeration^ CppSharp::Parser::AST::Enumeration::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Enumeration^ result = gcnew ::CppSharp::Parser::AST::Enumeration((::CppSharp::CppParser::AST::Enumeration*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Enumeration::~Enumeration()
@@ -2581,6 +2887,7 @@ CppSharp::Parser::AST::Enumeration::~Enumeration()
 CppSharp::Parser::AST::Enumeration::Enumeration()
     : CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Enumeration();
 }
 
@@ -2605,6 +2912,7 @@ void CppSharp::Parser::AST::Enumeration::clearItems()
 CppSharp::Parser::AST::Enumeration::Enumeration(CppSharp::Parser::AST::Enumeration^ _0)
     : CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Enumeration*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Enumeration(arg0);
 }
@@ -2652,7 +2960,14 @@ CppSharp::Parser::AST::Variable::Variable(::CppSharp::CppParser::AST::Variable*
 
 CppSharp::Parser::AST::Variable^ CppSharp::Parser::AST::Variable::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Variable((::CppSharp::CppParser::AST::Variable*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Variable::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Variable^ CppSharp::Parser::AST::Variable::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Variable^ result = gcnew ::CppSharp::Parser::AST::Variable((::CppSharp::CppParser::AST::Variable*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Variable::~Variable()
@@ -2662,12 +2977,14 @@ CppSharp::Parser::AST::Variable::~Variable()
 CppSharp::Parser::AST::Variable::Variable()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Variable();
 }
 
 CppSharp::Parser::AST::Variable::Variable(CppSharp::Parser::AST::Variable^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Variable*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Variable(arg0);
 }
@@ -2704,7 +3021,14 @@ CppSharp::Parser::AST::BaseClassSpecifier::BaseClassSpecifier(::CppSharp::CppPar
 
 CppSharp::Parser::AST::BaseClassSpecifier^ CppSharp::Parser::AST::BaseClassSpecifier::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::BaseClassSpecifier((::CppSharp::CppParser::AST::BaseClassSpecifier*) native.ToPointer());
+    return ::CppSharp::Parser::AST::BaseClassSpecifier::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::BaseClassSpecifier^ CppSharp::Parser::AST::BaseClassSpecifier::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::BaseClassSpecifier^ result = gcnew ::CppSharp::Parser::AST::BaseClassSpecifier((::CppSharp::CppParser::AST::BaseClassSpecifier*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::BaseClassSpecifier::~BaseClassSpecifier()
@@ -2714,14 +3038,14 @@ CppSharp::Parser::AST::BaseClassSpecifier::~BaseClassSpecifier()
 }
 
 CppSharp::Parser::AST::BaseClassSpecifier::BaseClassSpecifier()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::BaseClassSpecifier();
 }
 
 CppSharp::Parser::AST::BaseClassSpecifier::BaseClassSpecifier(CppSharp::Parser::AST::BaseClassSpecifier^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::BaseClassSpecifier*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::BaseClassSpecifier(arg0);
 }
@@ -2783,7 +3107,14 @@ CppSharp::Parser::AST::Field::Field(::CppSharp::CppParser::AST::Field* native)
 
 CppSharp::Parser::AST::Field^ CppSharp::Parser::AST::Field::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Field((::CppSharp::CppParser::AST::Field*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Field::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Field^ CppSharp::Parser::AST::Field::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Field^ result = gcnew ::CppSharp::Parser::AST::Field((::CppSharp::CppParser::AST::Field*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Field::~Field()
@@ -2793,12 +3124,14 @@ CppSharp::Parser::AST::Field::~Field()
 CppSharp::Parser::AST::Field::Field()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Field();
 }
 
 CppSharp::Parser::AST::Field::Field(CppSharp::Parser::AST::Field^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Field*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Field(arg0);
 }
@@ -2860,7 +3193,14 @@ CppSharp::Parser::AST::AccessSpecifierDecl::AccessSpecifierDecl(::CppSharp::CppP
 
 CppSharp::Parser::AST::AccessSpecifierDecl^ CppSharp::Parser::AST::AccessSpecifierDecl::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::AccessSpecifierDecl((::CppSharp::CppParser::AST::AccessSpecifierDecl*) native.ToPointer());
+    return ::CppSharp::Parser::AST::AccessSpecifierDecl::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::AccessSpecifierDecl^ CppSharp::Parser::AST::AccessSpecifierDecl::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::AccessSpecifierDecl^ result = gcnew ::CppSharp::Parser::AST::AccessSpecifierDecl((::CppSharp::CppParser::AST::AccessSpecifierDecl*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::AccessSpecifierDecl::~AccessSpecifierDecl()
@@ -2870,12 +3210,14 @@ CppSharp::Parser::AST::AccessSpecifierDecl::~AccessSpecifierDecl()
 CppSharp::Parser::AST::AccessSpecifierDecl::AccessSpecifierDecl()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::AccessSpecifierDecl();
 }
 
 CppSharp::Parser::AST::AccessSpecifierDecl::AccessSpecifierDecl(CppSharp::Parser::AST::AccessSpecifierDecl^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::AccessSpecifierDecl*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::AccessSpecifierDecl(arg0);
 }
@@ -2887,7 +3229,14 @@ CppSharp::Parser::AST::Class::Class(::CppSharp::CppParser::AST::Class* native)
 
 CppSharp::Parser::AST::Class^ CppSharp::Parser::AST::Class::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Class((::CppSharp::CppParser::AST::Class*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Class::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Class^ CppSharp::Parser::AST::Class::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Class^ result = gcnew ::CppSharp::Parser::AST::Class((::CppSharp::CppParser::AST::Class*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Class::~Class()
@@ -2897,6 +3246,7 @@ CppSharp::Parser::AST::Class::~Class()
 CppSharp::Parser::AST::Class::Class()
     : CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Class();
 }
 
@@ -2975,6 +3325,7 @@ void CppSharp::Parser::AST::Class::clearSpecifiers()
 CppSharp::Parser::AST::Class::Class(CppSharp::Parser::AST::Class^ _0)
     : CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Class*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Class(arg0);
 }
@@ -3110,7 +3461,14 @@ CppSharp::Parser::AST::Template::Template(::CppSharp::CppParser::AST::Template*
 
 CppSharp::Parser::AST::Template^ CppSharp::Parser::AST::Template::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Template((::CppSharp::CppParser::AST::Template*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Template::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Template^ CppSharp::Parser::AST::Template::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Template^ result = gcnew ::CppSharp::Parser::AST::Template((::CppSharp::CppParser::AST::Template*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Template::~Template()
@@ -3120,6 +3478,7 @@ CppSharp::Parser::AST::Template::~Template()
 CppSharp::Parser::AST::Template::Template(CppSharp::Parser::AST::DeclarationKind kind)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::DeclarationKind)kind;
     NativePtr = new ::CppSharp::CppParser::AST::Template(arg0);
 }
@@ -3127,6 +3486,7 @@ CppSharp::Parser::AST::Template::Template(CppSharp::Parser::AST::DeclarationKind
 CppSharp::Parser::AST::Template::Template()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Template();
 }
 
@@ -3151,6 +3511,7 @@ void CppSharp::Parser::AST::Template::clearParameters()
 CppSharp::Parser::AST::Template::Template(CppSharp::Parser::AST::Template^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Template*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Template(arg0);
 }
@@ -3178,7 +3539,14 @@ CppSharp::Parser::AST::ClassTemplate::ClassTemplate(::CppSharp::CppParser::AST::
 
 CppSharp::Parser::AST::ClassTemplate^ CppSharp::Parser::AST::ClassTemplate::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::ClassTemplate((::CppSharp::CppParser::AST::ClassTemplate*) native.ToPointer());
+    return ::CppSharp::Parser::AST::ClassTemplate::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::ClassTemplate^ CppSharp::Parser::AST::ClassTemplate::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::ClassTemplate^ result = gcnew ::CppSharp::Parser::AST::ClassTemplate((::CppSharp::CppParser::AST::ClassTemplate*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::ClassTemplate::~ClassTemplate()
@@ -3188,6 +3556,7 @@ CppSharp::Parser::AST::ClassTemplate::~ClassTemplate()
 CppSharp::Parser::AST::ClassTemplate::ClassTemplate()
     : CppSharp::Parser::AST::Template((::CppSharp::CppParser::AST::Template*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::ClassTemplate();
 }
 
@@ -3212,6 +3581,7 @@ void CppSharp::Parser::AST::ClassTemplate::clearSpecializations()
 CppSharp::Parser::AST::ClassTemplate::ClassTemplate(CppSharp::Parser::AST::ClassTemplate^ _0)
     : CppSharp::Parser::AST::Template((::CppSharp::CppParser::AST::Template*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::ClassTemplate*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::ClassTemplate(arg0);
 }
@@ -3229,7 +3599,14 @@ CppSharp::Parser::AST::ClassTemplateSpecialization::ClassTemplateSpecialization(
 
 CppSharp::Parser::AST::ClassTemplateSpecialization^ CppSharp::Parser::AST::ClassTemplateSpecialization::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::ClassTemplateSpecialization((::CppSharp::CppParser::AST::ClassTemplateSpecialization*) native.ToPointer());
+    return ::CppSharp::Parser::AST::ClassTemplateSpecialization::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::ClassTemplateSpecialization^ CppSharp::Parser::AST::ClassTemplateSpecialization::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::ClassTemplateSpecialization^ result = gcnew ::CppSharp::Parser::AST::ClassTemplateSpecialization((::CppSharp::CppParser::AST::ClassTemplateSpecialization*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::ClassTemplateSpecialization::~ClassTemplateSpecialization()
@@ -3239,6 +3616,7 @@ CppSharp::Parser::AST::ClassTemplateSpecialization::~ClassTemplateSpecialization
 CppSharp::Parser::AST::ClassTemplateSpecialization::ClassTemplateSpecialization()
     : CppSharp::Parser::AST::Class((::CppSharp::CppParser::AST::Class*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::ClassTemplateSpecialization();
 }
 
@@ -3263,6 +3641,7 @@ void CppSharp::Parser::AST::ClassTemplateSpecialization::clearArguments()
 CppSharp::Parser::AST::ClassTemplateSpecialization::ClassTemplateSpecialization(CppSharp::Parser::AST::ClassTemplateSpecialization^ _0)
     : CppSharp::Parser::AST::Class((::CppSharp::CppParser::AST::Class*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::ClassTemplateSpecialization*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::ClassTemplateSpecialization(arg0);
 }
@@ -3300,7 +3679,14 @@ CppSharp::Parser::AST::ClassTemplatePartialSpecialization::ClassTemplatePartialS
 
 CppSharp::Parser::AST::ClassTemplatePartialSpecialization^ CppSharp::Parser::AST::ClassTemplatePartialSpecialization::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::ClassTemplatePartialSpecialization((::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*) native.ToPointer());
+    return ::CppSharp::Parser::AST::ClassTemplatePartialSpecialization::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::ClassTemplatePartialSpecialization^ CppSharp::Parser::AST::ClassTemplatePartialSpecialization::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::ClassTemplatePartialSpecialization^ result = gcnew ::CppSharp::Parser::AST::ClassTemplatePartialSpecialization((::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::ClassTemplatePartialSpecialization::~ClassTemplatePartialSpecialization()
@@ -3310,12 +3696,14 @@ CppSharp::Parser::AST::ClassTemplatePartialSpecialization::~ClassTemplatePartial
 CppSharp::Parser::AST::ClassTemplatePartialSpecialization::ClassTemplatePartialSpecialization()
     : CppSharp::Parser::AST::ClassTemplateSpecialization((::CppSharp::CppParser::AST::ClassTemplateSpecialization*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization();
 }
 
 CppSharp::Parser::AST::ClassTemplatePartialSpecialization::ClassTemplatePartialSpecialization(CppSharp::Parser::AST::ClassTemplatePartialSpecialization^ _0)
     : CppSharp::Parser::AST::ClassTemplateSpecialization((::CppSharp::CppParser::AST::ClassTemplateSpecialization*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization(arg0);
 }
@@ -3327,7 +3715,14 @@ CppSharp::Parser::AST::FunctionTemplate::FunctionTemplate(::CppSharp::CppParser:
 
 CppSharp::Parser::AST::FunctionTemplate^ CppSharp::Parser::AST::FunctionTemplate::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::FunctionTemplate((::CppSharp::CppParser::AST::FunctionTemplate*) native.ToPointer());
+    return ::CppSharp::Parser::AST::FunctionTemplate::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::FunctionTemplate^ CppSharp::Parser::AST::FunctionTemplate::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::FunctionTemplate^ result = gcnew ::CppSharp::Parser::AST::FunctionTemplate((::CppSharp::CppParser::AST::FunctionTemplate*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::FunctionTemplate::~FunctionTemplate()
@@ -3337,6 +3732,7 @@ CppSharp::Parser::AST::FunctionTemplate::~FunctionTemplate()
 CppSharp::Parser::AST::FunctionTemplate::FunctionTemplate()
     : CppSharp::Parser::AST::Template((::CppSharp::CppParser::AST::Template*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::FunctionTemplate();
 }
 
@@ -3361,6 +3757,7 @@ void CppSharp::Parser::AST::FunctionTemplate::clearSpecializations()
 CppSharp::Parser::AST::FunctionTemplate::FunctionTemplate(CppSharp::Parser::AST::FunctionTemplate^ _0)
     : CppSharp::Parser::AST::Template((::CppSharp::CppParser::AST::Template*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::FunctionTemplate*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::FunctionTemplate(arg0);
 }
@@ -3379,7 +3776,14 @@ CppSharp::Parser::AST::FunctionTemplateSpecialization::FunctionTemplateSpecializ
 
 CppSharp::Parser::AST::FunctionTemplateSpecialization^ CppSharp::Parser::AST::FunctionTemplateSpecialization::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::FunctionTemplateSpecialization((::CppSharp::CppParser::AST::FunctionTemplateSpecialization*) native.ToPointer());
+    return ::CppSharp::Parser::AST::FunctionTemplateSpecialization::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::FunctionTemplateSpecialization^ CppSharp::Parser::AST::FunctionTemplateSpecialization::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::FunctionTemplateSpecialization^ result = gcnew ::CppSharp::Parser::AST::FunctionTemplateSpecialization((::CppSharp::CppParser::AST::FunctionTemplateSpecialization*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::FunctionTemplateSpecialization::~FunctionTemplateSpecialization()
@@ -3389,8 +3793,8 @@ CppSharp::Parser::AST::FunctionTemplateSpecialization::~FunctionTemplateSpeciali
 }
 
 CppSharp::Parser::AST::FunctionTemplateSpecialization::FunctionTemplateSpecialization()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::FunctionTemplateSpecialization();
 }
 
@@ -3413,8 +3817,8 @@ void CppSharp::Parser::AST::FunctionTemplateSpecialization::clearArguments()
 }
 
 CppSharp::Parser::AST::FunctionTemplateSpecialization::FunctionTemplateSpecialization(CppSharp::Parser::AST::FunctionTemplateSpecialization^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::FunctionTemplateSpecialization*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::FunctionTemplateSpecialization(arg0);
 }
@@ -3472,7 +3876,14 @@ CppSharp::Parser::AST::Namespace::Namespace(::CppSharp::CppParser::AST::Namespac
 
 CppSharp::Parser::AST::Namespace^ CppSharp::Parser::AST::Namespace::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Namespace((::CppSharp::CppParser::AST::Namespace*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Namespace::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Namespace^ CppSharp::Parser::AST::Namespace::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Namespace^ result = gcnew ::CppSharp::Parser::AST::Namespace((::CppSharp::CppParser::AST::Namespace*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Namespace::~Namespace()
@@ -3482,12 +3893,14 @@ CppSharp::Parser::AST::Namespace::~Namespace()
 CppSharp::Parser::AST::Namespace::Namespace()
     : CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::Namespace();
 }
 
 CppSharp::Parser::AST::Namespace::Namespace(CppSharp::Parser::AST::Namespace^ _0)
     : CppSharp::Parser::AST::DeclarationContext((::CppSharp::CppParser::AST::DeclarationContext*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Namespace*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Namespace(arg0);
 }
@@ -3509,7 +3922,14 @@ CppSharp::Parser::AST::PreprocessedEntity::PreprocessedEntity(::CppSharp::CppPar
 
 CppSharp::Parser::AST::PreprocessedEntity^ CppSharp::Parser::AST::PreprocessedEntity::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::PreprocessedEntity((::CppSharp::CppParser::AST::PreprocessedEntity*) native.ToPointer());
+    return ::CppSharp::Parser::AST::PreprocessedEntity::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::PreprocessedEntity^ CppSharp::Parser::AST::PreprocessedEntity::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::PreprocessedEntity^ result = gcnew ::CppSharp::Parser::AST::PreprocessedEntity((::CppSharp::CppParser::AST::PreprocessedEntity*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::PreprocessedEntity::~PreprocessedEntity()
@@ -3519,12 +3939,14 @@ CppSharp::Parser::AST::PreprocessedEntity::~PreprocessedEntity()
 CppSharp::Parser::AST::PreprocessedEntity::PreprocessedEntity()
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::PreprocessedEntity();
 }
 
 CppSharp::Parser::AST::PreprocessedEntity::PreprocessedEntity(CppSharp::Parser::AST::PreprocessedEntity^ _0)
     : CppSharp::Parser::AST::Declaration((::CppSharp::CppParser::AST::Declaration*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::PreprocessedEntity*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::PreprocessedEntity(arg0);
 }
@@ -3546,7 +3968,14 @@ CppSharp::Parser::AST::MacroDefinition::MacroDefinition(::CppSharp::CppParser::A
 
 CppSharp::Parser::AST::MacroDefinition^ CppSharp::Parser::AST::MacroDefinition::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::MacroDefinition((::CppSharp::CppParser::AST::MacroDefinition*) native.ToPointer());
+    return ::CppSharp::Parser::AST::MacroDefinition::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::MacroDefinition^ CppSharp::Parser::AST::MacroDefinition::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::MacroDefinition^ result = gcnew ::CppSharp::Parser::AST::MacroDefinition((::CppSharp::CppParser::AST::MacroDefinition*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::MacroDefinition::~MacroDefinition()
@@ -3556,12 +3985,14 @@ CppSharp::Parser::AST::MacroDefinition::~MacroDefinition()
 CppSharp::Parser::AST::MacroDefinition::MacroDefinition()
     : CppSharp::Parser::AST::PreprocessedEntity((::CppSharp::CppParser::AST::PreprocessedEntity*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::MacroDefinition();
 }
 
 CppSharp::Parser::AST::MacroDefinition::MacroDefinition(CppSharp::Parser::AST::MacroDefinition^ _0)
     : CppSharp::Parser::AST::PreprocessedEntity((::CppSharp::CppParser::AST::PreprocessedEntity*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::MacroDefinition*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::MacroDefinition(arg0);
 }
@@ -3587,7 +4018,14 @@ CppSharp::Parser::AST::MacroExpansion::MacroExpansion(::CppSharp::CppParser::AST
 
 CppSharp::Parser::AST::MacroExpansion^ CppSharp::Parser::AST::MacroExpansion::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::MacroExpansion((::CppSharp::CppParser::AST::MacroExpansion*) native.ToPointer());
+    return ::CppSharp::Parser::AST::MacroExpansion::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::MacroExpansion^ CppSharp::Parser::AST::MacroExpansion::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::MacroExpansion^ result = gcnew ::CppSharp::Parser::AST::MacroExpansion((::CppSharp::CppParser::AST::MacroExpansion*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::MacroExpansion::~MacroExpansion()
@@ -3597,12 +4035,14 @@ CppSharp::Parser::AST::MacroExpansion::~MacroExpansion()
 CppSharp::Parser::AST::MacroExpansion::MacroExpansion()
     : CppSharp::Parser::AST::PreprocessedEntity((::CppSharp::CppParser::AST::PreprocessedEntity*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::MacroExpansion();
 }
 
 CppSharp::Parser::AST::MacroExpansion::MacroExpansion(CppSharp::Parser::AST::MacroExpansion^ _0)
     : CppSharp::Parser::AST::PreprocessedEntity((::CppSharp::CppParser::AST::PreprocessedEntity*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::MacroExpansion*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::MacroExpansion(arg0);
 }
@@ -3638,7 +4078,14 @@ CppSharp::Parser::AST::TranslationUnit::TranslationUnit(::CppSharp::CppParser::A
 
 CppSharp::Parser::AST::TranslationUnit^ CppSharp::Parser::AST::TranslationUnit::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TranslationUnit((::CppSharp::CppParser::AST::TranslationUnit*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TranslationUnit::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TranslationUnit^ CppSharp::Parser::AST::TranslationUnit::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TranslationUnit^ result = gcnew ::CppSharp::Parser::AST::TranslationUnit((::CppSharp::CppParser::AST::TranslationUnit*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TranslationUnit::~TranslationUnit()
@@ -3648,6 +4095,7 @@ CppSharp::Parser::AST::TranslationUnit::~TranslationUnit()
 CppSharp::Parser::AST::TranslationUnit::TranslationUnit()
     : CppSharp::Parser::AST::Namespace((::CppSharp::CppParser::AST::Namespace*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TranslationUnit();
 }
 
@@ -3672,6 +4120,7 @@ void CppSharp::Parser::AST::TranslationUnit::clearMacros()
 CppSharp::Parser::AST::TranslationUnit::TranslationUnit(CppSharp::Parser::AST::TranslationUnit^ _0)
     : CppSharp::Parser::AST::Namespace((::CppSharp::CppParser::AST::Namespace*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TranslationUnit*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TranslationUnit(arg0);
 }
@@ -3714,7 +4163,14 @@ CppSharp::Parser::AST::NativeLibrary::NativeLibrary(::CppSharp::CppParser::AST::
 
 CppSharp::Parser::AST::NativeLibrary^ CppSharp::Parser::AST::NativeLibrary::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::NativeLibrary((::CppSharp::CppParser::AST::NativeLibrary*) native.ToPointer());
+    return ::CppSharp::Parser::AST::NativeLibrary::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::NativeLibrary^ CppSharp::Parser::AST::NativeLibrary::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::NativeLibrary^ result = gcnew ::CppSharp::Parser::AST::NativeLibrary((::CppSharp::CppParser::AST::NativeLibrary*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::NativeLibrary::~NativeLibrary()
@@ -3724,8 +4180,8 @@ CppSharp::Parser::AST::NativeLibrary::~NativeLibrary()
 }
 
 CppSharp::Parser::AST::NativeLibrary::NativeLibrary()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::NativeLibrary();
 }
 
@@ -3768,8 +4224,8 @@ void CppSharp::Parser::AST::NativeLibrary::clearDependencies()
 }
 
 CppSharp::Parser::AST::NativeLibrary::NativeLibrary(CppSharp::Parser::AST::NativeLibrary^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::NativeLibrary*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::NativeLibrary(arg0);
 }
@@ -3828,7 +4284,14 @@ CppSharp::Parser::AST::ASTContext::ASTContext(::CppSharp::CppParser::AST::ASTCon
 
 CppSharp::Parser::AST::ASTContext^ CppSharp::Parser::AST::ASTContext::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::ASTContext((::CppSharp::CppParser::AST::ASTContext*) native.ToPointer());
+    return ::CppSharp::Parser::AST::ASTContext::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::ASTContext^ CppSharp::Parser::AST::ASTContext::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::ASTContext^ result = gcnew ::CppSharp::Parser::AST::ASTContext((::CppSharp::CppParser::AST::ASTContext*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::ASTContext::~ASTContext()
@@ -3838,8 +4301,8 @@ CppSharp::Parser::AST::ASTContext::~ASTContext()
 }
 
 CppSharp::Parser::AST::ASTContext::ASTContext()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::ASTContext();
 }
 
@@ -3862,8 +4325,8 @@ void CppSharp::Parser::AST::ASTContext::clearTranslationUnits()
 }
 
 CppSharp::Parser::AST::ASTContext::ASTContext(CppSharp::Parser::AST::ASTContext^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::ASTContext*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::ASTContext(arg0);
 }
@@ -3892,7 +4355,14 @@ CppSharp::Parser::AST::Comment::Comment(::CppSharp::CppParser::AST::Comment* nat
 
 CppSharp::Parser::AST::Comment^ CppSharp::Parser::AST::Comment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::Comment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::Comment^ CppSharp::Parser::AST::Comment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::Comment^ result = gcnew ::CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::Comment::~Comment()
@@ -3902,15 +4372,15 @@ CppSharp::Parser::AST::Comment::~Comment()
 }
 
 CppSharp::Parser::AST::Comment::Comment(CppSharp::Parser::AST::CommentKind kind)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::CommentKind)kind;
     NativePtr = new ::CppSharp::CppParser::AST::Comment(arg0);
 }
 
 CppSharp::Parser::AST::Comment::Comment(CppSharp::Parser::AST::Comment^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::Comment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::Comment(arg0);
 }
@@ -3942,7 +4412,14 @@ CppSharp::Parser::AST::BlockContentComment::BlockContentComment(::CppSharp::CppP
 
 CppSharp::Parser::AST::BlockContentComment^ CppSharp::Parser::AST::BlockContentComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::BlockContentComment((::CppSharp::CppParser::AST::BlockContentComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::BlockContentComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::BlockContentComment^ CppSharp::Parser::AST::BlockContentComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::BlockContentComment^ result = gcnew ::CppSharp::Parser::AST::BlockContentComment((::CppSharp::CppParser::AST::BlockContentComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::BlockContentComment::~BlockContentComment()
@@ -3952,12 +4429,14 @@ CppSharp::Parser::AST::BlockContentComment::~BlockContentComment()
 CppSharp::Parser::AST::BlockContentComment::BlockContentComment()
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::BlockContentComment();
 }
 
 CppSharp::Parser::AST::BlockContentComment::BlockContentComment(CppSharp::Parser::AST::CommentKind Kind)
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::CommentKind)Kind;
     NativePtr = new ::CppSharp::CppParser::AST::BlockContentComment(arg0);
 }
@@ -3965,6 +4444,7 @@ CppSharp::Parser::AST::BlockContentComment::BlockContentComment(CppSharp::Parser
 CppSharp::Parser::AST::BlockContentComment::BlockContentComment(CppSharp::Parser::AST::BlockContentComment^ _0)
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::BlockContentComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::BlockContentComment(arg0);
 }
@@ -3976,7 +4456,14 @@ CppSharp::Parser::AST::FullComment::FullComment(::CppSharp::CppParser::AST::Full
 
 CppSharp::Parser::AST::FullComment^ CppSharp::Parser::AST::FullComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::FullComment((::CppSharp::CppParser::AST::FullComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::FullComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::FullComment^ CppSharp::Parser::AST::FullComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::FullComment^ result = gcnew ::CppSharp::Parser::AST::FullComment((::CppSharp::CppParser::AST::FullComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::FullComment::~FullComment()
@@ -3986,6 +4473,7 @@ CppSharp::Parser::AST::FullComment::~FullComment()
 CppSharp::Parser::AST::FullComment::FullComment()
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::FullComment();
 }
 
@@ -4010,6 +4498,7 @@ void CppSharp::Parser::AST::FullComment::clearBlocks()
 CppSharp::Parser::AST::FullComment::FullComment(CppSharp::Parser::AST::FullComment^ _0)
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::FullComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::FullComment(arg0);
 }
@@ -4028,7 +4517,14 @@ CppSharp::Parser::AST::BlockCommandComment::Argument::Argument(::CppSharp::CppPa
 
 CppSharp::Parser::AST::BlockCommandComment::Argument^ CppSharp::Parser::AST::BlockCommandComment::Argument::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::BlockCommandComment::Argument((::CppSharp::CppParser::AST::BlockCommandComment::Argument*) native.ToPointer());
+    return ::CppSharp::Parser::AST::BlockCommandComment::Argument::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::BlockCommandComment::Argument^ CppSharp::Parser::AST::BlockCommandComment::Argument::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::BlockCommandComment::Argument^ result = gcnew ::CppSharp::Parser::AST::BlockCommandComment::Argument((::CppSharp::CppParser::AST::BlockCommandComment::Argument*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::BlockCommandComment::Argument::~Argument()
@@ -4038,14 +4534,14 @@ CppSharp::Parser::AST::BlockCommandComment::Argument::~Argument()
 }
 
 CppSharp::Parser::AST::BlockCommandComment::Argument::Argument()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::BlockCommandComment::Argument();
 }
 
 CppSharp::Parser::AST::BlockCommandComment::Argument::Argument(CppSharp::Parser::AST::BlockCommandComment::Argument^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::BlockCommandComment::Argument*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::BlockCommandComment::Argument(arg0);
 }
@@ -4081,7 +4577,14 @@ CppSharp::Parser::AST::BlockCommandComment::BlockCommandComment(::CppSharp::CppP
 
 CppSharp::Parser::AST::BlockCommandComment^ CppSharp::Parser::AST::BlockCommandComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::BlockCommandComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::BlockCommandComment^ CppSharp::Parser::AST::BlockCommandComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::BlockCommandComment^ result = gcnew ::CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::BlockCommandComment::~BlockCommandComment()
@@ -4091,12 +4594,14 @@ CppSharp::Parser::AST::BlockCommandComment::~BlockCommandComment()
 CppSharp::Parser::AST::BlockCommandComment::BlockCommandComment()
     : CppSharp::Parser::AST::BlockContentComment((::CppSharp::CppParser::AST::BlockContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::BlockCommandComment();
 }
 
 CppSharp::Parser::AST::BlockCommandComment::BlockCommandComment(CppSharp::Parser::AST::CommentKind Kind)
     : CppSharp::Parser::AST::BlockContentComment((::CppSharp::CppParser::AST::BlockContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::CommentKind)Kind;
     NativePtr = new ::CppSharp::CppParser::AST::BlockCommandComment(arg0);
 }
@@ -4122,6 +4627,7 @@ void CppSharp::Parser::AST::BlockCommandComment::clearArguments()
 CppSharp::Parser::AST::BlockCommandComment::BlockCommandComment(CppSharp::Parser::AST::BlockCommandComment^ _0)
     : CppSharp::Parser::AST::BlockContentComment((::CppSharp::CppParser::AST::BlockContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::BlockCommandComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::BlockCommandComment(arg0);
 }
@@ -4149,7 +4655,14 @@ CppSharp::Parser::AST::ParamCommandComment::ParamCommandComment(::CppSharp::CppP
 
 CppSharp::Parser::AST::ParamCommandComment^ CppSharp::Parser::AST::ParamCommandComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::ParamCommandComment((::CppSharp::CppParser::AST::ParamCommandComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::ParamCommandComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::ParamCommandComment^ CppSharp::Parser::AST::ParamCommandComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::ParamCommandComment^ result = gcnew ::CppSharp::Parser::AST::ParamCommandComment((::CppSharp::CppParser::AST::ParamCommandComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::ParamCommandComment::~ParamCommandComment()
@@ -4159,12 +4672,14 @@ CppSharp::Parser::AST::ParamCommandComment::~ParamCommandComment()
 CppSharp::Parser::AST::ParamCommandComment::ParamCommandComment()
     : CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::ParamCommandComment();
 }
 
 CppSharp::Parser::AST::ParamCommandComment::ParamCommandComment(CppSharp::Parser::AST::ParamCommandComment^ _0)
     : CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::ParamCommandComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::ParamCommandComment(arg0);
 }
@@ -4196,7 +4711,14 @@ CppSharp::Parser::AST::TParamCommandComment::TParamCommandComment(::CppSharp::Cp
 
 CppSharp::Parser::AST::TParamCommandComment^ CppSharp::Parser::AST::TParamCommandComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TParamCommandComment((::CppSharp::CppParser::AST::TParamCommandComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TParamCommandComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TParamCommandComment^ CppSharp::Parser::AST::TParamCommandComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TParamCommandComment^ result = gcnew ::CppSharp::Parser::AST::TParamCommandComment((::CppSharp::CppParser::AST::TParamCommandComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TParamCommandComment::~TParamCommandComment()
@@ -4206,6 +4728,7 @@ CppSharp::Parser::AST::TParamCommandComment::~TParamCommandComment()
 CppSharp::Parser::AST::TParamCommandComment::TParamCommandComment()
     : CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TParamCommandComment();
 }
 
@@ -4230,6 +4753,7 @@ void CppSharp::Parser::AST::TParamCommandComment::clearPosition()
 CppSharp::Parser::AST::TParamCommandComment::TParamCommandComment(CppSharp::Parser::AST::TParamCommandComment^ _0)
     : CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TParamCommandComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TParamCommandComment(arg0);
 }
@@ -4247,7 +4771,14 @@ CppSharp::Parser::AST::VerbatimBlockLineComment::VerbatimBlockLineComment(::CppS
 
 CppSharp::Parser::AST::VerbatimBlockLineComment^ CppSharp::Parser::AST::VerbatimBlockLineComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::VerbatimBlockLineComment((::CppSharp::CppParser::AST::VerbatimBlockLineComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::VerbatimBlockLineComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::VerbatimBlockLineComment^ CppSharp::Parser::AST::VerbatimBlockLineComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::VerbatimBlockLineComment^ result = gcnew ::CppSharp::Parser::AST::VerbatimBlockLineComment((::CppSharp::CppParser::AST::VerbatimBlockLineComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::VerbatimBlockLineComment::~VerbatimBlockLineComment()
@@ -4257,12 +4788,14 @@ CppSharp::Parser::AST::VerbatimBlockLineComment::~VerbatimBlockLineComment()
 CppSharp::Parser::AST::VerbatimBlockLineComment::VerbatimBlockLineComment()
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::VerbatimBlockLineComment();
 }
 
 CppSharp::Parser::AST::VerbatimBlockLineComment::VerbatimBlockLineComment(CppSharp::Parser::AST::VerbatimBlockLineComment^ _0)
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::VerbatimBlockLineComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::VerbatimBlockLineComment(arg0);
 }
@@ -4288,7 +4821,14 @@ CppSharp::Parser::AST::VerbatimBlockComment::VerbatimBlockComment(::CppSharp::Cp
 
 CppSharp::Parser::AST::VerbatimBlockComment^ CppSharp::Parser::AST::VerbatimBlockComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::VerbatimBlockComment((::CppSharp::CppParser::AST::VerbatimBlockComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::VerbatimBlockComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::VerbatimBlockComment^ CppSharp::Parser::AST::VerbatimBlockComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::VerbatimBlockComment^ result = gcnew ::CppSharp::Parser::AST::VerbatimBlockComment((::CppSharp::CppParser::AST::VerbatimBlockComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::VerbatimBlockComment::~VerbatimBlockComment()
@@ -4298,6 +4838,7 @@ CppSharp::Parser::AST::VerbatimBlockComment::~VerbatimBlockComment()
 CppSharp::Parser::AST::VerbatimBlockComment::VerbatimBlockComment()
     : CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::VerbatimBlockComment();
 }
 
@@ -4322,6 +4863,7 @@ void CppSharp::Parser::AST::VerbatimBlockComment::clearLines()
 CppSharp::Parser::AST::VerbatimBlockComment::VerbatimBlockComment(CppSharp::Parser::AST::VerbatimBlockComment^ _0)
     : CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::VerbatimBlockComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::VerbatimBlockComment(arg0);
 }
@@ -4339,7 +4881,14 @@ CppSharp::Parser::AST::VerbatimLineComment::VerbatimLineComment(::CppSharp::CppP
 
 CppSharp::Parser::AST::VerbatimLineComment^ CppSharp::Parser::AST::VerbatimLineComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::VerbatimLineComment((::CppSharp::CppParser::AST::VerbatimLineComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::VerbatimLineComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::VerbatimLineComment^ CppSharp::Parser::AST::VerbatimLineComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::VerbatimLineComment^ result = gcnew ::CppSharp::Parser::AST::VerbatimLineComment((::CppSharp::CppParser::AST::VerbatimLineComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::VerbatimLineComment::~VerbatimLineComment()
@@ -4349,12 +4898,14 @@ CppSharp::Parser::AST::VerbatimLineComment::~VerbatimLineComment()
 CppSharp::Parser::AST::VerbatimLineComment::VerbatimLineComment()
     : CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::VerbatimLineComment();
 }
 
 CppSharp::Parser::AST::VerbatimLineComment::VerbatimLineComment(CppSharp::Parser::AST::VerbatimLineComment^ _0)
     : CppSharp::Parser::AST::BlockCommandComment((::CppSharp::CppParser::AST::BlockCommandComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::VerbatimLineComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::VerbatimLineComment(arg0);
 }
@@ -4380,7 +4931,14 @@ CppSharp::Parser::AST::InlineContentComment::InlineContentComment(::CppSharp::Cp
 
 CppSharp::Parser::AST::InlineContentComment^ CppSharp::Parser::AST::InlineContentComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::InlineContentComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::InlineContentComment^ CppSharp::Parser::AST::InlineContentComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::InlineContentComment^ result = gcnew ::CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::InlineContentComment::~InlineContentComment()
@@ -4390,12 +4948,14 @@ CppSharp::Parser::AST::InlineContentComment::~InlineContentComment()
 CppSharp::Parser::AST::InlineContentComment::InlineContentComment()
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::InlineContentComment();
 }
 
 CppSharp::Parser::AST::InlineContentComment::InlineContentComment(CppSharp::Parser::AST::CommentKind Kind)
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::CommentKind)Kind;
     NativePtr = new ::CppSharp::CppParser::AST::InlineContentComment(arg0);
 }
@@ -4403,6 +4963,7 @@ CppSharp::Parser::AST::InlineContentComment::InlineContentComment(CppSharp::Pars
 CppSharp::Parser::AST::InlineContentComment::InlineContentComment(CppSharp::Parser::AST::InlineContentComment^ _0)
     : CppSharp::Parser::AST::Comment((::CppSharp::CppParser::AST::Comment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::InlineContentComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::InlineContentComment(arg0);
 }
@@ -4414,7 +4975,14 @@ CppSharp::Parser::AST::ParagraphComment::ParagraphComment(::CppSharp::CppParser:
 
 CppSharp::Parser::AST::ParagraphComment^ CppSharp::Parser::AST::ParagraphComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::ParagraphComment((::CppSharp::CppParser::AST::ParagraphComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::ParagraphComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::ParagraphComment^ CppSharp::Parser::AST::ParagraphComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::ParagraphComment^ result = gcnew ::CppSharp::Parser::AST::ParagraphComment((::CppSharp::CppParser::AST::ParagraphComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::ParagraphComment::~ParagraphComment()
@@ -4424,6 +4992,7 @@ CppSharp::Parser::AST::ParagraphComment::~ParagraphComment()
 CppSharp::Parser::AST::ParagraphComment::ParagraphComment()
     : CppSharp::Parser::AST::BlockContentComment((::CppSharp::CppParser::AST::BlockContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::ParagraphComment();
 }
 
@@ -4448,6 +5017,7 @@ void CppSharp::Parser::AST::ParagraphComment::clearContent()
 CppSharp::Parser::AST::ParagraphComment::ParagraphComment(CppSharp::Parser::AST::ParagraphComment^ _0)
     : CppSharp::Parser::AST::BlockContentComment((::CppSharp::CppParser::AST::BlockContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::ParagraphComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::ParagraphComment(arg0);
 }
@@ -4476,7 +5046,14 @@ CppSharp::Parser::AST::InlineCommandComment::Argument::Argument(::CppSharp::CppP
 
 CppSharp::Parser::AST::InlineCommandComment::Argument^ CppSharp::Parser::AST::InlineCommandComment::Argument::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::InlineCommandComment::Argument((::CppSharp::CppParser::AST::InlineCommandComment::Argument*) native.ToPointer());
+    return ::CppSharp::Parser::AST::InlineCommandComment::Argument::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::InlineCommandComment::Argument^ CppSharp::Parser::AST::InlineCommandComment::Argument::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::InlineCommandComment::Argument^ result = gcnew ::CppSharp::Parser::AST::InlineCommandComment::Argument((::CppSharp::CppParser::AST::InlineCommandComment::Argument*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::InlineCommandComment::Argument::~Argument()
@@ -4486,14 +5063,14 @@ CppSharp::Parser::AST::InlineCommandComment::Argument::~Argument()
 }
 
 CppSharp::Parser::AST::InlineCommandComment::Argument::Argument()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::InlineCommandComment::Argument();
 }
 
 CppSharp::Parser::AST::InlineCommandComment::Argument::Argument(CppSharp::Parser::AST::InlineCommandComment::Argument^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::InlineCommandComment::Argument*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::InlineCommandComment::Argument(arg0);
 }
@@ -4529,7 +5106,14 @@ CppSharp::Parser::AST::InlineCommandComment::InlineCommandComment(::CppSharp::Cp
 
 CppSharp::Parser::AST::InlineCommandComment^ CppSharp::Parser::AST::InlineCommandComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::InlineCommandComment((::CppSharp::CppParser::AST::InlineCommandComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::InlineCommandComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::InlineCommandComment^ CppSharp::Parser::AST::InlineCommandComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::InlineCommandComment^ result = gcnew ::CppSharp::Parser::AST::InlineCommandComment((::CppSharp::CppParser::AST::InlineCommandComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::InlineCommandComment::~InlineCommandComment()
@@ -4539,6 +5123,7 @@ CppSharp::Parser::AST::InlineCommandComment::~InlineCommandComment()
 CppSharp::Parser::AST::InlineCommandComment::InlineCommandComment()
     : CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::InlineCommandComment();
 }
 
@@ -4563,6 +5148,7 @@ void CppSharp::Parser::AST::InlineCommandComment::clearArguments()
 CppSharp::Parser::AST::InlineCommandComment::InlineCommandComment(CppSharp::Parser::AST::InlineCommandComment^ _0)
     : CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::InlineCommandComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::InlineCommandComment(arg0);
 }
@@ -4590,7 +5176,14 @@ CppSharp::Parser::AST::HTMLTagComment::HTMLTagComment(::CppSharp::CppParser::AST
 
 CppSharp::Parser::AST::HTMLTagComment^ CppSharp::Parser::AST::HTMLTagComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::HTMLTagComment((::CppSharp::CppParser::AST::HTMLTagComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::HTMLTagComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::HTMLTagComment^ CppSharp::Parser::AST::HTMLTagComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::HTMLTagComment^ result = gcnew ::CppSharp::Parser::AST::HTMLTagComment((::CppSharp::CppParser::AST::HTMLTagComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::HTMLTagComment::~HTMLTagComment()
@@ -4600,12 +5193,14 @@ CppSharp::Parser::AST::HTMLTagComment::~HTMLTagComment()
 CppSharp::Parser::AST::HTMLTagComment::HTMLTagComment()
     : CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLTagComment();
 }
 
 CppSharp::Parser::AST::HTMLTagComment::HTMLTagComment(CppSharp::Parser::AST::CommentKind Kind)
     : CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto arg0 = (::CppSharp::CppParser::AST::CommentKind)Kind;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLTagComment(arg0);
 }
@@ -4613,6 +5208,7 @@ CppSharp::Parser::AST::HTMLTagComment::HTMLTagComment(CppSharp::Parser::AST::Com
 CppSharp::Parser::AST::HTMLTagComment::HTMLTagComment(CppSharp::Parser::AST::HTMLTagComment^ _0)
     : CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::HTMLTagComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLTagComment(arg0);
 }
@@ -4625,7 +5221,14 @@ CppSharp::Parser::AST::HTMLStartTagComment::Attribute::Attribute(::CppSharp::Cpp
 
 CppSharp::Parser::AST::HTMLStartTagComment::Attribute^ CppSharp::Parser::AST::HTMLStartTagComment::Attribute::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::HTMLStartTagComment::Attribute((::CppSharp::CppParser::AST::HTMLStartTagComment::Attribute*) native.ToPointer());
+    return ::CppSharp::Parser::AST::HTMLStartTagComment::Attribute::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::HTMLStartTagComment::Attribute^ CppSharp::Parser::AST::HTMLStartTagComment::Attribute::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::HTMLStartTagComment::Attribute^ result = gcnew ::CppSharp::Parser::AST::HTMLStartTagComment::Attribute((::CppSharp::CppParser::AST::HTMLStartTagComment::Attribute*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::HTMLStartTagComment::Attribute::~Attribute()
@@ -4635,14 +5238,14 @@ CppSharp::Parser::AST::HTMLStartTagComment::Attribute::~Attribute()
 }
 
 CppSharp::Parser::AST::HTMLStartTagComment::Attribute::Attribute()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLStartTagComment::Attribute();
 }
 
 CppSharp::Parser::AST::HTMLStartTagComment::Attribute::Attribute(CppSharp::Parser::AST::HTMLStartTagComment::Attribute^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::HTMLStartTagComment::Attribute*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLStartTagComment::Attribute(arg0);
 }
@@ -4692,7 +5295,14 @@ CppSharp::Parser::AST::HTMLStartTagComment::HTMLStartTagComment(::CppSharp::CppP
 
 CppSharp::Parser::AST::HTMLStartTagComment^ CppSharp::Parser::AST::HTMLStartTagComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::HTMLStartTagComment((::CppSharp::CppParser::AST::HTMLStartTagComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::HTMLStartTagComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::HTMLStartTagComment^ CppSharp::Parser::AST::HTMLStartTagComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::HTMLStartTagComment^ result = gcnew ::CppSharp::Parser::AST::HTMLStartTagComment((::CppSharp::CppParser::AST::HTMLStartTagComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::HTMLStartTagComment::~HTMLStartTagComment()
@@ -4702,6 +5312,7 @@ CppSharp::Parser::AST::HTMLStartTagComment::~HTMLStartTagComment()
 CppSharp::Parser::AST::HTMLStartTagComment::HTMLStartTagComment()
     : CppSharp::Parser::AST::HTMLTagComment((::CppSharp::CppParser::AST::HTMLTagComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLStartTagComment();
 }
 
@@ -4726,6 +5337,7 @@ void CppSharp::Parser::AST::HTMLStartTagComment::clearAttributes()
 CppSharp::Parser::AST::HTMLStartTagComment::HTMLStartTagComment(CppSharp::Parser::AST::HTMLStartTagComment^ _0)
     : CppSharp::Parser::AST::HTMLTagComment((::CppSharp::CppParser::AST::HTMLTagComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::HTMLStartTagComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLStartTagComment(arg0);
 }
@@ -4757,7 +5369,14 @@ CppSharp::Parser::AST::HTMLEndTagComment::HTMLEndTagComment(::CppSharp::CppParse
 
 CppSharp::Parser::AST::HTMLEndTagComment^ CppSharp::Parser::AST::HTMLEndTagComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::HTMLEndTagComment((::CppSharp::CppParser::AST::HTMLEndTagComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::HTMLEndTagComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::HTMLEndTagComment^ CppSharp::Parser::AST::HTMLEndTagComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::HTMLEndTagComment^ result = gcnew ::CppSharp::Parser::AST::HTMLEndTagComment((::CppSharp::CppParser::AST::HTMLEndTagComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::HTMLEndTagComment::~HTMLEndTagComment()
@@ -4767,12 +5386,14 @@ CppSharp::Parser::AST::HTMLEndTagComment::~HTMLEndTagComment()
 CppSharp::Parser::AST::HTMLEndTagComment::HTMLEndTagComment()
     : CppSharp::Parser::AST::HTMLTagComment((::CppSharp::CppParser::AST::HTMLTagComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLEndTagComment();
 }
 
 CppSharp::Parser::AST::HTMLEndTagComment::HTMLEndTagComment(CppSharp::Parser::AST::HTMLEndTagComment^ _0)
     : CppSharp::Parser::AST::HTMLTagComment((::CppSharp::CppParser::AST::HTMLTagComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::HTMLEndTagComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::HTMLEndTagComment(arg0);
 }
@@ -4798,7 +5419,14 @@ CppSharp::Parser::AST::TextComment::TextComment(::CppSharp::CppParser::AST::Text
 
 CppSharp::Parser::AST::TextComment^ CppSharp::Parser::AST::TextComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::TextComment((::CppSharp::CppParser::AST::TextComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::TextComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::TextComment^ CppSharp::Parser::AST::TextComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::TextComment^ result = gcnew ::CppSharp::Parser::AST::TextComment((::CppSharp::CppParser::AST::TextComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::TextComment::~TextComment()
@@ -4808,12 +5436,14 @@ CppSharp::Parser::AST::TextComment::~TextComment()
 CppSharp::Parser::AST::TextComment::TextComment()
     : CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::TextComment();
 }
 
 CppSharp::Parser::AST::TextComment::TextComment(CppSharp::Parser::AST::TextComment^ _0)
     : CppSharp::Parser::AST::InlineContentComment((::CppSharp::CppParser::AST::InlineContentComment*)nullptr)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::TextComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::TextComment(arg0);
 }
@@ -4840,7 +5470,14 @@ CppSharp::Parser::AST::RawComment::RawComment(::CppSharp::CppParser::AST::RawCom
 
 CppSharp::Parser::AST::RawComment^ CppSharp::Parser::AST::RawComment::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::AST::RawComment((::CppSharp::CppParser::AST::RawComment*) native.ToPointer());
+    return ::CppSharp::Parser::AST::RawComment::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::AST::RawComment^ CppSharp::Parser::AST::RawComment::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::AST::RawComment^ result = gcnew ::CppSharp::Parser::AST::RawComment((::CppSharp::CppParser::AST::RawComment*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::AST::RawComment::~RawComment()
@@ -4850,14 +5487,14 @@ CppSharp::Parser::AST::RawComment::~RawComment()
 }
 
 CppSharp::Parser::AST::RawComment::RawComment()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::AST::RawComment();
 }
 
 CppSharp::Parser::AST::RawComment::RawComment(CppSharp::Parser::AST::RawComment^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::AST::RawComment*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::AST::RawComment(arg0);
 }
diff --git a/src/CppParser/Bindings/CLI/AST.h b/src/CppParser/Bindings/CLI/AST.h
index 51f63e18..996ab859 100644
--- a/src/CppParser/Bindings/CLI/AST.h
+++ b/src/CppParser/Bindings/CLI/AST.h
@@ -349,6 +349,7 @@ namespace CppSharp
 
                 Type(::CppSharp::CppParser::AST::Type* native);
                 static Type^ __CreateInstance(::System::IntPtr native);
+                static Type^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Type(CppSharp::Parser::AST::TypeKind kind);
 
                 Type(CppSharp::Parser::AST::Type^ _0);
@@ -367,7 +368,7 @@ namespace CppSharp
                     void set(bool);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -384,6 +385,7 @@ namespace CppSharp
 
                 TypeQualifiers(::CppSharp::CppParser::AST::TypeQualifiers* native);
                 static TypeQualifiers^ __CreateInstance(::System::IntPtr native);
+                static TypeQualifiers^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TypeQualifiers(CppSharp::Parser::AST::TypeQualifiers^ _0);
 
                 TypeQualifiers();
@@ -408,7 +410,7 @@ namespace CppSharp
                     void set(bool);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -425,6 +427,7 @@ namespace CppSharp
 
                 QualifiedType(::CppSharp::CppParser::AST::QualifiedType* native);
                 static QualifiedType^ __CreateInstance(::System::IntPtr native);
+                static QualifiedType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 QualifiedType();
 
                 QualifiedType(CppSharp::Parser::AST::QualifiedType^ _0);
@@ -443,7 +446,7 @@ namespace CppSharp
                     void set(CppSharp::Parser::AST::TypeQualifiers^);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -453,6 +456,7 @@ namespace CppSharp
 
                 TagType(::CppSharp::CppParser::AST::TagType* native);
                 static TagType^ __CreateInstance(::System::IntPtr native);
+                static TagType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TagType();
 
                 TagType(CppSharp::Parser::AST::TagType^ _0);
@@ -480,6 +484,7 @@ namespace CppSharp
 
                 ArrayType(::CppSharp::CppParser::AST::ArrayType* native);
                 static ArrayType^ __CreateInstance(::System::IntPtr native);
+                static ArrayType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 ArrayType();
 
                 ArrayType(CppSharp::Parser::AST::ArrayType^ _0);
@@ -511,6 +516,7 @@ namespace CppSharp
 
                 FunctionType(::CppSharp::CppParser::AST::FunctionType* native);
                 static FunctionType^ __CreateInstance(::System::IntPtr native);
+                static FunctionType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 FunctionType();
 
                 FunctionType(CppSharp::Parser::AST::FunctionType^ _0);
@@ -555,6 +561,7 @@ namespace CppSharp
 
                 PointerType(::CppSharp::CppParser::AST::PointerType* native);
                 static PointerType^ __CreateInstance(::System::IntPtr native);
+                static PointerType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 PointerType();
 
                 PointerType(CppSharp::Parser::AST::PointerType^ _0);
@@ -580,6 +587,7 @@ namespace CppSharp
 
                 MemberPointerType(::CppSharp::CppParser::AST::MemberPointerType* native);
                 static MemberPointerType^ __CreateInstance(::System::IntPtr native);
+                static MemberPointerType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 MemberPointerType();
 
                 MemberPointerType(CppSharp::Parser::AST::MemberPointerType^ _0);
@@ -599,6 +607,7 @@ namespace CppSharp
 
                 TypedefType(::CppSharp::CppParser::AST::TypedefType* native);
                 static TypedefType^ __CreateInstance(::System::IntPtr native);
+                static TypedefType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TypedefType();
 
                 TypedefType(CppSharp::Parser::AST::TypedefType^ _0);
@@ -618,6 +627,7 @@ namespace CppSharp
 
                 AttributedType(::CppSharp::CppParser::AST::AttributedType* native);
                 static AttributedType^ __CreateInstance(::System::IntPtr native);
+                static AttributedType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 AttributedType();
 
                 AttributedType(CppSharp::Parser::AST::AttributedType^ _0);
@@ -643,6 +653,7 @@ namespace CppSharp
 
                 DecayedType(::CppSharp::CppParser::AST::DecayedType* native);
                 static DecayedType^ __CreateInstance(::System::IntPtr native);
+                static DecayedType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 DecayedType();
 
                 DecayedType(CppSharp::Parser::AST::DecayedType^ _0);
@@ -693,6 +704,7 @@ namespace CppSharp
 
                 TemplateArgument(::CppSharp::CppParser::AST::TemplateArgument* native);
                 static TemplateArgument^ __CreateInstance(::System::IntPtr native);
+                static TemplateArgument^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TemplateArgument();
 
                 TemplateArgument(CppSharp::Parser::AST::TemplateArgument^ _0);
@@ -723,7 +735,7 @@ namespace CppSharp
                     void set(long);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -733,6 +745,7 @@ namespace CppSharp
 
                 TemplateSpecializationType(::CppSharp::CppParser::AST::TemplateSpecializationType* native);
                 static TemplateSpecializationType^ __CreateInstance(::System::IntPtr native);
+                static TemplateSpecializationType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TemplateSpecializationType();
 
                 TemplateSpecializationType(CppSharp::Parser::AST::TemplateSpecializationType^ _0);
@@ -776,6 +789,7 @@ namespace CppSharp
 
                 TemplateParameter(::CppSharp::CppParser::AST::TemplateParameter* native);
                 static TemplateParameter^ __CreateInstance(::System::IntPtr native);
+                static TemplateParameter^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TemplateParameter();
 
                 TemplateParameter(CppSharp::Parser::AST::TemplateParameter^ _0);
@@ -798,7 +812,7 @@ namespace CppSharp
 
                 virtual bool Equals(::System::Object^ obj) override;
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -808,6 +822,7 @@ namespace CppSharp
 
                 TemplateParameterType(::CppSharp::CppParser::AST::TemplateParameterType* native);
                 static TemplateParameterType^ __CreateInstance(::System::IntPtr native);
+                static TemplateParameterType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TemplateParameterType();
 
                 TemplateParameterType(CppSharp::Parser::AST::TemplateParameterType^ _0);
@@ -845,6 +860,7 @@ namespace CppSharp
 
                 TemplateParameterSubstitutionType(::CppSharp::CppParser::AST::TemplateParameterSubstitutionType* native);
                 static TemplateParameterSubstitutionType^ __CreateInstance(::System::IntPtr native);
+                static TemplateParameterSubstitutionType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TemplateParameterSubstitutionType();
 
                 TemplateParameterSubstitutionType(CppSharp::Parser::AST::TemplateParameterSubstitutionType^ _0);
@@ -864,6 +880,7 @@ namespace CppSharp
 
                 InjectedClassNameType(::CppSharp::CppParser::AST::InjectedClassNameType* native);
                 static InjectedClassNameType^ __CreateInstance(::System::IntPtr native);
+                static InjectedClassNameType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 InjectedClassNameType();
 
                 InjectedClassNameType(CppSharp::Parser::AST::InjectedClassNameType^ _0);
@@ -889,6 +906,7 @@ namespace CppSharp
 
                 DependentNameType(::CppSharp::CppParser::AST::DependentNameType* native);
                 static DependentNameType^ __CreateInstance(::System::IntPtr native);
+                static DependentNameType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 DependentNameType();
 
                 DependentNameType(CppSharp::Parser::AST::DependentNameType^ _0);
@@ -902,6 +920,7 @@ namespace CppSharp
 
                 PackExpansionType(::CppSharp::CppParser::AST::PackExpansionType* native);
                 static PackExpansionType^ __CreateInstance(::System::IntPtr native);
+                static PackExpansionType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 PackExpansionType();
 
                 PackExpansionType(CppSharp::Parser::AST::PackExpansionType^ _0);
@@ -915,6 +934,7 @@ namespace CppSharp
 
                 BuiltinType(::CppSharp::CppParser::AST::BuiltinType* native);
                 static BuiltinType^ __CreateInstance(::System::IntPtr native);
+                static BuiltinType^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 BuiltinType();
 
                 BuiltinType(CppSharp::Parser::AST::BuiltinType^ _0);
@@ -941,6 +961,7 @@ namespace CppSharp
 
                 VTableComponent(::CppSharp::CppParser::AST::VTableComponent* native);
                 static VTableComponent^ __CreateInstance(::System::IntPtr native);
+                static VTableComponent^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 VTableComponent();
 
                 VTableComponent(CppSharp::Parser::AST::VTableComponent^ _0);
@@ -965,7 +986,7 @@ namespace CppSharp
                     void set(CppSharp::Parser::AST::Declaration^);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -982,6 +1003,7 @@ namespace CppSharp
 
                 VTableLayout(::CppSharp::CppParser::AST::VTableLayout* native);
                 static VTableLayout^ __CreateInstance(::System::IntPtr native);
+                static VTableLayout^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 VTableLayout();
 
                 VTableLayout(CppSharp::Parser::AST::VTableLayout^ _0);
@@ -999,7 +1021,7 @@ namespace CppSharp
 
                 void clearComponents();
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -1016,6 +1038,7 @@ namespace CppSharp
 
                 VFTableInfo(::CppSharp::CppParser::AST::VFTableInfo* native);
                 static VFTableInfo^ __CreateInstance(::System::IntPtr native);
+                static VFTableInfo^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 VFTableInfo();
 
                 VFTableInfo(CppSharp::Parser::AST::VFTableInfo^ _0);
@@ -1046,7 +1069,7 @@ namespace CppSharp
                     void set(CppSharp::Parser::AST::VTableLayout^);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -1063,6 +1086,7 @@ namespace CppSharp
 
                 ClassLayout(::CppSharp::CppParser::AST::ClassLayout* native);
                 static ClassLayout^ __CreateInstance(::System::IntPtr native);
+                static ClassLayout^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 ClassLayout();
 
                 ClassLayout(CppSharp::Parser::AST::ClassLayout^ _0);
@@ -1122,7 +1146,7 @@ namespace CppSharp
 
                 void clearVFTables();
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -1139,6 +1163,7 @@ namespace CppSharp
 
                 Declaration(::CppSharp::CppParser::AST::Declaration* native);
                 static Declaration^ __CreateInstance(::System::IntPtr native);
+                static Declaration^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Declaration(CppSharp::Parser::AST::DeclarationKind kind);
 
                 Declaration(CppSharp::Parser::AST::Declaration^ _0);
@@ -1240,7 +1265,7 @@ namespace CppSharp
 
                 void clearPreprocessedEntities();
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -1250,6 +1275,7 @@ namespace CppSharp
 
                 DeclarationContext(::CppSharp::CppParser::AST::DeclarationContext* native);
                 static DeclarationContext^ __CreateInstance(::System::IntPtr native);
+                static DeclarationContext^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 DeclarationContext(CppSharp::Parser::AST::DeclarationKind kind);
 
                 DeclarationContext(CppSharp::Parser::AST::DeclarationContext^ _0);
@@ -1357,6 +1383,7 @@ namespace CppSharp
 
                 TypedefDecl(::CppSharp::CppParser::AST::TypedefDecl* native);
                 static TypedefDecl^ __CreateInstance(::System::IntPtr native);
+                static TypedefDecl^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TypedefDecl();
 
                 TypedefDecl(CppSharp::Parser::AST::TypedefDecl^ _0);
@@ -1376,6 +1403,7 @@ namespace CppSharp
 
                 Friend(::CppSharp::CppParser::AST::Friend* native);
                 static Friend^ __CreateInstance(::System::IntPtr native);
+                static Friend^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Friend();
 
                 Friend(CppSharp::Parser::AST::Friend^ _0);
@@ -1402,6 +1430,7 @@ namespace CppSharp
 
                 Statement(::CppSharp::CppParser::AST::Statement* native);
                 static Statement^ __CreateInstance(::System::IntPtr native);
+                static Statement^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Statement(CppSharp::Parser::AST::Statement^ _0);
 
                 ~Statement();
@@ -1424,7 +1453,7 @@ namespace CppSharp
                     void set(CppSharp::Parser::AST::Declaration^);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -1434,6 +1463,7 @@ namespace CppSharp
 
                 Expression(::CppSharp::CppParser::AST::Expression* native);
                 static Expression^ __CreateInstance(::System::IntPtr native);
+                static Expression^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Expression(CppSharp::Parser::AST::Expression^ _0);
 
                 ~Expression();
@@ -1445,6 +1475,7 @@ namespace CppSharp
 
                 BinaryOperator(::CppSharp::CppParser::AST::BinaryOperator* native);
                 static BinaryOperator^ __CreateInstance(::System::IntPtr native);
+                static BinaryOperator^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 BinaryOperator(CppSharp::Parser::AST::BinaryOperator^ _0);
 
                 ~BinaryOperator();
@@ -1474,6 +1505,7 @@ namespace CppSharp
 
                 CXXConstructExpr(::CppSharp::CppParser::AST::CXXConstructExpr* native);
                 static CXXConstructExpr^ __CreateInstance(::System::IntPtr native);
+                static CXXConstructExpr^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 CXXConstructExpr(CppSharp::Parser::AST::CXXConstructExpr^ _0);
 
                 ~CXXConstructExpr();
@@ -1496,6 +1528,7 @@ namespace CppSharp
 
                 Parameter(::CppSharp::CppParser::AST::Parameter* native);
                 static Parameter^ __CreateInstance(::System::IntPtr native);
+                static Parameter^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Parameter();
 
                 Parameter(CppSharp::Parser::AST::Parameter^ _0);
@@ -1539,6 +1572,7 @@ namespace CppSharp
 
                 Function(::CppSharp::CppParser::AST::Function* native);
                 static Function^ __CreateInstance(::System::IntPtr native);
+                static Function^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Function();
 
                 Function(CppSharp::Parser::AST::Function^ _0);
@@ -1635,6 +1669,7 @@ namespace CppSharp
 
                 Method(::CppSharp::CppParser::AST::Method* native);
                 static Method^ __CreateInstance(::System::IntPtr native);
+                static Method^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Method();
 
                 Method(CppSharp::Parser::AST::Method^ _0);
@@ -1732,6 +1767,7 @@ namespace CppSharp
 
                     Item(::CppSharp::CppParser::AST::Enumeration::Item* native);
                     static Item^ __CreateInstance(::System::IntPtr native);
+                    static Item^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                     Item();
 
                     Item(CppSharp::Parser::AST::Enumeration::Item^ _0);
@@ -1753,6 +1789,7 @@ namespace CppSharp
 
                 Enumeration(::CppSharp::CppParser::AST::Enumeration* native);
                 static Enumeration^ __CreateInstance(::System::IntPtr native);
+                static Enumeration^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Enumeration();
 
                 Enumeration(CppSharp::Parser::AST::Enumeration^ _0);
@@ -1795,6 +1832,7 @@ namespace CppSharp
 
                 Variable(::CppSharp::CppParser::AST::Variable* native);
                 static Variable^ __CreateInstance(::System::IntPtr native);
+                static Variable^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Variable();
 
                 Variable(CppSharp::Parser::AST::Variable^ _0);
@@ -1827,6 +1865,7 @@ namespace CppSharp
 
                 BaseClassSpecifier(::CppSharp::CppParser::AST::BaseClassSpecifier* native);
                 static BaseClassSpecifier^ __CreateInstance(::System::IntPtr native);
+                static BaseClassSpecifier^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 BaseClassSpecifier();
 
                 BaseClassSpecifier(CppSharp::Parser::AST::BaseClassSpecifier^ _0);
@@ -1857,7 +1896,7 @@ namespace CppSharp
                     void set(int);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -1867,6 +1906,7 @@ namespace CppSharp
 
                 Field(::CppSharp::CppParser::AST::Field* native);
                 static Field^ __CreateInstance(::System::IntPtr native);
+                static Field^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Field();
 
                 Field(CppSharp::Parser::AST::Field^ _0);
@@ -1910,6 +1950,7 @@ namespace CppSharp
 
                 AccessSpecifierDecl(::CppSharp::CppParser::AST::AccessSpecifierDecl* native);
                 static AccessSpecifierDecl^ __CreateInstance(::System::IntPtr native);
+                static AccessSpecifierDecl^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 AccessSpecifierDecl();
 
                 AccessSpecifierDecl(CppSharp::Parser::AST::AccessSpecifierDecl^ _0);
@@ -1923,6 +1964,7 @@ namespace CppSharp
 
                 Class(::CppSharp::CppParser::AST::Class* native);
                 static Class^ __CreateInstance(::System::IntPtr native);
+                static Class^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Class();
 
                 Class(CppSharp::Parser::AST::Class^ _0);
@@ -2040,6 +2082,7 @@ namespace CppSharp
 
                 Template(::CppSharp::CppParser::AST::Template* native);
                 static Template^ __CreateInstance(::System::IntPtr native);
+                static Template^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Template(CppSharp::Parser::AST::DeclarationKind kind);
 
                 Template();
@@ -2072,6 +2115,7 @@ namespace CppSharp
 
                 ClassTemplate(::CppSharp::CppParser::AST::ClassTemplate* native);
                 static ClassTemplate^ __CreateInstance(::System::IntPtr native);
+                static ClassTemplate^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 ClassTemplate();
 
                 ClassTemplate(CppSharp::Parser::AST::ClassTemplate^ _0);
@@ -2096,6 +2140,7 @@ namespace CppSharp
 
                 ClassTemplateSpecialization(::CppSharp::CppParser::AST::ClassTemplateSpecialization* native);
                 static ClassTemplateSpecialization^ __CreateInstance(::System::IntPtr native);
+                static ClassTemplateSpecialization^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 ClassTemplateSpecialization();
 
                 ClassTemplateSpecialization(CppSharp::Parser::AST::ClassTemplateSpecialization^ _0);
@@ -2132,6 +2177,7 @@ namespace CppSharp
 
                 ClassTemplatePartialSpecialization(::CppSharp::CppParser::AST::ClassTemplatePartialSpecialization* native);
                 static ClassTemplatePartialSpecialization^ __CreateInstance(::System::IntPtr native);
+                static ClassTemplatePartialSpecialization^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 ClassTemplatePartialSpecialization();
 
                 ClassTemplatePartialSpecialization(CppSharp::Parser::AST::ClassTemplatePartialSpecialization^ _0);
@@ -2145,6 +2191,7 @@ namespace CppSharp
 
                 FunctionTemplate(::CppSharp::CppParser::AST::FunctionTemplate* native);
                 static FunctionTemplate^ __CreateInstance(::System::IntPtr native);
+                static FunctionTemplate^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 FunctionTemplate();
 
                 FunctionTemplate(CppSharp::Parser::AST::FunctionTemplate^ _0);
@@ -2176,6 +2223,7 @@ namespace CppSharp
 
                 FunctionTemplateSpecialization(::CppSharp::CppParser::AST::FunctionTemplateSpecialization* native);
                 static FunctionTemplateSpecialization^ __CreateInstance(::System::IntPtr native);
+                static FunctionTemplateSpecialization^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 FunctionTemplateSpecialization();
 
                 FunctionTemplateSpecialization(CppSharp::Parser::AST::FunctionTemplateSpecialization^ _0);
@@ -2211,7 +2259,7 @@ namespace CppSharp
 
                 void clearArguments();
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -2221,6 +2269,7 @@ namespace CppSharp
 
                 Namespace(::CppSharp::CppParser::AST::Namespace* native);
                 static Namespace^ __CreateInstance(::System::IntPtr native);
+                static Namespace^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Namespace();
 
                 Namespace(CppSharp::Parser::AST::Namespace^ _0);
@@ -2240,6 +2289,7 @@ namespace CppSharp
 
                 PreprocessedEntity(::CppSharp::CppParser::AST::PreprocessedEntity* native);
                 static PreprocessedEntity^ __CreateInstance(::System::IntPtr native);
+                static PreprocessedEntity^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 PreprocessedEntity();
 
                 PreprocessedEntity(CppSharp::Parser::AST::PreprocessedEntity^ _0);
@@ -2259,6 +2309,7 @@ namespace CppSharp
 
                 MacroDefinition(::CppSharp::CppParser::AST::MacroDefinition* native);
                 static MacroDefinition^ __CreateInstance(::System::IntPtr native);
+                static MacroDefinition^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 MacroDefinition();
 
                 MacroDefinition(CppSharp::Parser::AST::MacroDefinition^ _0);
@@ -2278,6 +2329,7 @@ namespace CppSharp
 
                 MacroExpansion(::CppSharp::CppParser::AST::MacroExpansion* native);
                 static MacroExpansion^ __CreateInstance(::System::IntPtr native);
+                static MacroExpansion^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 MacroExpansion();
 
                 MacroExpansion(CppSharp::Parser::AST::MacroExpansion^ _0);
@@ -2303,6 +2355,7 @@ namespace CppSharp
 
                 TranslationUnit(::CppSharp::CppParser::AST::TranslationUnit* native);
                 static TranslationUnit^ __CreateInstance(::System::IntPtr native);
+                static TranslationUnit^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TranslationUnit();
 
                 TranslationUnit(CppSharp::Parser::AST::TranslationUnit^ _0);
@@ -2346,6 +2399,7 @@ namespace CppSharp
 
                 NativeLibrary(::CppSharp::CppParser::AST::NativeLibrary* native);
                 static NativeLibrary^ __CreateInstance(::System::IntPtr native);
+                static NativeLibrary^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 NativeLibrary();
 
                 NativeLibrary(CppSharp::Parser::AST::NativeLibrary^ _0);
@@ -2386,7 +2440,7 @@ namespace CppSharp
 
                 void clearDependencies();
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -2403,6 +2457,7 @@ namespace CppSharp
 
                 ASTContext(::CppSharp::CppParser::AST::ASTContext* native);
                 static ASTContext^ __CreateInstance(::System::IntPtr native);
+                static ASTContext^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 ASTContext();
 
                 ASTContext(CppSharp::Parser::AST::ASTContext^ _0);
@@ -2420,7 +2475,7 @@ namespace CppSharp
 
                 void clearTranslationUnits();
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -2437,6 +2492,7 @@ namespace CppSharp
 
                 Comment(::CppSharp::CppParser::AST::Comment* native);
                 static Comment^ __CreateInstance(::System::IntPtr native);
+                static Comment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 Comment(CppSharp::Parser::AST::CommentKind kind);
 
                 Comment(CppSharp::Parser::AST::Comment^ _0);
@@ -2449,7 +2505,7 @@ namespace CppSharp
                     void set(CppSharp::Parser::AST::CommentKind);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
 
@@ -2459,6 +2515,7 @@ namespace CppSharp
 
                 BlockContentComment(::CppSharp::CppParser::AST::BlockContentComment* native);
                 static BlockContentComment^ __CreateInstance(::System::IntPtr native);
+                static BlockContentComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 BlockContentComment();
 
                 BlockContentComment(CppSharp::Parser::AST::CommentKind Kind);
@@ -2474,6 +2531,7 @@ namespace CppSharp
 
                 FullComment(::CppSharp::CppParser::AST::FullComment* native);
                 static FullComment^ __CreateInstance(::System::IntPtr native);
+                static FullComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 FullComment();
 
                 FullComment(CppSharp::Parser::AST::FullComment^ _0);
@@ -2509,6 +2567,7 @@ namespace CppSharp
 
                     Argument(::CppSharp::CppParser::AST::BlockCommandComment::Argument* native);
                     static Argument^ __CreateInstance(::System::IntPtr native);
+                    static Argument^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                     Argument();
 
                     Argument(CppSharp::Parser::AST::BlockCommandComment::Argument^ _0);
@@ -2521,12 +2580,13 @@ namespace CppSharp
                         void set(System::String^);
                     }
 
-                    private:
+                    protected:
                     bool __ownsNativeInstance;
                 };
 
                 BlockCommandComment(::CppSharp::CppParser::AST::BlockCommandComment* native);
                 static BlockCommandComment^ __CreateInstance(::System::IntPtr native);
+                static BlockCommandComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 BlockCommandComment();
 
                 BlockCommandComment(CppSharp::Parser::AST::CommentKind Kind);
@@ -2566,6 +2626,7 @@ namespace CppSharp
 
                 ParamCommandComment(::CppSharp::CppParser::AST::ParamCommandComment* native);
                 static ParamCommandComment^ __CreateInstance(::System::IntPtr native);
+                static ParamCommandComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 ParamCommandComment();
 
                 ParamCommandComment(CppSharp::Parser::AST::ParamCommandComment^ _0);
@@ -2591,6 +2652,7 @@ namespace CppSharp
 
                 TParamCommandComment(::CppSharp::CppParser::AST::TParamCommandComment* native);
                 static TParamCommandComment^ __CreateInstance(::System::IntPtr native);
+                static TParamCommandComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TParamCommandComment();
 
                 TParamCommandComment(CppSharp::Parser::AST::TParamCommandComment^ _0);
@@ -2615,6 +2677,7 @@ namespace CppSharp
 
                 VerbatimBlockLineComment(::CppSharp::CppParser::AST::VerbatimBlockLineComment* native);
                 static VerbatimBlockLineComment^ __CreateInstance(::System::IntPtr native);
+                static VerbatimBlockLineComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 VerbatimBlockLineComment();
 
                 VerbatimBlockLineComment(CppSharp::Parser::AST::VerbatimBlockLineComment^ _0);
@@ -2634,6 +2697,7 @@ namespace CppSharp
 
                 VerbatimBlockComment(::CppSharp::CppParser::AST::VerbatimBlockComment* native);
                 static VerbatimBlockComment^ __CreateInstance(::System::IntPtr native);
+                static VerbatimBlockComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 VerbatimBlockComment();
 
                 VerbatimBlockComment(CppSharp::Parser::AST::VerbatimBlockComment^ _0);
@@ -2658,6 +2722,7 @@ namespace CppSharp
 
                 VerbatimLineComment(::CppSharp::CppParser::AST::VerbatimLineComment* native);
                 static VerbatimLineComment^ __CreateInstance(::System::IntPtr native);
+                static VerbatimLineComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 VerbatimLineComment();
 
                 VerbatimLineComment(CppSharp::Parser::AST::VerbatimLineComment^ _0);
@@ -2677,6 +2742,7 @@ namespace CppSharp
 
                 InlineContentComment(::CppSharp::CppParser::AST::InlineContentComment* native);
                 static InlineContentComment^ __CreateInstance(::System::IntPtr native);
+                static InlineContentComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 InlineContentComment();
 
                 InlineContentComment(CppSharp::Parser::AST::CommentKind Kind);
@@ -2692,6 +2758,7 @@ namespace CppSharp
 
                 ParagraphComment(::CppSharp::CppParser::AST::ParagraphComment* native);
                 static ParagraphComment^ __CreateInstance(::System::IntPtr native);
+                static ParagraphComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 ParagraphComment();
 
                 ParagraphComment(CppSharp::Parser::AST::ParagraphComment^ _0);
@@ -2741,6 +2808,7 @@ namespace CppSharp
 
                     Argument(::CppSharp::CppParser::AST::InlineCommandComment::Argument* native);
                     static Argument^ __CreateInstance(::System::IntPtr native);
+                    static Argument^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                     Argument();
 
                     Argument(CppSharp::Parser::AST::InlineCommandComment::Argument^ _0);
@@ -2753,12 +2821,13 @@ namespace CppSharp
                         void set(System::String^);
                     }
 
-                    private:
+                    protected:
                     bool __ownsNativeInstance;
                 };
 
                 InlineCommandComment(::CppSharp::CppParser::AST::InlineCommandComment* native);
                 static InlineCommandComment^ __CreateInstance(::System::IntPtr native);
+                static InlineCommandComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 InlineCommandComment();
 
                 InlineCommandComment(CppSharp::Parser::AST::InlineCommandComment^ _0);
@@ -2789,6 +2858,7 @@ namespace CppSharp
 
                 HTMLTagComment(::CppSharp::CppParser::AST::HTMLTagComment* native);
                 static HTMLTagComment^ __CreateInstance(::System::IntPtr native);
+                static HTMLTagComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 HTMLTagComment();
 
                 HTMLTagComment(CppSharp::Parser::AST::CommentKind Kind);
@@ -2815,6 +2885,7 @@ namespace CppSharp
 
                     Attribute(::CppSharp::CppParser::AST::HTMLStartTagComment::Attribute* native);
                     static Attribute^ __CreateInstance(::System::IntPtr native);
+                    static Attribute^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                     Attribute();
 
                     Attribute(CppSharp::Parser::AST::HTMLStartTagComment::Attribute^ _0);
@@ -2833,12 +2904,13 @@ namespace CppSharp
                         void set(System::String^);
                     }
 
-                    private:
+                    protected:
                     bool __ownsNativeInstance;
                 };
 
                 HTMLStartTagComment(::CppSharp::CppParser::AST::HTMLStartTagComment* native);
                 static HTMLStartTagComment^ __CreateInstance(::System::IntPtr native);
+                static HTMLStartTagComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 HTMLStartTagComment();
 
                 HTMLStartTagComment(CppSharp::Parser::AST::HTMLStartTagComment^ _0);
@@ -2869,6 +2941,7 @@ namespace CppSharp
 
                 HTMLEndTagComment(::CppSharp::CppParser::AST::HTMLEndTagComment* native);
                 static HTMLEndTagComment^ __CreateInstance(::System::IntPtr native);
+                static HTMLEndTagComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 HTMLEndTagComment();
 
                 HTMLEndTagComment(CppSharp::Parser::AST::HTMLEndTagComment^ _0);
@@ -2888,6 +2961,7 @@ namespace CppSharp
 
                 TextComment(::CppSharp::CppParser::AST::TextComment* native);
                 static TextComment^ __CreateInstance(::System::IntPtr native);
+                static TextComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 TextComment();
 
                 TextComment(CppSharp::Parser::AST::TextComment^ _0);
@@ -2914,6 +2988,7 @@ namespace CppSharp
 
                 RawComment(::CppSharp::CppParser::AST::RawComment* native);
                 static RawComment^ __CreateInstance(::System::IntPtr native);
+                static RawComment^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
                 RawComment();
 
                 RawComment(CppSharp::Parser::AST::RawComment^ _0);
@@ -2944,7 +3019,7 @@ namespace CppSharp
                     void set(CppSharp::Parser::AST::FullComment^);
                 }
 
-                private:
+                protected:
                 bool __ownsNativeInstance;
             };
         }
diff --git a/src/CppParser/Bindings/CLI/CppParser.cpp b/src/CppParser/Bindings/CLI/CppParser.cpp
index 3b57e873..e3ae6507 100644
--- a/src/CppParser/Bindings/CLI/CppParser.cpp
+++ b/src/CppParser/Bindings/CLI/CppParser.cpp
@@ -13,7 +13,14 @@ CppSharp::Parser::ParserOptions::ParserOptions(::CppSharp::CppParser::ParserOpti
 
 CppSharp::Parser::ParserOptions^ CppSharp::Parser::ParserOptions::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::ParserOptions((::CppSharp::CppParser::ParserOptions*) native.ToPointer());
+    return ::CppSharp::Parser::ParserOptions::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::ParserOptions^ CppSharp::Parser::ParserOptions::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::ParserOptions^ result = gcnew ::CppSharp::Parser::ParserOptions((::CppSharp::CppParser::ParserOptions*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::ParserOptions::~ParserOptions()
@@ -23,8 +30,8 @@ CppSharp::Parser::ParserOptions::~ParserOptions()
 }
 
 CppSharp::Parser::ParserOptions::ParserOptions()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::ParserOptions();
 }
 
@@ -143,8 +150,8 @@ void CppSharp::Parser::ParserOptions::clearLibraryDirs()
 }
 
 CppSharp::Parser::ParserOptions::ParserOptions(CppSharp::Parser::ParserOptions^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::ParserOptions*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::ParserOptions(arg0);
 }
@@ -311,7 +318,14 @@ CppSharp::Parser::ParserDiagnostic::ParserDiagnostic(::CppSharp::CppParser::Pars
 
 CppSharp::Parser::ParserDiagnostic^ CppSharp::Parser::ParserDiagnostic::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::ParserDiagnostic((::CppSharp::CppParser::ParserDiagnostic*) native.ToPointer());
+    return ::CppSharp::Parser::ParserDiagnostic::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::ParserDiagnostic^ CppSharp::Parser::ParserDiagnostic::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::ParserDiagnostic^ result = gcnew ::CppSharp::Parser::ParserDiagnostic((::CppSharp::CppParser::ParserDiagnostic*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::ParserDiagnostic::~ParserDiagnostic()
@@ -321,14 +335,14 @@ CppSharp::Parser::ParserDiagnostic::~ParserDiagnostic()
 }
 
 CppSharp::Parser::ParserDiagnostic::ParserDiagnostic()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::ParserDiagnostic();
 }
 
 CppSharp::Parser::ParserDiagnostic::ParserDiagnostic(CppSharp::Parser::ParserDiagnostic^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::ParserDiagnostic*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::ParserDiagnostic(arg0);
 }
@@ -409,7 +423,14 @@ CppSharp::Parser::ParserResult::ParserResult(::CppSharp::CppParser::ParserResult
 
 CppSharp::Parser::ParserResult^ CppSharp::Parser::ParserResult::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::ParserResult((::CppSharp::CppParser::ParserResult*) native.ToPointer());
+    return ::CppSharp::Parser::ParserResult::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::ParserResult^ CppSharp::Parser::ParserResult::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::ParserResult^ result = gcnew ::CppSharp::Parser::ParserResult((::CppSharp::CppParser::ParserResult*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::ParserResult::~ParserResult()
@@ -419,14 +440,14 @@ CppSharp::Parser::ParserResult::~ParserResult()
 }
 
 CppSharp::Parser::ParserResult::ParserResult()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::ParserResult();
 }
 
 CppSharp::Parser::ParserResult::ParserResult(CppSharp::Parser::ParserResult^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::ParserResult*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::ParserResult(arg0);
 }
@@ -503,7 +524,14 @@ CppSharp::Parser::ClangParser::ClangParser(::CppSharp::CppParser::ClangParser* n
 
 CppSharp::Parser::ClangParser^ CppSharp::Parser::ClangParser::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::ClangParser((::CppSharp::CppParser::ClangParser*) native.ToPointer());
+    return ::CppSharp::Parser::ClangParser::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::ClangParser^ CppSharp::Parser::ClangParser::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::ClangParser^ result = gcnew ::CppSharp::Parser::ClangParser((::CppSharp::CppParser::ClangParser*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::ClangParser::~ClangParser()
@@ -537,14 +565,14 @@ CppSharp::Parser::ParserTargetInfo^ CppSharp::Parser::ClangParser::GetTargetInfo
 }
 
 CppSharp::Parser::ClangParser::ClangParser()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::ClangParser();
 }
 
 CppSharp::Parser::ClangParser::ClangParser(CppSharp::Parser::ClangParser^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::ClangParser*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::ClangParser(arg0);
 }
diff --git a/src/CppParser/Bindings/CLI/CppParser.h b/src/CppParser/Bindings/CLI/CppParser.h
index 9f2d704a..81fc0cf4 100644
--- a/src/CppParser/Bindings/CLI/CppParser.h
+++ b/src/CppParser/Bindings/CLI/CppParser.h
@@ -78,6 +78,7 @@ namespace CppSharp
 
             ParserOptions(::CppSharp::CppParser::ParserOptions* native);
             static ParserOptions^ __CreateInstance(::System::IntPtr native);
+            static ParserOptions^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
             ParserOptions();
 
             ParserOptions(CppSharp::Parser::ParserOptions^ _0);
@@ -210,7 +211,7 @@ namespace CppSharp
 
             void clearLibraryDirs();
 
-            private:
+            protected:
             bool __ownsNativeInstance;
         };
 
@@ -227,6 +228,7 @@ namespace CppSharp
 
             ParserDiagnostic(::CppSharp::CppParser::ParserDiagnostic* native);
             static ParserDiagnostic^ __CreateInstance(::System::IntPtr native);
+            static ParserDiagnostic^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
             ParserDiagnostic();
 
             ParserDiagnostic(CppSharp::Parser::ParserDiagnostic^ _0);
@@ -263,7 +265,7 @@ namespace CppSharp
                 void set(int);
             }
 
-            private:
+            protected:
             bool __ownsNativeInstance;
         };
 
@@ -280,6 +282,7 @@ namespace CppSharp
 
             ParserResult(::CppSharp::CppParser::ParserResult* native);
             static ParserResult^ __CreateInstance(::System::IntPtr native);
+            static ParserResult^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
             ParserResult();
 
             ParserResult(CppSharp::Parser::ParserResult^ _0);
@@ -315,7 +318,7 @@ namespace CppSharp
 
             void clearDiagnostics();
 
-            private:
+            protected:
             bool __ownsNativeInstance;
         };
 
@@ -332,6 +335,7 @@ namespace CppSharp
 
             ClangParser(::CppSharp::CppParser::ClangParser* native);
             static ClangParser^ __CreateInstance(::System::IntPtr native);
+            static ClangParser^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
             ClangParser();
 
             ClangParser(CppSharp::Parser::ClangParser^ _0);
@@ -344,7 +348,7 @@ namespace CppSharp
 
             static CppSharp::Parser::ParserTargetInfo^ GetTargetInfo(CppSharp::Parser::ParserOptions^ Opts);
 
-            private:
+            protected:
             bool __ownsNativeInstance;
         };
     }
diff --git a/src/CppParser/Bindings/CLI/Target.cpp b/src/CppParser/Bindings/CLI/Target.cpp
index 1ad83fc6..9cd160f9 100644
--- a/src/CppParser/Bindings/CLI/Target.cpp
+++ b/src/CppParser/Bindings/CLI/Target.cpp
@@ -11,7 +11,14 @@ CppSharp::Parser::ParserTargetInfo::ParserTargetInfo(::CppSharp::CppParser::Pars
 
 CppSharp::Parser::ParserTargetInfo^ CppSharp::Parser::ParserTargetInfo::__CreateInstance(::System::IntPtr native)
 {
-    return gcnew ::CppSharp::Parser::ParserTargetInfo((::CppSharp::CppParser::ParserTargetInfo*) native.ToPointer());
+    return ::CppSharp::Parser::ParserTargetInfo::__CreateInstance(native, false);
+}
+
+CppSharp::Parser::ParserTargetInfo^ CppSharp::Parser::ParserTargetInfo::__CreateInstance(::System::IntPtr native, bool __ownsNativeInstance)
+{
+    ::CppSharp::Parser::ParserTargetInfo^ result = gcnew ::CppSharp::Parser::ParserTargetInfo((::CppSharp::CppParser::ParserTargetInfo*) native.ToPointer());
+    result->__ownsNativeInstance = __ownsNativeInstance;
+    return result;
 }
 
 CppSharp::Parser::ParserTargetInfo::~ParserTargetInfo()
@@ -21,14 +28,14 @@ CppSharp::Parser::ParserTargetInfo::~ParserTargetInfo()
 }
 
 CppSharp::Parser::ParserTargetInfo::ParserTargetInfo()
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     NativePtr = new ::CppSharp::CppParser::ParserTargetInfo();
 }
 
 CppSharp::Parser::ParserTargetInfo::ParserTargetInfo(CppSharp::Parser::ParserTargetInfo^ _0)
-    : __ownsNativeInstance(true)
 {
+    __ownsNativeInstance = true;
     auto &arg0 = *(::CppSharp::CppParser::ParserTargetInfo*)_0->NativePtr;
     NativePtr = new ::CppSharp::CppParser::ParserTargetInfo(arg0);
 }
diff --git a/src/CppParser/Bindings/CLI/Target.h b/src/CppParser/Bindings/CLI/Target.h
index 62adea48..a5cef524 100644
--- a/src/CppParser/Bindings/CLI/Target.h
+++ b/src/CppParser/Bindings/CLI/Target.h
@@ -44,6 +44,7 @@ namespace CppSharp
 
             ParserTargetInfo(::CppSharp::CppParser::ParserTargetInfo* native);
             static ParserTargetInfo^ __CreateInstance(::System::IntPtr native);
+            static ParserTargetInfo^ __CreateInstance(::System::IntPtr native, bool __ownsNativeInstance);
             ParserTargetInfo();
 
             ParserTargetInfo(CppSharp::Parser::ParserTargetInfo^ _0);
@@ -284,7 +285,7 @@ namespace CppSharp
                 void set(unsigned int);
             }
 
-            private:
+            protected:
             bool __ownsNativeInstance;
         };
     }
diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs
index e4075fb9..ed576d6d 100644
--- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs
+++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/AST.cs
@@ -267,11 +267,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Type> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Type>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Type __CreateInstance(global::System.IntPtr native)
+                public static Type __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Type((Type.Internal*) native);
+                    return new Type((Type.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Type __CreateInstance(Type.Internal native)
@@ -389,11 +389,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TypeQualifiers> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TypeQualifiers>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TypeQualifiers __CreateInstance(global::System.IntPtr native)
+                public static TypeQualifiers __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypeQualifiers((TypeQualifiers.Internal*) native);
+                    return new TypeQualifiers((TypeQualifiers.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypeQualifiers __CreateInstance(TypeQualifiers.Internal native)
@@ -523,11 +523,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, QualifiedType> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, QualifiedType>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static QualifiedType __CreateInstance(global::System.IntPtr native)
+                public static QualifiedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new QualifiedType((QualifiedType.Internal*) native);
+                    return new QualifiedType((QualifiedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static QualifiedType __CreateInstance(QualifiedType.Internal native)
@@ -650,11 +650,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TagType __CreateInstance(global::System.IntPtr native)
+                public static new TagType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TagType((TagType.Internal*) native);
+                    return new TagType((TagType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TagType __CreateInstance(TagType.Internal native)
@@ -777,11 +777,11 @@ namespace CppSharp
                     Incomplete = 3
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ArrayType __CreateInstance(global::System.IntPtr native)
+                public static new ArrayType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ArrayType((ArrayType.Internal*) native);
+                    return new ArrayType((ArrayType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ArrayType __CreateInstance(ArrayType.Internal native)
@@ -939,11 +939,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FunctionType __CreateInstance(global::System.IntPtr native)
+                public static new FunctionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionType((FunctionType.Internal*) native);
+                    return new FunctionType((FunctionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionType __CreateInstance(FunctionType.Internal native)
@@ -1102,11 +1102,11 @@ namespace CppSharp
                     RVReference = 3
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PointerType __CreateInstance(global::System.IntPtr native)
+                public static new PointerType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PointerType((PointerType.Internal*) native);
+                    return new PointerType((PointerType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PointerType __CreateInstance(PointerType.Internal native)
@@ -1223,11 +1223,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MemberPointerType __CreateInstance(global::System.IntPtr native)
+                public static new MemberPointerType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MemberPointerType((MemberPointerType.Internal*) native);
+                    return new MemberPointerType((MemberPointerType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MemberPointerType __CreateInstance(MemberPointerType.Internal native)
@@ -1331,11 +1331,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TypedefType __CreateInstance(global::System.IntPtr native)
+                public static new TypedefType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypedefType((TypedefType.Internal*) native);
+                    return new TypedefType((TypedefType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypedefType __CreateInstance(TypedefType.Internal native)
@@ -1447,11 +1447,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new AttributedType __CreateInstance(global::System.IntPtr native)
+                public static new AttributedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new AttributedType((AttributedType.Internal*) native);
+                    return new AttributedType((AttributedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static AttributedType __CreateInstance(AttributedType.Internal native)
@@ -1574,11 +1574,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DecayedType __CreateInstance(global::System.IntPtr native)
+                public static new DecayedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DecayedType((DecayedType.Internal*) native);
+                    return new DecayedType((DecayedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DecayedType __CreateInstance(DecayedType.Internal native)
@@ -1726,11 +1726,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateArgument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateArgument>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TemplateArgument __CreateInstance(global::System.IntPtr native)
+                public static TemplateArgument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateArgument((TemplateArgument.Internal*) native);
+                    return new TemplateArgument((TemplateArgument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateArgument __CreateInstance(TemplateArgument.Internal native)
@@ -1907,11 +1907,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateSpecializationType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateSpecializationType((TemplateSpecializationType.Internal*) native);
+                    return new TemplateSpecializationType((TemplateSpecializationType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateSpecializationType __CreateInstance(TemplateSpecializationType.Internal native)
@@ -2083,11 +2083,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateParameter> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateParameter>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TemplateParameter __CreateInstance(global::System.IntPtr native)
+                public static TemplateParameter __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameter((TemplateParameter.Internal*) native);
+                    return new TemplateParameter((TemplateParameter.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameter __CreateInstance(TemplateParameter.Internal native)
@@ -2247,11 +2247,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateParameterType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateParameterType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameterType((TemplateParameterType.Internal*) native);
+                    return new TemplateParameterType((TemplateParameterType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameterType __CreateInstance(TemplateParameterType.Internal native)
@@ -2394,11 +2394,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateParameterSubstitutionType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateParameterSubstitutionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameterSubstitutionType((TemplateParameterSubstitutionType.Internal*) native);
+                    return new TemplateParameterSubstitutionType((TemplateParameterSubstitutionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameterSubstitutionType __CreateInstance(TemplateParameterSubstitutionType.Internal native)
@@ -2505,11 +2505,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InjectedClassNameType __CreateInstance(global::System.IntPtr native)
+                public static new InjectedClassNameType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InjectedClassNameType((InjectedClassNameType.Internal*) native);
+                    return new InjectedClassNameType((InjectedClassNameType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InjectedClassNameType __CreateInstance(InjectedClassNameType.Internal native)
@@ -2633,11 +2633,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DependentNameType __CreateInstance(global::System.IntPtr native)
+                public static new DependentNameType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DependentNameType((DependentNameType.Internal*) native);
+                    return new DependentNameType((DependentNameType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DependentNameType __CreateInstance(DependentNameType.Internal native)
@@ -2725,11 +2725,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PackExpansionType __CreateInstance(global::System.IntPtr native)
+                public static new PackExpansionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PackExpansionType((PackExpansionType.Internal*) native);
+                    return new PackExpansionType((PackExpansionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PackExpansionType __CreateInstance(PackExpansionType.Internal native)
@@ -2820,11 +2820,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BuiltinType __CreateInstance(global::System.IntPtr native)
+                public static new BuiltinType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BuiltinType((BuiltinType.Internal*) native);
+                    return new BuiltinType((BuiltinType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BuiltinType __CreateInstance(BuiltinType.Internal native)
@@ -2931,11 +2931,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableComponent> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableComponent>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VTableComponent __CreateInstance(global::System.IntPtr native)
+                public static VTableComponent __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VTableComponent((VTableComponent.Internal*) native);
+                    return new VTableComponent((VTableComponent.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VTableComponent __CreateInstance(VTableComponent.Internal native)
@@ -3090,11 +3090,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableLayout> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableLayout>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VTableLayout __CreateInstance(global::System.IntPtr native)
+                public static VTableLayout __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VTableLayout((VTableLayout.Internal*) native);
+                    return new VTableLayout((VTableLayout.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VTableLayout __CreateInstance(VTableLayout.Internal native)
@@ -3227,11 +3227,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VFTableInfo> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VFTableInfo>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VFTableInfo __CreateInstance(global::System.IntPtr native)
+                public static VFTableInfo __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VFTableInfo((VFTableInfo.Internal*) native);
+                    return new VFTableInfo((VFTableInfo.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VFTableInfo __CreateInstance(VFTableInfo.Internal native)
@@ -3418,11 +3418,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClassLayout> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClassLayout>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static ClassLayout __CreateInstance(global::System.IntPtr native)
+                public static ClassLayout __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassLayout((ClassLayout.Internal*) native);
+                    return new ClassLayout((ClassLayout.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassLayout __CreateInstance(ClassLayout.Internal native)
@@ -3710,11 +3710,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Declaration> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Declaration>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Declaration __CreateInstance(global::System.IntPtr native)
+                public static Declaration __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Declaration((Declaration.Internal*) native);
+                    return new Declaration((Declaration.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Declaration __CreateInstance(Declaration.Internal native)
@@ -4239,11 +4239,11 @@ namespace CppSharp
                     internal static extern uint getFriendsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DeclarationContext __CreateInstance(global::System.IntPtr native)
+                public static new DeclarationContext __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DeclarationContext((DeclarationContext.Internal*) native);
+                    return new DeclarationContext((DeclarationContext.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DeclarationContext __CreateInstance(DeclarationContext.Internal native)
@@ -4631,11 +4631,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TypedefDecl __CreateInstance(global::System.IntPtr native)
+                public static new TypedefDecl __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypedefDecl((TypedefDecl.Internal*) native);
+                    return new TypedefDecl((TypedefDecl.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypedefDecl __CreateInstance(TypedefDecl.Internal native)
@@ -4774,11 +4774,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Friend __CreateInstance(global::System.IntPtr native)
+                public static new Friend __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Friend((Friend.Internal*) native);
+                    return new Friend((Friend.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Friend __CreateInstance(Friend.Internal native)
@@ -4897,11 +4897,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Statement> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Statement>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Statement __CreateInstance(global::System.IntPtr native)
+                public static Statement __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Statement((Statement.Internal*) native);
+                    return new Statement((Statement.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Statement __CreateInstance(Statement.Internal native)
@@ -5032,11 +5032,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Expression __CreateInstance(global::System.IntPtr native)
+                public static new Expression __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Expression((Expression.Internal*) native);
+                    return new Expression((Expression.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Expression __CreateInstance(Expression.Internal native)
@@ -5131,11 +5131,11 @@ namespace CppSharp
                     internal static extern void setOpcodeStr_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BinaryOperator __CreateInstance(global::System.IntPtr native)
+                public static new BinaryOperator __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BinaryOperator((BinaryOperator.Internal*) native);
+                    return new BinaryOperator((BinaryOperator.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BinaryOperator __CreateInstance(BinaryOperator.Internal native)
@@ -5286,11 +5286,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new CXXConstructExpr __CreateInstance(global::System.IntPtr native)
+                public static new CXXConstructExpr __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new CXXConstructExpr((CXXConstructExpr.Internal*) native);
+                    return new CXXConstructExpr((CXXConstructExpr.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static CXXConstructExpr __CreateInstance(CXXConstructExpr.Internal native)
@@ -5450,11 +5450,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Parameter __CreateInstance(global::System.IntPtr native)
+                public static new Parameter __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Parameter((Parameter.Internal*) native);
+                    return new Parameter((Parameter.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Parameter __CreateInstance(Parameter.Internal native)
@@ -5717,11 +5717,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Function __CreateInstance(global::System.IntPtr native)
+                public static new Function __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Function((Function.Internal*) native);
+                    return new Function((Function.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Function __CreateInstance(Function.Internal native)
@@ -6108,11 +6108,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Method __CreateInstance(global::System.IntPtr native)
+                public static new Method __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Method((Method.Internal*) native);
+                    return new Method((Method.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Method __CreateInstance(Method.Internal native)
@@ -6506,11 +6506,11 @@ namespace CppSharp
                         internal static extern void setExpression_0(global::System.IntPtr instance, global::System.IntPtr s);
                     }
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static new Item __CreateInstance(global::System.IntPtr native)
+                    public static new Item __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Item((Item.Internal*) native);
+                        return new Item((Item.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Item __CreateInstance(Item.Internal native)
@@ -6605,11 +6605,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Enumeration __CreateInstance(global::System.IntPtr native)
+                public static new Enumeration __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Enumeration((Enumeration.Internal*) native);
+                    return new Enumeration((Enumeration.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Enumeration __CreateInstance(Enumeration.Internal native)
@@ -6821,11 +6821,11 @@ namespace CppSharp
                     internal static extern void setMangled_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Variable __CreateInstance(global::System.IntPtr native)
+                public static new Variable __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Variable((Variable.Internal*) native);
+                    return new Variable((Variable.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Variable __CreateInstance(Variable.Internal native)
@@ -6951,11 +6951,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, BaseClassSpecifier> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, BaseClassSpecifier>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static BaseClassSpecifier __CreateInstance(global::System.IntPtr native)
+                public static BaseClassSpecifier __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BaseClassSpecifier((BaseClassSpecifier.Internal*) native);
+                    return new BaseClassSpecifier((BaseClassSpecifier.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BaseClassSpecifier __CreateInstance(BaseClassSpecifier.Internal native)
@@ -7151,11 +7151,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Field __CreateInstance(global::System.IntPtr native)
+                public static new Field __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Field((Field.Internal*) native);
+                    return new Field((Field.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Field __CreateInstance(Field.Internal native)
@@ -7348,11 +7348,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new AccessSpecifierDecl __CreateInstance(global::System.IntPtr native)
+                public static new AccessSpecifierDecl __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new AccessSpecifierDecl((AccessSpecifierDecl.Internal*) native);
+                    return new AccessSpecifierDecl((AccessSpecifierDecl.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static AccessSpecifierDecl __CreateInstance(AccessSpecifierDecl.Internal native)
@@ -7588,11 +7588,11 @@ namespace CppSharp
                     internal static extern uint getSpecifiersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Class __CreateInstance(global::System.IntPtr native)
+                public static new Class __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Class((Class.Internal*) native);
+                    return new Class((Class.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Class __CreateInstance(Class.Internal native)
@@ -8002,11 +8002,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Template __CreateInstance(global::System.IntPtr native)
+                public static new Template __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Template((Template.Internal*) native);
+                    return new Template((Template.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Template __CreateInstance(Template.Internal native)
@@ -8207,11 +8207,11 @@ namespace CppSharp
                     internal static extern uint getSpecializationsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplate __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplate __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplate((ClassTemplate.Internal*) native);
+                    return new ClassTemplate((ClassTemplate.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplate __CreateInstance(ClassTemplate.Internal native)
@@ -8424,11 +8424,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplateSpecialization __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplateSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplateSpecialization((ClassTemplateSpecialization.Internal*) native);
+                    return new ClassTemplateSpecialization((ClassTemplateSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplateSpecialization __CreateInstance(ClassTemplateSpecialization.Internal native)
@@ -8648,11 +8648,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplatePartialSpecialization __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplatePartialSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplatePartialSpecialization((ClassTemplatePartialSpecialization.Internal*) native);
+                    return new ClassTemplatePartialSpecialization((ClassTemplatePartialSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplatePartialSpecialization __CreateInstance(ClassTemplatePartialSpecialization.Internal native)
@@ -8798,11 +8798,11 @@ namespace CppSharp
                     internal static extern uint getSpecializationsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FunctionTemplate __CreateInstance(global::System.IntPtr native)
+                public static new FunctionTemplate __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionTemplate((FunctionTemplate.Internal*) native);
+                    return new FunctionTemplate((FunctionTemplate.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionTemplate __CreateInstance(FunctionTemplate.Internal native)
@@ -8952,11 +8952,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, FunctionTemplateSpecialization> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, FunctionTemplateSpecialization>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static FunctionTemplateSpecialization __CreateInstance(global::System.IntPtr native)
+                public static FunctionTemplateSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionTemplateSpecialization((FunctionTemplateSpecialization.Internal*) native);
+                    return new FunctionTemplateSpecialization((FunctionTemplateSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionTemplateSpecialization __CreateInstance(FunctionTemplateSpecialization.Internal native)
@@ -9165,11 +9165,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Namespace __CreateInstance(global::System.IntPtr native)
+                public static new Namespace __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Namespace((Namespace.Internal*) native);
+                    return new Namespace((Namespace.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Namespace __CreateInstance(Namespace.Internal native)
@@ -9308,11 +9308,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PreprocessedEntity __CreateInstance(global::System.IntPtr native)
+                public static new PreprocessedEntity __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PreprocessedEntity((PreprocessedEntity.Internal*) native);
+                    return new PreprocessedEntity((PreprocessedEntity.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PreprocessedEntity __CreateInstance(PreprocessedEntity.Internal native)
@@ -9461,11 +9461,11 @@ namespace CppSharp
                     internal static extern void setExpression_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MacroDefinition __CreateInstance(global::System.IntPtr native)
+                public static new MacroDefinition __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MacroDefinition((MacroDefinition.Internal*) native);
+                    return new MacroDefinition((MacroDefinition.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MacroDefinition __CreateInstance(MacroDefinition.Internal native)
@@ -9620,11 +9620,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MacroExpansion __CreateInstance(global::System.IntPtr native)
+                public static new MacroExpansion __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MacroExpansion((MacroExpansion.Internal*) native);
+                    return new MacroExpansion((MacroExpansion.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MacroExpansion __CreateInstance(MacroExpansion.Internal native)
@@ -9820,11 +9820,11 @@ namespace CppSharp
                     internal static extern uint getMacrosCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TranslationUnit __CreateInstance(global::System.IntPtr native)
+                public static new TranslationUnit __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TranslationUnit((TranslationUnit.Internal*) native);
+                    return new TranslationUnit((TranslationUnit.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TranslationUnit __CreateInstance(TranslationUnit.Internal native)
@@ -10027,11 +10027,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, NativeLibrary> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, NativeLibrary>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static NativeLibrary __CreateInstance(global::System.IntPtr native)
+                public static NativeLibrary __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new NativeLibrary((NativeLibrary.Internal*) native);
+                    return new NativeLibrary((NativeLibrary.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static NativeLibrary __CreateInstance(NativeLibrary.Internal native)
@@ -10228,11 +10228,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ASTContext> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ASTContext>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static ASTContext __CreateInstance(global::System.IntPtr native)
+                public static ASTContext __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ASTContext((ASTContext.Internal*) native);
+                    return new ASTContext((ASTContext.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ASTContext __CreateInstance(ASTContext.Internal native)
@@ -10355,11 +10355,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Comment> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Comment>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Comment __CreateInstance(global::System.IntPtr native)
+                public static Comment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Comment((Comment.Internal*) native);
+                    return new Comment((Comment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Comment __CreateInstance(Comment.Internal native)
@@ -10464,11 +10464,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BlockContentComment __CreateInstance(global::System.IntPtr native)
+                public static new BlockContentComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BlockContentComment((BlockContentComment.Internal*) native);
+                    return new BlockContentComment((BlockContentComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BlockContentComment __CreateInstance(BlockContentComment.Internal native)
@@ -10587,11 +10587,11 @@ namespace CppSharp
                     internal static extern uint getBlocksCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FullComment __CreateInstance(global::System.IntPtr native)
+                public static new FullComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FullComment((FullComment.Internal*) native);
+                    return new FullComment((FullComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FullComment __CreateInstance(FullComment.Internal native)
@@ -10774,11 +10774,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Argument __CreateInstance(global::System.IntPtr native)
+                    public static Argument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Argument((Argument.Internal*) native);
+                        return new Argument((Argument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Argument __CreateInstance(Argument.Internal native)
@@ -10864,11 +10864,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BlockCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new BlockCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BlockCommandComment((BlockCommandComment.Internal*) native);
+                    return new BlockCommandComment((BlockCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BlockCommandComment __CreateInstance(BlockCommandComment.Internal native)
@@ -11024,11 +11024,11 @@ namespace CppSharp
                     InOut = 2
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ParamCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new ParamCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ParamCommandComment((ParamCommandComment.Internal*) native);
+                    return new ParamCommandComment((ParamCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ParamCommandComment __CreateInstance(ParamCommandComment.Internal native)
@@ -11167,11 +11167,11 @@ namespace CppSharp
                     internal static extern uint getPositionCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TParamCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new TParamCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TParamCommandComment((TParamCommandComment.Internal*) native);
+                    return new TParamCommandComment((TParamCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TParamCommandComment __CreateInstance(TParamCommandComment.Internal native)
@@ -11299,11 +11299,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimBlockLineComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimBlockLineComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimBlockLineComment((VerbatimBlockLineComment.Internal*) native);
+                    return new VerbatimBlockLineComment((VerbatimBlockLineComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimBlockLineComment __CreateInstance(VerbatimBlockLineComment.Internal native)
@@ -11432,11 +11432,11 @@ namespace CppSharp
                     internal static extern uint getLinesCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimBlockComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimBlockComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimBlockComment((VerbatimBlockComment.Internal*) native);
+                    return new VerbatimBlockComment((VerbatimBlockComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimBlockComment __CreateInstance(VerbatimBlockComment.Internal native)
@@ -11570,11 +11570,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimLineComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimLineComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimLineComment((VerbatimLineComment.Internal*) native);
+                    return new VerbatimLineComment((VerbatimLineComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimLineComment __CreateInstance(VerbatimLineComment.Internal native)
@@ -11680,11 +11680,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InlineContentComment __CreateInstance(global::System.IntPtr native)
+                public static new InlineContentComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InlineContentComment((InlineContentComment.Internal*) native);
+                    return new InlineContentComment((InlineContentComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InlineContentComment __CreateInstance(InlineContentComment.Internal native)
@@ -11806,11 +11806,11 @@ namespace CppSharp
                     internal static extern uint getContentCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ParagraphComment __CreateInstance(global::System.IntPtr native)
+                public static new ParagraphComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ParagraphComment((ParagraphComment.Internal*) native);
+                    return new ParagraphComment((ParagraphComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ParagraphComment __CreateInstance(ParagraphComment.Internal native)
@@ -12009,11 +12009,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Argument __CreateInstance(global::System.IntPtr native)
+                    public static Argument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Argument((Argument.Internal*) native);
+                        return new Argument((Argument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Argument __CreateInstance(Argument.Internal native)
@@ -12099,11 +12099,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InlineCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new InlineCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InlineCommandComment((InlineCommandComment.Internal*) native);
+                    return new InlineCommandComment((InlineCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InlineCommandComment __CreateInstance(InlineCommandComment.Internal native)
@@ -12233,11 +12233,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLTagComment((HTMLTagComment.Internal*) native);
+                    return new HTMLTagComment((HTMLTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLTagComment __CreateInstance(HTMLTagComment.Internal native)
@@ -12410,11 +12410,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Attribute> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Attribute>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Attribute __CreateInstance(global::System.IntPtr native)
+                    public static Attribute __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Attribute((Attribute.Internal*) native);
+                        return new Attribute((Attribute.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Attribute __CreateInstance(Attribute.Internal native)
@@ -12516,11 +12516,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLStartTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLStartTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLStartTagComment((HTMLStartTagComment.Internal*) native);
+                    return new HTMLStartTagComment((HTMLStartTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLStartTagComment __CreateInstance(HTMLStartTagComment.Internal native)
@@ -12663,11 +12663,11 @@ namespace CppSharp
                     internal static extern void setTagName_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLEndTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLEndTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLEndTagComment((HTMLEndTagComment.Internal*) native);
+                    return new HTMLEndTagComment((HTMLEndTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLEndTagComment __CreateInstance(HTMLEndTagComment.Internal native)
@@ -12783,11 +12783,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TextComment __CreateInstance(global::System.IntPtr native)
+                public static new TextComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TextComment((TextComment.Internal*) native);
+                    return new TextComment((TextComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TextComment __CreateInstance(TextComment.Internal native)
@@ -12919,11 +12919,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, RawComment> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, RawComment>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static RawComment __CreateInstance(global::System.IntPtr native)
+                public static RawComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new RawComment((RawComment.Internal*) native);
+                    return new RawComment((RawComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static RawComment __CreateInstance(RawComment.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppParser.cs b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppParser.cs
index 1348b55c..5eba5e13 100644
--- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppParser.cs
+++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppParser.cs
@@ -233,11 +233,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserOptions> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserOptions>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserOptions __CreateInstance(global::System.IntPtr native)
+            public static ParserOptions __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserOptions((ParserOptions.Internal*) native);
+                return new ParserOptions((ParserOptions.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserOptions __CreateInstance(ParserOptions.Internal native)
@@ -663,11 +663,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserDiagnostic> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserDiagnostic>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserDiagnostic __CreateInstance(global::System.IntPtr native)
+            public static ParserDiagnostic __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserDiagnostic((ParserDiagnostic.Internal*) native);
+                return new ParserDiagnostic((ParserDiagnostic.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserDiagnostic __CreateInstance(ParserDiagnostic.Internal native)
@@ -864,11 +864,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserResult> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserResult>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserResult __CreateInstance(global::System.IntPtr native)
+            public static ParserResult __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserResult((ParserResult.Internal*) native);
+                return new ParserResult((ParserResult.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserResult __CreateInstance(ParserResult.Internal native)
@@ -1043,11 +1043,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClangParser> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClangParser>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ClangParser __CreateInstance(global::System.IntPtr native)
+            public static ClangParser __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ClangParser((ClangParser.Internal*) native);
+                return new ClangParser((ClangParser.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ClangParser __CreateInstance(ClangParser.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Target.cs b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Target.cs
index 14c0f563..ad14ef3e 100644
--- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Target.cs
+++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Target.cs
@@ -173,11 +173,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserTargetInfo> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserTargetInfo>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserTargetInfo __CreateInstance(global::System.IntPtr native)
+            public static ParserTargetInfo __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserTargetInfo((ParserTargetInfo.Internal*) native);
+                return new ParserTargetInfo((ParserTargetInfo.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserTargetInfo __CreateInstance(ParserTargetInfo.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs
index 9cdc7870..33899fa4 100644
--- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs
+++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/AST.cs
@@ -267,11 +267,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Type> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Type>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Type __CreateInstance(global::System.IntPtr native)
+                public static Type __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Type((Type.Internal*) native);
+                    return new Type((Type.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Type __CreateInstance(Type.Internal native)
@@ -389,11 +389,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TypeQualifiers> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TypeQualifiers>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TypeQualifiers __CreateInstance(global::System.IntPtr native)
+                public static TypeQualifiers __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypeQualifiers((TypeQualifiers.Internal*) native);
+                    return new TypeQualifiers((TypeQualifiers.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypeQualifiers __CreateInstance(TypeQualifiers.Internal native)
@@ -523,11 +523,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, QualifiedType> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, QualifiedType>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static QualifiedType __CreateInstance(global::System.IntPtr native)
+                public static QualifiedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new QualifiedType((QualifiedType.Internal*) native);
+                    return new QualifiedType((QualifiedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static QualifiedType __CreateInstance(QualifiedType.Internal native)
@@ -650,11 +650,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TagType __CreateInstance(global::System.IntPtr native)
+                public static new TagType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TagType((TagType.Internal*) native);
+                    return new TagType((TagType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TagType __CreateInstance(TagType.Internal native)
@@ -777,11 +777,11 @@ namespace CppSharp
                     Incomplete = 3
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ArrayType __CreateInstance(global::System.IntPtr native)
+                public static new ArrayType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ArrayType((ArrayType.Internal*) native);
+                    return new ArrayType((ArrayType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ArrayType __CreateInstance(ArrayType.Internal native)
@@ -939,11 +939,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FunctionType __CreateInstance(global::System.IntPtr native)
+                public static new FunctionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionType((FunctionType.Internal*) native);
+                    return new FunctionType((FunctionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionType __CreateInstance(FunctionType.Internal native)
@@ -1102,11 +1102,11 @@ namespace CppSharp
                     RVReference = 3
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PointerType __CreateInstance(global::System.IntPtr native)
+                public static new PointerType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PointerType((PointerType.Internal*) native);
+                    return new PointerType((PointerType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PointerType __CreateInstance(PointerType.Internal native)
@@ -1223,11 +1223,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MemberPointerType __CreateInstance(global::System.IntPtr native)
+                public static new MemberPointerType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MemberPointerType((MemberPointerType.Internal*) native);
+                    return new MemberPointerType((MemberPointerType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MemberPointerType __CreateInstance(MemberPointerType.Internal native)
@@ -1331,11 +1331,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TypedefType __CreateInstance(global::System.IntPtr native)
+                public static new TypedefType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypedefType((TypedefType.Internal*) native);
+                    return new TypedefType((TypedefType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypedefType __CreateInstance(TypedefType.Internal native)
@@ -1447,11 +1447,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new AttributedType __CreateInstance(global::System.IntPtr native)
+                public static new AttributedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new AttributedType((AttributedType.Internal*) native);
+                    return new AttributedType((AttributedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static AttributedType __CreateInstance(AttributedType.Internal native)
@@ -1574,11 +1574,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DecayedType __CreateInstance(global::System.IntPtr native)
+                public static new DecayedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DecayedType((DecayedType.Internal*) native);
+                    return new DecayedType((DecayedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DecayedType __CreateInstance(DecayedType.Internal native)
@@ -1726,11 +1726,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateArgument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateArgument>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TemplateArgument __CreateInstance(global::System.IntPtr native)
+                public static TemplateArgument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateArgument((TemplateArgument.Internal*) native);
+                    return new TemplateArgument((TemplateArgument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateArgument __CreateInstance(TemplateArgument.Internal native)
@@ -1907,11 +1907,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateSpecializationType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateSpecializationType((TemplateSpecializationType.Internal*) native);
+                    return new TemplateSpecializationType((TemplateSpecializationType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateSpecializationType __CreateInstance(TemplateSpecializationType.Internal native)
@@ -2083,11 +2083,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateParameter> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateParameter>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TemplateParameter __CreateInstance(global::System.IntPtr native)
+                public static TemplateParameter __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameter((TemplateParameter.Internal*) native);
+                    return new TemplateParameter((TemplateParameter.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameter __CreateInstance(TemplateParameter.Internal native)
@@ -2247,11 +2247,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateParameterType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateParameterType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameterType((TemplateParameterType.Internal*) native);
+                    return new TemplateParameterType((TemplateParameterType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameterType __CreateInstance(TemplateParameterType.Internal native)
@@ -2394,11 +2394,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateParameterSubstitutionType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateParameterSubstitutionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameterSubstitutionType((TemplateParameterSubstitutionType.Internal*) native);
+                    return new TemplateParameterSubstitutionType((TemplateParameterSubstitutionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameterSubstitutionType __CreateInstance(TemplateParameterSubstitutionType.Internal native)
@@ -2505,11 +2505,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InjectedClassNameType __CreateInstance(global::System.IntPtr native)
+                public static new InjectedClassNameType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InjectedClassNameType((InjectedClassNameType.Internal*) native);
+                    return new InjectedClassNameType((InjectedClassNameType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InjectedClassNameType __CreateInstance(InjectedClassNameType.Internal native)
@@ -2633,11 +2633,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DependentNameType __CreateInstance(global::System.IntPtr native)
+                public static new DependentNameType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DependentNameType((DependentNameType.Internal*) native);
+                    return new DependentNameType((DependentNameType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DependentNameType __CreateInstance(DependentNameType.Internal native)
@@ -2725,11 +2725,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PackExpansionType __CreateInstance(global::System.IntPtr native)
+                public static new PackExpansionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PackExpansionType((PackExpansionType.Internal*) native);
+                    return new PackExpansionType((PackExpansionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PackExpansionType __CreateInstance(PackExpansionType.Internal native)
@@ -2820,11 +2820,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BuiltinType __CreateInstance(global::System.IntPtr native)
+                public static new BuiltinType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BuiltinType((BuiltinType.Internal*) native);
+                    return new BuiltinType((BuiltinType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BuiltinType __CreateInstance(BuiltinType.Internal native)
@@ -2931,11 +2931,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableComponent> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableComponent>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VTableComponent __CreateInstance(global::System.IntPtr native)
+                public static VTableComponent __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VTableComponent((VTableComponent.Internal*) native);
+                    return new VTableComponent((VTableComponent.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VTableComponent __CreateInstance(VTableComponent.Internal native)
@@ -3090,11 +3090,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableLayout> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableLayout>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VTableLayout __CreateInstance(global::System.IntPtr native)
+                public static VTableLayout __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VTableLayout((VTableLayout.Internal*) native);
+                    return new VTableLayout((VTableLayout.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VTableLayout __CreateInstance(VTableLayout.Internal native)
@@ -3227,11 +3227,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VFTableInfo> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VFTableInfo>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VFTableInfo __CreateInstance(global::System.IntPtr native)
+                public static VFTableInfo __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VFTableInfo((VFTableInfo.Internal*) native);
+                    return new VFTableInfo((VFTableInfo.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VFTableInfo __CreateInstance(VFTableInfo.Internal native)
@@ -3418,11 +3418,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClassLayout> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClassLayout>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static ClassLayout __CreateInstance(global::System.IntPtr native)
+                public static ClassLayout __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassLayout((ClassLayout.Internal*) native);
+                    return new ClassLayout((ClassLayout.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassLayout __CreateInstance(ClassLayout.Internal native)
@@ -3710,11 +3710,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Declaration> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Declaration>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Declaration __CreateInstance(global::System.IntPtr native)
+                public static Declaration __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Declaration((Declaration.Internal*) native);
+                    return new Declaration((Declaration.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Declaration __CreateInstance(Declaration.Internal native)
@@ -4239,11 +4239,11 @@ namespace CppSharp
                     internal static extern uint getFriendsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DeclarationContext __CreateInstance(global::System.IntPtr native)
+                public static new DeclarationContext __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DeclarationContext((DeclarationContext.Internal*) native);
+                    return new DeclarationContext((DeclarationContext.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DeclarationContext __CreateInstance(DeclarationContext.Internal native)
@@ -4631,11 +4631,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TypedefDecl __CreateInstance(global::System.IntPtr native)
+                public static new TypedefDecl __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypedefDecl((TypedefDecl.Internal*) native);
+                    return new TypedefDecl((TypedefDecl.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypedefDecl __CreateInstance(TypedefDecl.Internal native)
@@ -4774,11 +4774,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Friend __CreateInstance(global::System.IntPtr native)
+                public static new Friend __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Friend((Friend.Internal*) native);
+                    return new Friend((Friend.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Friend __CreateInstance(Friend.Internal native)
@@ -4897,11 +4897,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Statement> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Statement>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Statement __CreateInstance(global::System.IntPtr native)
+                public static Statement __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Statement((Statement.Internal*) native);
+                    return new Statement((Statement.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Statement __CreateInstance(Statement.Internal native)
@@ -5032,11 +5032,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Expression __CreateInstance(global::System.IntPtr native)
+                public static new Expression __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Expression((Expression.Internal*) native);
+                    return new Expression((Expression.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Expression __CreateInstance(Expression.Internal native)
@@ -5131,11 +5131,11 @@ namespace CppSharp
                     internal static extern void setOpcodeStr_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BinaryOperator __CreateInstance(global::System.IntPtr native)
+                public static new BinaryOperator __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BinaryOperator((BinaryOperator.Internal*) native);
+                    return new BinaryOperator((BinaryOperator.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BinaryOperator __CreateInstance(BinaryOperator.Internal native)
@@ -5286,11 +5286,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new CXXConstructExpr __CreateInstance(global::System.IntPtr native)
+                public static new CXXConstructExpr __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new CXXConstructExpr((CXXConstructExpr.Internal*) native);
+                    return new CXXConstructExpr((CXXConstructExpr.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static CXXConstructExpr __CreateInstance(CXXConstructExpr.Internal native)
@@ -5450,11 +5450,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Parameter __CreateInstance(global::System.IntPtr native)
+                public static new Parameter __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Parameter((Parameter.Internal*) native);
+                    return new Parameter((Parameter.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Parameter __CreateInstance(Parameter.Internal native)
@@ -5717,11 +5717,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Function __CreateInstance(global::System.IntPtr native)
+                public static new Function __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Function((Function.Internal*) native);
+                    return new Function((Function.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Function __CreateInstance(Function.Internal native)
@@ -6108,11 +6108,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Method __CreateInstance(global::System.IntPtr native)
+                public static new Method __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Method((Method.Internal*) native);
+                    return new Method((Method.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Method __CreateInstance(Method.Internal native)
@@ -6506,11 +6506,11 @@ namespace CppSharp
                         internal static extern void setExpression_0(global::System.IntPtr instance, global::System.IntPtr s);
                     }
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static new Item __CreateInstance(global::System.IntPtr native)
+                    public static new Item __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Item((Item.Internal*) native);
+                        return new Item((Item.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Item __CreateInstance(Item.Internal native)
@@ -6605,11 +6605,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Enumeration __CreateInstance(global::System.IntPtr native)
+                public static new Enumeration __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Enumeration((Enumeration.Internal*) native);
+                    return new Enumeration((Enumeration.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Enumeration __CreateInstance(Enumeration.Internal native)
@@ -6821,11 +6821,11 @@ namespace CppSharp
                     internal static extern void setMangled_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Variable __CreateInstance(global::System.IntPtr native)
+                public static new Variable __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Variable((Variable.Internal*) native);
+                    return new Variable((Variable.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Variable __CreateInstance(Variable.Internal native)
@@ -6951,11 +6951,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, BaseClassSpecifier> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, BaseClassSpecifier>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static BaseClassSpecifier __CreateInstance(global::System.IntPtr native)
+                public static BaseClassSpecifier __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BaseClassSpecifier((BaseClassSpecifier.Internal*) native);
+                    return new BaseClassSpecifier((BaseClassSpecifier.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BaseClassSpecifier __CreateInstance(BaseClassSpecifier.Internal native)
@@ -7151,11 +7151,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Field __CreateInstance(global::System.IntPtr native)
+                public static new Field __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Field((Field.Internal*) native);
+                    return new Field((Field.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Field __CreateInstance(Field.Internal native)
@@ -7348,11 +7348,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new AccessSpecifierDecl __CreateInstance(global::System.IntPtr native)
+                public static new AccessSpecifierDecl __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new AccessSpecifierDecl((AccessSpecifierDecl.Internal*) native);
+                    return new AccessSpecifierDecl((AccessSpecifierDecl.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static AccessSpecifierDecl __CreateInstance(AccessSpecifierDecl.Internal native)
@@ -7588,11 +7588,11 @@ namespace CppSharp
                     internal static extern uint getSpecifiersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Class __CreateInstance(global::System.IntPtr native)
+                public static new Class __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Class((Class.Internal*) native);
+                    return new Class((Class.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Class __CreateInstance(Class.Internal native)
@@ -8002,11 +8002,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Template __CreateInstance(global::System.IntPtr native)
+                public static new Template __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Template((Template.Internal*) native);
+                    return new Template((Template.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Template __CreateInstance(Template.Internal native)
@@ -8207,11 +8207,11 @@ namespace CppSharp
                     internal static extern uint getSpecializationsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplate __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplate __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplate((ClassTemplate.Internal*) native);
+                    return new ClassTemplate((ClassTemplate.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplate __CreateInstance(ClassTemplate.Internal native)
@@ -8424,11 +8424,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplateSpecialization __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplateSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplateSpecialization((ClassTemplateSpecialization.Internal*) native);
+                    return new ClassTemplateSpecialization((ClassTemplateSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplateSpecialization __CreateInstance(ClassTemplateSpecialization.Internal native)
@@ -8648,11 +8648,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplatePartialSpecialization __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplatePartialSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplatePartialSpecialization((ClassTemplatePartialSpecialization.Internal*) native);
+                    return new ClassTemplatePartialSpecialization((ClassTemplatePartialSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplatePartialSpecialization __CreateInstance(ClassTemplatePartialSpecialization.Internal native)
@@ -8798,11 +8798,11 @@ namespace CppSharp
                     internal static extern uint getSpecializationsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FunctionTemplate __CreateInstance(global::System.IntPtr native)
+                public static new FunctionTemplate __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionTemplate((FunctionTemplate.Internal*) native);
+                    return new FunctionTemplate((FunctionTemplate.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionTemplate __CreateInstance(FunctionTemplate.Internal native)
@@ -8952,11 +8952,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, FunctionTemplateSpecialization> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, FunctionTemplateSpecialization>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static FunctionTemplateSpecialization __CreateInstance(global::System.IntPtr native)
+                public static FunctionTemplateSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionTemplateSpecialization((FunctionTemplateSpecialization.Internal*) native);
+                    return new FunctionTemplateSpecialization((FunctionTemplateSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionTemplateSpecialization __CreateInstance(FunctionTemplateSpecialization.Internal native)
@@ -9165,11 +9165,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Namespace __CreateInstance(global::System.IntPtr native)
+                public static new Namespace __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Namespace((Namespace.Internal*) native);
+                    return new Namespace((Namespace.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Namespace __CreateInstance(Namespace.Internal native)
@@ -9308,11 +9308,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance, int delete);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PreprocessedEntity __CreateInstance(global::System.IntPtr native)
+                public static new PreprocessedEntity __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PreprocessedEntity((PreprocessedEntity.Internal*) native);
+                    return new PreprocessedEntity((PreprocessedEntity.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PreprocessedEntity __CreateInstance(PreprocessedEntity.Internal native)
@@ -9461,11 +9461,11 @@ namespace CppSharp
                     internal static extern void setExpression_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MacroDefinition __CreateInstance(global::System.IntPtr native)
+                public static new MacroDefinition __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MacroDefinition((MacroDefinition.Internal*) native);
+                    return new MacroDefinition((MacroDefinition.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MacroDefinition __CreateInstance(MacroDefinition.Internal native)
@@ -9620,11 +9620,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MacroExpansion __CreateInstance(global::System.IntPtr native)
+                public static new MacroExpansion __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MacroExpansion((MacroExpansion.Internal*) native);
+                    return new MacroExpansion((MacroExpansion.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MacroExpansion __CreateInstance(MacroExpansion.Internal native)
@@ -9820,11 +9820,11 @@ namespace CppSharp
                     internal static extern uint getMacrosCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TranslationUnit __CreateInstance(global::System.IntPtr native)
+                public static new TranslationUnit __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TranslationUnit((TranslationUnit.Internal*) native);
+                    return new TranslationUnit((TranslationUnit.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TranslationUnit __CreateInstance(TranslationUnit.Internal native)
@@ -10027,11 +10027,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, NativeLibrary> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, NativeLibrary>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static NativeLibrary __CreateInstance(global::System.IntPtr native)
+                public static NativeLibrary __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new NativeLibrary((NativeLibrary.Internal*) native);
+                    return new NativeLibrary((NativeLibrary.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static NativeLibrary __CreateInstance(NativeLibrary.Internal native)
@@ -10228,11 +10228,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ASTContext> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ASTContext>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static ASTContext __CreateInstance(global::System.IntPtr native)
+                public static ASTContext __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ASTContext((ASTContext.Internal*) native);
+                    return new ASTContext((ASTContext.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ASTContext __CreateInstance(ASTContext.Internal native)
@@ -10355,11 +10355,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Comment> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Comment>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Comment __CreateInstance(global::System.IntPtr native)
+                public static Comment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Comment((Comment.Internal*) native);
+                    return new Comment((Comment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Comment __CreateInstance(Comment.Internal native)
@@ -10464,11 +10464,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BlockContentComment __CreateInstance(global::System.IntPtr native)
+                public static new BlockContentComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BlockContentComment((BlockContentComment.Internal*) native);
+                    return new BlockContentComment((BlockContentComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BlockContentComment __CreateInstance(BlockContentComment.Internal native)
@@ -10587,11 +10587,11 @@ namespace CppSharp
                     internal static extern uint getBlocksCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FullComment __CreateInstance(global::System.IntPtr native)
+                public static new FullComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FullComment((FullComment.Internal*) native);
+                    return new FullComment((FullComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FullComment __CreateInstance(FullComment.Internal native)
@@ -10774,11 +10774,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Argument __CreateInstance(global::System.IntPtr native)
+                    public static Argument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Argument((Argument.Internal*) native);
+                        return new Argument((Argument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Argument __CreateInstance(Argument.Internal native)
@@ -10864,11 +10864,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BlockCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new BlockCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BlockCommandComment((BlockCommandComment.Internal*) native);
+                    return new BlockCommandComment((BlockCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BlockCommandComment __CreateInstance(BlockCommandComment.Internal native)
@@ -11024,11 +11024,11 @@ namespace CppSharp
                     InOut = 2
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ParamCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new ParamCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ParamCommandComment((ParamCommandComment.Internal*) native);
+                    return new ParamCommandComment((ParamCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ParamCommandComment __CreateInstance(ParamCommandComment.Internal native)
@@ -11167,11 +11167,11 @@ namespace CppSharp
                     internal static extern uint getPositionCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TParamCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new TParamCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TParamCommandComment((TParamCommandComment.Internal*) native);
+                    return new TParamCommandComment((TParamCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TParamCommandComment __CreateInstance(TParamCommandComment.Internal native)
@@ -11299,11 +11299,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimBlockLineComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimBlockLineComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimBlockLineComment((VerbatimBlockLineComment.Internal*) native);
+                    return new VerbatimBlockLineComment((VerbatimBlockLineComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimBlockLineComment __CreateInstance(VerbatimBlockLineComment.Internal native)
@@ -11432,11 +11432,11 @@ namespace CppSharp
                     internal static extern uint getLinesCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimBlockComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimBlockComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimBlockComment((VerbatimBlockComment.Internal*) native);
+                    return new VerbatimBlockComment((VerbatimBlockComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimBlockComment __CreateInstance(VerbatimBlockComment.Internal native)
@@ -11570,11 +11570,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimLineComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimLineComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimLineComment((VerbatimLineComment.Internal*) native);
+                    return new VerbatimLineComment((VerbatimLineComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimLineComment __CreateInstance(VerbatimLineComment.Internal native)
@@ -11680,11 +11680,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InlineContentComment __CreateInstance(global::System.IntPtr native)
+                public static new InlineContentComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InlineContentComment((InlineContentComment.Internal*) native);
+                    return new InlineContentComment((InlineContentComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InlineContentComment __CreateInstance(InlineContentComment.Internal native)
@@ -11806,11 +11806,11 @@ namespace CppSharp
                     internal static extern uint getContentCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ParagraphComment __CreateInstance(global::System.IntPtr native)
+                public static new ParagraphComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ParagraphComment((ParagraphComment.Internal*) native);
+                    return new ParagraphComment((ParagraphComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ParagraphComment __CreateInstance(ParagraphComment.Internal native)
@@ -12009,11 +12009,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Argument __CreateInstance(global::System.IntPtr native)
+                    public static Argument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Argument((Argument.Internal*) native);
+                        return new Argument((Argument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Argument __CreateInstance(Argument.Internal native)
@@ -12099,11 +12099,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InlineCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new InlineCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InlineCommandComment((InlineCommandComment.Internal*) native);
+                    return new InlineCommandComment((InlineCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InlineCommandComment __CreateInstance(InlineCommandComment.Internal native)
@@ -12233,11 +12233,11 @@ namespace CppSharp
                     internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLTagComment((HTMLTagComment.Internal*) native);
+                    return new HTMLTagComment((HTMLTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLTagComment __CreateInstance(HTMLTagComment.Internal native)
@@ -12410,11 +12410,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Attribute> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Attribute>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Attribute __CreateInstance(global::System.IntPtr native)
+                    public static Attribute __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Attribute((Attribute.Internal*) native);
+                        return new Attribute((Attribute.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Attribute __CreateInstance(Attribute.Internal native)
@@ -12516,11 +12516,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLStartTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLStartTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLStartTagComment((HTMLStartTagComment.Internal*) native);
+                    return new HTMLStartTagComment((HTMLStartTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLStartTagComment __CreateInstance(HTMLStartTagComment.Internal native)
@@ -12663,11 +12663,11 @@ namespace CppSharp
                     internal static extern void setTagName_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLEndTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLEndTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLEndTagComment((HTMLEndTagComment.Internal*) native);
+                    return new HTMLEndTagComment((HTMLEndTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLEndTagComment __CreateInstance(HTMLEndTagComment.Internal native)
@@ -12783,11 +12783,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TextComment __CreateInstance(global::System.IntPtr native)
+                public static new TextComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TextComment((TextComment.Internal*) native);
+                    return new TextComment((TextComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TextComment __CreateInstance(TextComment.Internal native)
@@ -12919,11 +12919,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, RawComment> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, RawComment>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static RawComment __CreateInstance(global::System.IntPtr native)
+                public static RawComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new RawComment((RawComment.Internal*) native);
+                    return new RawComment((RawComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static RawComment __CreateInstance(RawComment.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppParser.cs b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppParser.cs
index a6ba7f09..8b7103c1 100644
--- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppParser.cs
+++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppParser.cs
@@ -233,11 +233,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserOptions> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserOptions>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserOptions __CreateInstance(global::System.IntPtr native)
+            public static ParserOptions __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserOptions((ParserOptions.Internal*) native);
+                return new ParserOptions((ParserOptions.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserOptions __CreateInstance(ParserOptions.Internal native)
@@ -663,11 +663,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserDiagnostic> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserDiagnostic>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserDiagnostic __CreateInstance(global::System.IntPtr native)
+            public static ParserDiagnostic __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserDiagnostic((ParserDiagnostic.Internal*) native);
+                return new ParserDiagnostic((ParserDiagnostic.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserDiagnostic __CreateInstance(ParserDiagnostic.Internal native)
@@ -864,11 +864,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserResult> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserResult>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserResult __CreateInstance(global::System.IntPtr native)
+            public static ParserResult __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserResult((ParserResult.Internal*) native);
+                return new ParserResult((ParserResult.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserResult __CreateInstance(ParserResult.Internal native)
@@ -1043,11 +1043,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClangParser> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClangParser>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ClangParser __CreateInstance(global::System.IntPtr native)
+            public static ClangParser __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ClangParser((ClangParser.Internal*) native);
+                return new ClangParser((ClangParser.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ClangParser __CreateInstance(ClangParser.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Target.cs b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Target.cs
index 51c4ad61..9eff4688 100644
--- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Target.cs
+++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Target.cs
@@ -173,11 +173,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserTargetInfo> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserTargetInfo>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserTargetInfo __CreateInstance(global::System.IntPtr native)
+            public static ParserTargetInfo __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserTargetInfo((ParserTargetInfo.Internal*) native);
+                return new ParserTargetInfo((ParserTargetInfo.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserTargetInfo __CreateInstance(ParserTargetInfo.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs
index 86d298da..efe6982c 100644
--- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs
+++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/AST.cs
@@ -267,11 +267,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Type> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Type>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Type __CreateInstance(global::System.IntPtr native)
+                public static Type __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Type((Type.Internal*) native);
+                    return new Type((Type.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Type __CreateInstance(Type.Internal native)
@@ -389,11 +389,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TypeQualifiers> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TypeQualifiers>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TypeQualifiers __CreateInstance(global::System.IntPtr native)
+                public static TypeQualifiers __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypeQualifiers((TypeQualifiers.Internal*) native);
+                    return new TypeQualifiers((TypeQualifiers.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypeQualifiers __CreateInstance(TypeQualifiers.Internal native)
@@ -523,11 +523,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, QualifiedType> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, QualifiedType>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static QualifiedType __CreateInstance(global::System.IntPtr native)
+                public static QualifiedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new QualifiedType((QualifiedType.Internal*) native);
+                    return new QualifiedType((QualifiedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static QualifiedType __CreateInstance(QualifiedType.Internal native)
@@ -650,11 +650,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TagType __CreateInstance(global::System.IntPtr native)
+                public static new TagType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TagType((TagType.Internal*) native);
+                    return new TagType((TagType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TagType __CreateInstance(TagType.Internal native)
@@ -777,11 +777,11 @@ namespace CppSharp
                     Incomplete = 3
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ArrayType __CreateInstance(global::System.IntPtr native)
+                public static new ArrayType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ArrayType((ArrayType.Internal*) native);
+                    return new ArrayType((ArrayType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ArrayType __CreateInstance(ArrayType.Internal native)
@@ -939,11 +939,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FunctionType __CreateInstance(global::System.IntPtr native)
+                public static new FunctionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionType((FunctionType.Internal*) native);
+                    return new FunctionType((FunctionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionType __CreateInstance(FunctionType.Internal native)
@@ -1102,11 +1102,11 @@ namespace CppSharp
                     RVReference = 3
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PointerType __CreateInstance(global::System.IntPtr native)
+                public static new PointerType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PointerType((PointerType.Internal*) native);
+                    return new PointerType((PointerType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PointerType __CreateInstance(PointerType.Internal native)
@@ -1223,11 +1223,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MemberPointerType __CreateInstance(global::System.IntPtr native)
+                public static new MemberPointerType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MemberPointerType((MemberPointerType.Internal*) native);
+                    return new MemberPointerType((MemberPointerType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MemberPointerType __CreateInstance(MemberPointerType.Internal native)
@@ -1331,11 +1331,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TypedefType __CreateInstance(global::System.IntPtr native)
+                public static new TypedefType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypedefType((TypedefType.Internal*) native);
+                    return new TypedefType((TypedefType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypedefType __CreateInstance(TypedefType.Internal native)
@@ -1447,11 +1447,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new AttributedType __CreateInstance(global::System.IntPtr native)
+                public static new AttributedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new AttributedType((AttributedType.Internal*) native);
+                    return new AttributedType((AttributedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static AttributedType __CreateInstance(AttributedType.Internal native)
@@ -1574,11 +1574,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DecayedType __CreateInstance(global::System.IntPtr native)
+                public static new DecayedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DecayedType((DecayedType.Internal*) native);
+                    return new DecayedType((DecayedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DecayedType __CreateInstance(DecayedType.Internal native)
@@ -1726,11 +1726,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateArgument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateArgument>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TemplateArgument __CreateInstance(global::System.IntPtr native)
+                public static TemplateArgument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateArgument((TemplateArgument.Internal*) native);
+                    return new TemplateArgument((TemplateArgument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateArgument __CreateInstance(TemplateArgument.Internal native)
@@ -1907,11 +1907,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateSpecializationType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateSpecializationType((TemplateSpecializationType.Internal*) native);
+                    return new TemplateSpecializationType((TemplateSpecializationType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateSpecializationType __CreateInstance(TemplateSpecializationType.Internal native)
@@ -2083,11 +2083,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateParameter> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateParameter>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TemplateParameter __CreateInstance(global::System.IntPtr native)
+                public static TemplateParameter __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameter((TemplateParameter.Internal*) native);
+                    return new TemplateParameter((TemplateParameter.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameter __CreateInstance(TemplateParameter.Internal native)
@@ -2247,11 +2247,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateParameterType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateParameterType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameterType((TemplateParameterType.Internal*) native);
+                    return new TemplateParameterType((TemplateParameterType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameterType __CreateInstance(TemplateParameterType.Internal native)
@@ -2394,11 +2394,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateParameterSubstitutionType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateParameterSubstitutionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameterSubstitutionType((TemplateParameterSubstitutionType.Internal*) native);
+                    return new TemplateParameterSubstitutionType((TemplateParameterSubstitutionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameterSubstitutionType __CreateInstance(TemplateParameterSubstitutionType.Internal native)
@@ -2505,11 +2505,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InjectedClassNameType __CreateInstance(global::System.IntPtr native)
+                public static new InjectedClassNameType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InjectedClassNameType((InjectedClassNameType.Internal*) native);
+                    return new InjectedClassNameType((InjectedClassNameType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InjectedClassNameType __CreateInstance(InjectedClassNameType.Internal native)
@@ -2633,11 +2633,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DependentNameType __CreateInstance(global::System.IntPtr native)
+                public static new DependentNameType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DependentNameType((DependentNameType.Internal*) native);
+                    return new DependentNameType((DependentNameType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DependentNameType __CreateInstance(DependentNameType.Internal native)
@@ -2725,11 +2725,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PackExpansionType __CreateInstance(global::System.IntPtr native)
+                public static new PackExpansionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PackExpansionType((PackExpansionType.Internal*) native);
+                    return new PackExpansionType((PackExpansionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PackExpansionType __CreateInstance(PackExpansionType.Internal native)
@@ -2820,11 +2820,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BuiltinType __CreateInstance(global::System.IntPtr native)
+                public static new BuiltinType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BuiltinType((BuiltinType.Internal*) native);
+                    return new BuiltinType((BuiltinType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BuiltinType __CreateInstance(BuiltinType.Internal native)
@@ -2931,11 +2931,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableComponent> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableComponent>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VTableComponent __CreateInstance(global::System.IntPtr native)
+                public static VTableComponent __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VTableComponent((VTableComponent.Internal*) native);
+                    return new VTableComponent((VTableComponent.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VTableComponent __CreateInstance(VTableComponent.Internal native)
@@ -3090,11 +3090,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableLayout> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableLayout>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VTableLayout __CreateInstance(global::System.IntPtr native)
+                public static VTableLayout __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VTableLayout((VTableLayout.Internal*) native);
+                    return new VTableLayout((VTableLayout.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VTableLayout __CreateInstance(VTableLayout.Internal native)
@@ -3226,11 +3226,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VFTableInfo> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VFTableInfo>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VFTableInfo __CreateInstance(global::System.IntPtr native)
+                public static VFTableInfo __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VFTableInfo((VFTableInfo.Internal*) native);
+                    return new VFTableInfo((VFTableInfo.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VFTableInfo __CreateInstance(VFTableInfo.Internal native)
@@ -3417,11 +3417,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClassLayout> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClassLayout>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static ClassLayout __CreateInstance(global::System.IntPtr native)
+                public static ClassLayout __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassLayout((ClassLayout.Internal*) native);
+                    return new ClassLayout((ClassLayout.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassLayout __CreateInstance(ClassLayout.Internal native)
@@ -3709,11 +3709,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Declaration> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Declaration>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Declaration __CreateInstance(global::System.IntPtr native)
+                public static Declaration __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Declaration((Declaration.Internal*) native);
+                    return new Declaration((Declaration.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Declaration __CreateInstance(Declaration.Internal native)
@@ -4238,11 +4238,11 @@ namespace CppSharp
                     internal static extern uint getFriendsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DeclarationContext __CreateInstance(global::System.IntPtr native)
+                public static new DeclarationContext __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DeclarationContext((DeclarationContext.Internal*) native);
+                    return new DeclarationContext((DeclarationContext.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DeclarationContext __CreateInstance(DeclarationContext.Internal native)
@@ -4630,11 +4630,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TypedefDecl __CreateInstance(global::System.IntPtr native)
+                public static new TypedefDecl __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypedefDecl((TypedefDecl.Internal*) native);
+                    return new TypedefDecl((TypedefDecl.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypedefDecl __CreateInstance(TypedefDecl.Internal native)
@@ -4773,11 +4773,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Friend __CreateInstance(global::System.IntPtr native)
+                public static new Friend __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Friend((Friend.Internal*) native);
+                    return new Friend((Friend.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Friend __CreateInstance(Friend.Internal native)
@@ -4896,11 +4896,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Statement> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Statement>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Statement __CreateInstance(global::System.IntPtr native)
+                public static Statement __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Statement((Statement.Internal*) native);
+                    return new Statement((Statement.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Statement __CreateInstance(Statement.Internal native)
@@ -5031,11 +5031,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Expression __CreateInstance(global::System.IntPtr native)
+                public static new Expression __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Expression((Expression.Internal*) native);
+                    return new Expression((Expression.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Expression __CreateInstance(Expression.Internal native)
@@ -5130,11 +5130,11 @@ namespace CppSharp
                     internal static extern void setOpcodeStr_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BinaryOperator __CreateInstance(global::System.IntPtr native)
+                public static new BinaryOperator __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BinaryOperator((BinaryOperator.Internal*) native);
+                    return new BinaryOperator((BinaryOperator.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BinaryOperator __CreateInstance(BinaryOperator.Internal native)
@@ -5285,11 +5285,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new CXXConstructExpr __CreateInstance(global::System.IntPtr native)
+                public static new CXXConstructExpr __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new CXXConstructExpr((CXXConstructExpr.Internal*) native);
+                    return new CXXConstructExpr((CXXConstructExpr.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static CXXConstructExpr __CreateInstance(CXXConstructExpr.Internal native)
@@ -5449,11 +5449,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Parameter __CreateInstance(global::System.IntPtr native)
+                public static new Parameter __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Parameter((Parameter.Internal*) native);
+                    return new Parameter((Parameter.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Parameter __CreateInstance(Parameter.Internal native)
@@ -5716,11 +5716,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Function __CreateInstance(global::System.IntPtr native)
+                public static new Function __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Function((Function.Internal*) native);
+                    return new Function((Function.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Function __CreateInstance(Function.Internal native)
@@ -6107,11 +6107,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Method __CreateInstance(global::System.IntPtr native)
+                public static new Method __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Method((Method.Internal*) native);
+                    return new Method((Method.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Method __CreateInstance(Method.Internal native)
@@ -6505,11 +6505,11 @@ namespace CppSharp
                         internal static extern void setExpression_0(global::System.IntPtr instance, global::System.IntPtr s);
                     }
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static new Item __CreateInstance(global::System.IntPtr native)
+                    public static new Item __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Item((Item.Internal*) native);
+                        return new Item((Item.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Item __CreateInstance(Item.Internal native)
@@ -6604,11 +6604,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Enumeration __CreateInstance(global::System.IntPtr native)
+                public static new Enumeration __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Enumeration((Enumeration.Internal*) native);
+                    return new Enumeration((Enumeration.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Enumeration __CreateInstance(Enumeration.Internal native)
@@ -6820,11 +6820,11 @@ namespace CppSharp
                     internal static extern void setMangled_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Variable __CreateInstance(global::System.IntPtr native)
+                public static new Variable __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Variable((Variable.Internal*) native);
+                    return new Variable((Variable.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Variable __CreateInstance(Variable.Internal native)
@@ -6950,11 +6950,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, BaseClassSpecifier> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, BaseClassSpecifier>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static BaseClassSpecifier __CreateInstance(global::System.IntPtr native)
+                public static BaseClassSpecifier __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BaseClassSpecifier((BaseClassSpecifier.Internal*) native);
+                    return new BaseClassSpecifier((BaseClassSpecifier.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BaseClassSpecifier __CreateInstance(BaseClassSpecifier.Internal native)
@@ -7150,11 +7150,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Field __CreateInstance(global::System.IntPtr native)
+                public static new Field __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Field((Field.Internal*) native);
+                    return new Field((Field.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Field __CreateInstance(Field.Internal native)
@@ -7347,11 +7347,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new AccessSpecifierDecl __CreateInstance(global::System.IntPtr native)
+                public static new AccessSpecifierDecl __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new AccessSpecifierDecl((AccessSpecifierDecl.Internal*) native);
+                    return new AccessSpecifierDecl((AccessSpecifierDecl.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static AccessSpecifierDecl __CreateInstance(AccessSpecifierDecl.Internal native)
@@ -7587,11 +7587,11 @@ namespace CppSharp
                     internal static extern uint getSpecifiersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Class __CreateInstance(global::System.IntPtr native)
+                public static new Class __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Class((Class.Internal*) native);
+                    return new Class((Class.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Class __CreateInstance(Class.Internal native)
@@ -8001,11 +8001,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Template __CreateInstance(global::System.IntPtr native)
+                public static new Template __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Template((Template.Internal*) native);
+                    return new Template((Template.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Template __CreateInstance(Template.Internal native)
@@ -8206,11 +8206,11 @@ namespace CppSharp
                     internal static extern uint getSpecializationsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplate __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplate __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplate((ClassTemplate.Internal*) native);
+                    return new ClassTemplate((ClassTemplate.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplate __CreateInstance(ClassTemplate.Internal native)
@@ -8423,11 +8423,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplateSpecialization __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplateSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplateSpecialization((ClassTemplateSpecialization.Internal*) native);
+                    return new ClassTemplateSpecialization((ClassTemplateSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplateSpecialization __CreateInstance(ClassTemplateSpecialization.Internal native)
@@ -8647,11 +8647,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplatePartialSpecialization __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplatePartialSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplatePartialSpecialization((ClassTemplatePartialSpecialization.Internal*) native);
+                    return new ClassTemplatePartialSpecialization((ClassTemplatePartialSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplatePartialSpecialization __CreateInstance(ClassTemplatePartialSpecialization.Internal native)
@@ -8797,11 +8797,11 @@ namespace CppSharp
                     internal static extern uint getSpecializationsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FunctionTemplate __CreateInstance(global::System.IntPtr native)
+                public static new FunctionTemplate __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionTemplate((FunctionTemplate.Internal*) native);
+                    return new FunctionTemplate((FunctionTemplate.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionTemplate __CreateInstance(FunctionTemplate.Internal native)
@@ -8951,11 +8951,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, FunctionTemplateSpecialization> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, FunctionTemplateSpecialization>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static FunctionTemplateSpecialization __CreateInstance(global::System.IntPtr native)
+                public static FunctionTemplateSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionTemplateSpecialization((FunctionTemplateSpecialization.Internal*) native);
+                    return new FunctionTemplateSpecialization((FunctionTemplateSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionTemplateSpecialization __CreateInstance(FunctionTemplateSpecialization.Internal native)
@@ -9164,11 +9164,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Namespace __CreateInstance(global::System.IntPtr native)
+                public static new Namespace __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Namespace((Namespace.Internal*) native);
+                    return new Namespace((Namespace.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Namespace __CreateInstance(Namespace.Internal native)
@@ -9307,11 +9307,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PreprocessedEntity __CreateInstance(global::System.IntPtr native)
+                public static new PreprocessedEntity __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PreprocessedEntity((PreprocessedEntity.Internal*) native);
+                    return new PreprocessedEntity((PreprocessedEntity.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PreprocessedEntity __CreateInstance(PreprocessedEntity.Internal native)
@@ -9460,11 +9460,11 @@ namespace CppSharp
                     internal static extern void setExpression_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MacroDefinition __CreateInstance(global::System.IntPtr native)
+                public static new MacroDefinition __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MacroDefinition((MacroDefinition.Internal*) native);
+                    return new MacroDefinition((MacroDefinition.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MacroDefinition __CreateInstance(MacroDefinition.Internal native)
@@ -9619,11 +9619,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MacroExpansion __CreateInstance(global::System.IntPtr native)
+                public static new MacroExpansion __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MacroExpansion((MacroExpansion.Internal*) native);
+                    return new MacroExpansion((MacroExpansion.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MacroExpansion __CreateInstance(MacroExpansion.Internal native)
@@ -9819,11 +9819,11 @@ namespace CppSharp
                     internal static extern uint getMacrosCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TranslationUnit __CreateInstance(global::System.IntPtr native)
+                public static new TranslationUnit __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TranslationUnit((TranslationUnit.Internal*) native);
+                    return new TranslationUnit((TranslationUnit.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TranslationUnit __CreateInstance(TranslationUnit.Internal native)
@@ -10026,11 +10026,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, NativeLibrary> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, NativeLibrary>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static NativeLibrary __CreateInstance(global::System.IntPtr native)
+                public static NativeLibrary __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new NativeLibrary((NativeLibrary.Internal*) native);
+                    return new NativeLibrary((NativeLibrary.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static NativeLibrary __CreateInstance(NativeLibrary.Internal native)
@@ -10227,11 +10227,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ASTContext> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ASTContext>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static ASTContext __CreateInstance(global::System.IntPtr native)
+                public static ASTContext __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ASTContext((ASTContext.Internal*) native);
+                    return new ASTContext((ASTContext.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ASTContext __CreateInstance(ASTContext.Internal native)
@@ -10354,11 +10354,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Comment> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Comment>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Comment __CreateInstance(global::System.IntPtr native)
+                public static Comment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Comment((Comment.Internal*) native);
+                    return new Comment((Comment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Comment __CreateInstance(Comment.Internal native)
@@ -10463,11 +10463,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BlockContentComment __CreateInstance(global::System.IntPtr native)
+                public static new BlockContentComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BlockContentComment((BlockContentComment.Internal*) native);
+                    return new BlockContentComment((BlockContentComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BlockContentComment __CreateInstance(BlockContentComment.Internal native)
@@ -10586,11 +10586,11 @@ namespace CppSharp
                     internal static extern uint getBlocksCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FullComment __CreateInstance(global::System.IntPtr native)
+                public static new FullComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FullComment((FullComment.Internal*) native);
+                    return new FullComment((FullComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FullComment __CreateInstance(FullComment.Internal native)
@@ -10773,11 +10773,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Argument __CreateInstance(global::System.IntPtr native)
+                    public static Argument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Argument((Argument.Internal*) native);
+                        return new Argument((Argument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Argument __CreateInstance(Argument.Internal native)
@@ -10863,11 +10863,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BlockCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new BlockCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BlockCommandComment((BlockCommandComment.Internal*) native);
+                    return new BlockCommandComment((BlockCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BlockCommandComment __CreateInstance(BlockCommandComment.Internal native)
@@ -11023,11 +11023,11 @@ namespace CppSharp
                     InOut = 2
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ParamCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new ParamCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ParamCommandComment((ParamCommandComment.Internal*) native);
+                    return new ParamCommandComment((ParamCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ParamCommandComment __CreateInstance(ParamCommandComment.Internal native)
@@ -11166,11 +11166,11 @@ namespace CppSharp
                     internal static extern uint getPositionCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TParamCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new TParamCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TParamCommandComment((TParamCommandComment.Internal*) native);
+                    return new TParamCommandComment((TParamCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TParamCommandComment __CreateInstance(TParamCommandComment.Internal native)
@@ -11298,11 +11298,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimBlockLineComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimBlockLineComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimBlockLineComment((VerbatimBlockLineComment.Internal*) native);
+                    return new VerbatimBlockLineComment((VerbatimBlockLineComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimBlockLineComment __CreateInstance(VerbatimBlockLineComment.Internal native)
@@ -11431,11 +11431,11 @@ namespace CppSharp
                     internal static extern uint getLinesCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimBlockComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimBlockComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimBlockComment((VerbatimBlockComment.Internal*) native);
+                    return new VerbatimBlockComment((VerbatimBlockComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimBlockComment __CreateInstance(VerbatimBlockComment.Internal native)
@@ -11569,11 +11569,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimLineComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimLineComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimLineComment((VerbatimLineComment.Internal*) native);
+                    return new VerbatimLineComment((VerbatimLineComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimLineComment __CreateInstance(VerbatimLineComment.Internal native)
@@ -11679,11 +11679,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InlineContentComment __CreateInstance(global::System.IntPtr native)
+                public static new InlineContentComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InlineContentComment((InlineContentComment.Internal*) native);
+                    return new InlineContentComment((InlineContentComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InlineContentComment __CreateInstance(InlineContentComment.Internal native)
@@ -11805,11 +11805,11 @@ namespace CppSharp
                     internal static extern uint getContentCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ParagraphComment __CreateInstance(global::System.IntPtr native)
+                public static new ParagraphComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ParagraphComment((ParagraphComment.Internal*) native);
+                    return new ParagraphComment((ParagraphComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ParagraphComment __CreateInstance(ParagraphComment.Internal native)
@@ -12008,11 +12008,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Argument __CreateInstance(global::System.IntPtr native)
+                    public static Argument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Argument((Argument.Internal*) native);
+                        return new Argument((Argument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Argument __CreateInstance(Argument.Internal native)
@@ -12098,11 +12098,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InlineCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new InlineCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InlineCommandComment((InlineCommandComment.Internal*) native);
+                    return new InlineCommandComment((InlineCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InlineCommandComment __CreateInstance(InlineCommandComment.Internal native)
@@ -12232,11 +12232,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLTagComment((HTMLTagComment.Internal*) native);
+                    return new HTMLTagComment((HTMLTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLTagComment __CreateInstance(HTMLTagComment.Internal native)
@@ -12409,11 +12409,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Attribute> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Attribute>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Attribute __CreateInstance(global::System.IntPtr native)
+                    public static Attribute __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Attribute((Attribute.Internal*) native);
+                        return new Attribute((Attribute.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Attribute __CreateInstance(Attribute.Internal native)
@@ -12515,11 +12515,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLStartTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLStartTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLStartTagComment((HTMLStartTagComment.Internal*) native);
+                    return new HTMLStartTagComment((HTMLStartTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLStartTagComment __CreateInstance(HTMLStartTagComment.Internal native)
@@ -12662,11 +12662,11 @@ namespace CppSharp
                     internal static extern void setTagName_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLEndTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLEndTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLEndTagComment((HTMLEndTagComment.Internal*) native);
+                    return new HTMLEndTagComment((HTMLEndTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLEndTagComment __CreateInstance(HTMLEndTagComment.Internal native)
@@ -12782,11 +12782,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TextComment __CreateInstance(global::System.IntPtr native)
+                public static new TextComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TextComment((TextComment.Internal*) native);
+                    return new TextComment((TextComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TextComment __CreateInstance(TextComment.Internal native)
@@ -12918,11 +12918,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, RawComment> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, RawComment>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static RawComment __CreateInstance(global::System.IntPtr native)
+                public static RawComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new RawComment((RawComment.Internal*) native);
+                    return new RawComment((RawComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static RawComment __CreateInstance(RawComment.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppParser.cs
index 03d5fa67..df7ded27 100644
--- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppParser.cs
+++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppParser.cs
@@ -233,11 +233,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserOptions> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserOptions>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserOptions __CreateInstance(global::System.IntPtr native)
+            public static ParserOptions __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserOptions((ParserOptions.Internal*) native);
+                return new ParserOptions((ParserOptions.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserOptions __CreateInstance(ParserOptions.Internal native)
@@ -663,11 +663,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserDiagnostic> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserDiagnostic>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserDiagnostic __CreateInstance(global::System.IntPtr native)
+            public static ParserDiagnostic __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserDiagnostic((ParserDiagnostic.Internal*) native);
+                return new ParserDiagnostic((ParserDiagnostic.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserDiagnostic __CreateInstance(ParserDiagnostic.Internal native)
@@ -864,11 +864,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserResult> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserResult>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserResult __CreateInstance(global::System.IntPtr native)
+            public static ParserResult __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserResult((ParserResult.Internal*) native);
+                return new ParserResult((ParserResult.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserResult __CreateInstance(ParserResult.Internal native)
@@ -1043,11 +1043,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClangParser> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClangParser>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ClangParser __CreateInstance(global::System.IntPtr native)
+            public static ClangParser __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ClangParser((ClangParser.Internal*) native);
+                return new ClangParser((ClangParser.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ClangParser __CreateInstance(ClangParser.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Target.cs b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Target.cs
index c597a021..cc98dd64 100644
--- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Target.cs
+++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Target.cs
@@ -173,11 +173,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserTargetInfo> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserTargetInfo>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserTargetInfo __CreateInstance(global::System.IntPtr native)
+            public static ParserTargetInfo __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserTargetInfo((ParserTargetInfo.Internal*) native);
+                return new ParserTargetInfo((ParserTargetInfo.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserTargetInfo __CreateInstance(ParserTargetInfo.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs
index 19e02422..4e4b858e 100644
--- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs
+++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/AST.cs
@@ -267,11 +267,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Type> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Type>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Type __CreateInstance(global::System.IntPtr native)
+                public static Type __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Type((Type.Internal*) native);
+                    return new Type((Type.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Type __CreateInstance(Type.Internal native)
@@ -389,11 +389,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TypeQualifiers> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TypeQualifiers>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TypeQualifiers __CreateInstance(global::System.IntPtr native)
+                public static TypeQualifiers __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypeQualifiers((TypeQualifiers.Internal*) native);
+                    return new TypeQualifiers((TypeQualifiers.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypeQualifiers __CreateInstance(TypeQualifiers.Internal native)
@@ -523,11 +523,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, QualifiedType> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, QualifiedType>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static QualifiedType __CreateInstance(global::System.IntPtr native)
+                public static QualifiedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new QualifiedType((QualifiedType.Internal*) native);
+                    return new QualifiedType((QualifiedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static QualifiedType __CreateInstance(QualifiedType.Internal native)
@@ -650,11 +650,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TagType __CreateInstance(global::System.IntPtr native)
+                public static new TagType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TagType((TagType.Internal*) native);
+                    return new TagType((TagType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TagType __CreateInstance(TagType.Internal native)
@@ -777,11 +777,11 @@ namespace CppSharp
                     Incomplete = 3
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ArrayType __CreateInstance(global::System.IntPtr native)
+                public static new ArrayType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ArrayType((ArrayType.Internal*) native);
+                    return new ArrayType((ArrayType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ArrayType __CreateInstance(ArrayType.Internal native)
@@ -939,11 +939,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FunctionType __CreateInstance(global::System.IntPtr native)
+                public static new FunctionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionType((FunctionType.Internal*) native);
+                    return new FunctionType((FunctionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionType __CreateInstance(FunctionType.Internal native)
@@ -1102,11 +1102,11 @@ namespace CppSharp
                     RVReference = 3
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PointerType __CreateInstance(global::System.IntPtr native)
+                public static new PointerType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PointerType((PointerType.Internal*) native);
+                    return new PointerType((PointerType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PointerType __CreateInstance(PointerType.Internal native)
@@ -1223,11 +1223,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MemberPointerType __CreateInstance(global::System.IntPtr native)
+                public static new MemberPointerType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MemberPointerType((MemberPointerType.Internal*) native);
+                    return new MemberPointerType((MemberPointerType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MemberPointerType __CreateInstance(MemberPointerType.Internal native)
@@ -1331,11 +1331,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TypedefType __CreateInstance(global::System.IntPtr native)
+                public static new TypedefType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypedefType((TypedefType.Internal*) native);
+                    return new TypedefType((TypedefType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypedefType __CreateInstance(TypedefType.Internal native)
@@ -1447,11 +1447,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new AttributedType __CreateInstance(global::System.IntPtr native)
+                public static new AttributedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new AttributedType((AttributedType.Internal*) native);
+                    return new AttributedType((AttributedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static AttributedType __CreateInstance(AttributedType.Internal native)
@@ -1574,11 +1574,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DecayedType __CreateInstance(global::System.IntPtr native)
+                public static new DecayedType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DecayedType((DecayedType.Internal*) native);
+                    return new DecayedType((DecayedType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DecayedType __CreateInstance(DecayedType.Internal native)
@@ -1726,11 +1726,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateArgument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateArgument>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TemplateArgument __CreateInstance(global::System.IntPtr native)
+                public static TemplateArgument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateArgument((TemplateArgument.Internal*) native);
+                    return new TemplateArgument((TemplateArgument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateArgument __CreateInstance(TemplateArgument.Internal native)
@@ -1907,11 +1907,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateSpecializationType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateSpecializationType((TemplateSpecializationType.Internal*) native);
+                    return new TemplateSpecializationType((TemplateSpecializationType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateSpecializationType __CreateInstance(TemplateSpecializationType.Internal native)
@@ -2083,11 +2083,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateParameter> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, TemplateParameter>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static TemplateParameter __CreateInstance(global::System.IntPtr native)
+                public static TemplateParameter __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameter((TemplateParameter.Internal*) native);
+                    return new TemplateParameter((TemplateParameter.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameter __CreateInstance(TemplateParameter.Internal native)
@@ -2247,11 +2247,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateParameterType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateParameterType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameterType((TemplateParameterType.Internal*) native);
+                    return new TemplateParameterType((TemplateParameterType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameterType __CreateInstance(TemplateParameterType.Internal native)
@@ -2394,11 +2394,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TemplateParameterSubstitutionType __CreateInstance(global::System.IntPtr native)
+                public static new TemplateParameterSubstitutionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TemplateParameterSubstitutionType((TemplateParameterSubstitutionType.Internal*) native);
+                    return new TemplateParameterSubstitutionType((TemplateParameterSubstitutionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TemplateParameterSubstitutionType __CreateInstance(TemplateParameterSubstitutionType.Internal native)
@@ -2505,11 +2505,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InjectedClassNameType __CreateInstance(global::System.IntPtr native)
+                public static new InjectedClassNameType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InjectedClassNameType((InjectedClassNameType.Internal*) native);
+                    return new InjectedClassNameType((InjectedClassNameType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InjectedClassNameType __CreateInstance(InjectedClassNameType.Internal native)
@@ -2633,11 +2633,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DependentNameType __CreateInstance(global::System.IntPtr native)
+                public static new DependentNameType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DependentNameType((DependentNameType.Internal*) native);
+                    return new DependentNameType((DependentNameType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DependentNameType __CreateInstance(DependentNameType.Internal native)
@@ -2725,11 +2725,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PackExpansionType __CreateInstance(global::System.IntPtr native)
+                public static new PackExpansionType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PackExpansionType((PackExpansionType.Internal*) native);
+                    return new PackExpansionType((PackExpansionType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PackExpansionType __CreateInstance(PackExpansionType.Internal native)
@@ -2820,11 +2820,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BuiltinType __CreateInstance(global::System.IntPtr native)
+                public static new BuiltinType __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BuiltinType((BuiltinType.Internal*) native);
+                    return new BuiltinType((BuiltinType.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BuiltinType __CreateInstance(BuiltinType.Internal native)
@@ -2931,11 +2931,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableComponent> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableComponent>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VTableComponent __CreateInstance(global::System.IntPtr native)
+                public static VTableComponent __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VTableComponent((VTableComponent.Internal*) native);
+                    return new VTableComponent((VTableComponent.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VTableComponent __CreateInstance(VTableComponent.Internal native)
@@ -3090,11 +3090,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableLayout> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VTableLayout>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VTableLayout __CreateInstance(global::System.IntPtr native)
+                public static VTableLayout __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VTableLayout((VTableLayout.Internal*) native);
+                    return new VTableLayout((VTableLayout.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VTableLayout __CreateInstance(VTableLayout.Internal native)
@@ -3226,11 +3226,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VFTableInfo> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, VFTableInfo>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static VFTableInfo __CreateInstance(global::System.IntPtr native)
+                public static VFTableInfo __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VFTableInfo((VFTableInfo.Internal*) native);
+                    return new VFTableInfo((VFTableInfo.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VFTableInfo __CreateInstance(VFTableInfo.Internal native)
@@ -3417,11 +3417,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClassLayout> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClassLayout>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static ClassLayout __CreateInstance(global::System.IntPtr native)
+                public static ClassLayout __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassLayout((ClassLayout.Internal*) native);
+                    return new ClassLayout((ClassLayout.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassLayout __CreateInstance(ClassLayout.Internal native)
@@ -3709,11 +3709,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Declaration> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Declaration>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Declaration __CreateInstance(global::System.IntPtr native)
+                public static Declaration __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Declaration((Declaration.Internal*) native);
+                    return new Declaration((Declaration.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Declaration __CreateInstance(Declaration.Internal native)
@@ -4238,11 +4238,11 @@ namespace CppSharp
                     internal static extern uint getFriendsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new DeclarationContext __CreateInstance(global::System.IntPtr native)
+                public static new DeclarationContext __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new DeclarationContext((DeclarationContext.Internal*) native);
+                    return new DeclarationContext((DeclarationContext.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static DeclarationContext __CreateInstance(DeclarationContext.Internal native)
@@ -4630,11 +4630,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TypedefDecl __CreateInstance(global::System.IntPtr native)
+                public static new TypedefDecl __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TypedefDecl((TypedefDecl.Internal*) native);
+                    return new TypedefDecl((TypedefDecl.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TypedefDecl __CreateInstance(TypedefDecl.Internal native)
@@ -4773,11 +4773,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Friend __CreateInstance(global::System.IntPtr native)
+                public static new Friend __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Friend((Friend.Internal*) native);
+                    return new Friend((Friend.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Friend __CreateInstance(Friend.Internal native)
@@ -4896,11 +4896,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Statement> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Statement>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Statement __CreateInstance(global::System.IntPtr native)
+                public static Statement __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Statement((Statement.Internal*) native);
+                    return new Statement((Statement.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Statement __CreateInstance(Statement.Internal native)
@@ -5031,11 +5031,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Expression __CreateInstance(global::System.IntPtr native)
+                public static new Expression __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Expression((Expression.Internal*) native);
+                    return new Expression((Expression.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Expression __CreateInstance(Expression.Internal native)
@@ -5130,11 +5130,11 @@ namespace CppSharp
                     internal static extern void setOpcodeStr_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BinaryOperator __CreateInstance(global::System.IntPtr native)
+                public static new BinaryOperator __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BinaryOperator((BinaryOperator.Internal*) native);
+                    return new BinaryOperator((BinaryOperator.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BinaryOperator __CreateInstance(BinaryOperator.Internal native)
@@ -5285,11 +5285,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new CXXConstructExpr __CreateInstance(global::System.IntPtr native)
+                public static new CXXConstructExpr __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new CXXConstructExpr((CXXConstructExpr.Internal*) native);
+                    return new CXXConstructExpr((CXXConstructExpr.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static CXXConstructExpr __CreateInstance(CXXConstructExpr.Internal native)
@@ -5449,11 +5449,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Parameter __CreateInstance(global::System.IntPtr native)
+                public static new Parameter __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Parameter((Parameter.Internal*) native);
+                    return new Parameter((Parameter.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Parameter __CreateInstance(Parameter.Internal native)
@@ -5716,11 +5716,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Function __CreateInstance(global::System.IntPtr native)
+                public static new Function __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Function((Function.Internal*) native);
+                    return new Function((Function.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Function __CreateInstance(Function.Internal native)
@@ -6107,11 +6107,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Method __CreateInstance(global::System.IntPtr native)
+                public static new Method __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Method((Method.Internal*) native);
+                    return new Method((Method.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Method __CreateInstance(Method.Internal native)
@@ -6505,11 +6505,11 @@ namespace CppSharp
                         internal static extern void setExpression_0(global::System.IntPtr instance, global::System.IntPtr s);
                     }
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static new Item __CreateInstance(global::System.IntPtr native)
+                    public static new Item __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Item((Item.Internal*) native);
+                        return new Item((Item.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Item __CreateInstance(Item.Internal native)
@@ -6604,11 +6604,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Enumeration __CreateInstance(global::System.IntPtr native)
+                public static new Enumeration __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Enumeration((Enumeration.Internal*) native);
+                    return new Enumeration((Enumeration.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Enumeration __CreateInstance(Enumeration.Internal native)
@@ -6820,11 +6820,11 @@ namespace CppSharp
                     internal static extern void setMangled_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Variable __CreateInstance(global::System.IntPtr native)
+                public static new Variable __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Variable((Variable.Internal*) native);
+                    return new Variable((Variable.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Variable __CreateInstance(Variable.Internal native)
@@ -6950,11 +6950,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, BaseClassSpecifier> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, BaseClassSpecifier>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static BaseClassSpecifier __CreateInstance(global::System.IntPtr native)
+                public static BaseClassSpecifier __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BaseClassSpecifier((BaseClassSpecifier.Internal*) native);
+                    return new BaseClassSpecifier((BaseClassSpecifier.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BaseClassSpecifier __CreateInstance(BaseClassSpecifier.Internal native)
@@ -7150,11 +7150,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Field __CreateInstance(global::System.IntPtr native)
+                public static new Field __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Field((Field.Internal*) native);
+                    return new Field((Field.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Field __CreateInstance(Field.Internal native)
@@ -7347,11 +7347,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new AccessSpecifierDecl __CreateInstance(global::System.IntPtr native)
+                public static new AccessSpecifierDecl __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new AccessSpecifierDecl((AccessSpecifierDecl.Internal*) native);
+                    return new AccessSpecifierDecl((AccessSpecifierDecl.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static AccessSpecifierDecl __CreateInstance(AccessSpecifierDecl.Internal native)
@@ -7587,11 +7587,11 @@ namespace CppSharp
                     internal static extern uint getSpecifiersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Class __CreateInstance(global::System.IntPtr native)
+                public static new Class __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Class((Class.Internal*) native);
+                    return new Class((Class.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Class __CreateInstance(Class.Internal native)
@@ -8001,11 +8001,11 @@ namespace CppSharp
                     internal static extern uint getParametersCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Template __CreateInstance(global::System.IntPtr native)
+                public static new Template __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Template((Template.Internal*) native);
+                    return new Template((Template.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Template __CreateInstance(Template.Internal native)
@@ -8206,11 +8206,11 @@ namespace CppSharp
                     internal static extern uint getSpecializationsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplate __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplate __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplate((ClassTemplate.Internal*) native);
+                    return new ClassTemplate((ClassTemplate.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplate __CreateInstance(ClassTemplate.Internal native)
@@ -8423,11 +8423,11 @@ namespace CppSharp
                     internal static extern uint getArgumentsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplateSpecialization __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplateSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplateSpecialization((ClassTemplateSpecialization.Internal*) native);
+                    return new ClassTemplateSpecialization((ClassTemplateSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplateSpecialization __CreateInstance(ClassTemplateSpecialization.Internal native)
@@ -8647,11 +8647,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ClassTemplatePartialSpecialization __CreateInstance(global::System.IntPtr native)
+                public static new ClassTemplatePartialSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ClassTemplatePartialSpecialization((ClassTemplatePartialSpecialization.Internal*) native);
+                    return new ClassTemplatePartialSpecialization((ClassTemplatePartialSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ClassTemplatePartialSpecialization __CreateInstance(ClassTemplatePartialSpecialization.Internal native)
@@ -8797,11 +8797,11 @@ namespace CppSharp
                     internal static extern uint getSpecializationsCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FunctionTemplate __CreateInstance(global::System.IntPtr native)
+                public static new FunctionTemplate __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionTemplate((FunctionTemplate.Internal*) native);
+                    return new FunctionTemplate((FunctionTemplate.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionTemplate __CreateInstance(FunctionTemplate.Internal native)
@@ -8951,11 +8951,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, FunctionTemplateSpecialization> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, FunctionTemplateSpecialization>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static FunctionTemplateSpecialization __CreateInstance(global::System.IntPtr native)
+                public static FunctionTemplateSpecialization __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FunctionTemplateSpecialization((FunctionTemplateSpecialization.Internal*) native);
+                    return new FunctionTemplateSpecialization((FunctionTemplateSpecialization.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FunctionTemplateSpecialization __CreateInstance(FunctionTemplateSpecialization.Internal native)
@@ -9164,11 +9164,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new Namespace __CreateInstance(global::System.IntPtr native)
+                public static new Namespace __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Namespace((Namespace.Internal*) native);
+                    return new Namespace((Namespace.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Namespace __CreateInstance(Namespace.Internal native)
@@ -9307,11 +9307,11 @@ namespace CppSharp
                     internal static extern void dtor_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new PreprocessedEntity __CreateInstance(global::System.IntPtr native)
+                public static new PreprocessedEntity __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new PreprocessedEntity((PreprocessedEntity.Internal*) native);
+                    return new PreprocessedEntity((PreprocessedEntity.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static PreprocessedEntity __CreateInstance(PreprocessedEntity.Internal native)
@@ -9460,11 +9460,11 @@ namespace CppSharp
                     internal static extern void setExpression_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MacroDefinition __CreateInstance(global::System.IntPtr native)
+                public static new MacroDefinition __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MacroDefinition((MacroDefinition.Internal*) native);
+                    return new MacroDefinition((MacroDefinition.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MacroDefinition __CreateInstance(MacroDefinition.Internal native)
@@ -9619,11 +9619,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new MacroExpansion __CreateInstance(global::System.IntPtr native)
+                public static new MacroExpansion __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new MacroExpansion((MacroExpansion.Internal*) native);
+                    return new MacroExpansion((MacroExpansion.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static MacroExpansion __CreateInstance(MacroExpansion.Internal native)
@@ -9819,11 +9819,11 @@ namespace CppSharp
                     internal static extern uint getMacrosCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TranslationUnit __CreateInstance(global::System.IntPtr native)
+                public static new TranslationUnit __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TranslationUnit((TranslationUnit.Internal*) native);
+                    return new TranslationUnit((TranslationUnit.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TranslationUnit __CreateInstance(TranslationUnit.Internal native)
@@ -10026,11 +10026,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, NativeLibrary> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, NativeLibrary>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static NativeLibrary __CreateInstance(global::System.IntPtr native)
+                public static NativeLibrary __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new NativeLibrary((NativeLibrary.Internal*) native);
+                    return new NativeLibrary((NativeLibrary.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static NativeLibrary __CreateInstance(NativeLibrary.Internal native)
@@ -10227,11 +10227,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ASTContext> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ASTContext>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static ASTContext __CreateInstance(global::System.IntPtr native)
+                public static ASTContext __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ASTContext((ASTContext.Internal*) native);
+                    return new ASTContext((ASTContext.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ASTContext __CreateInstance(ASTContext.Internal native)
@@ -10354,11 +10354,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Comment> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Comment>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static Comment __CreateInstance(global::System.IntPtr native)
+                public static Comment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new Comment((Comment.Internal*) native);
+                    return new Comment((Comment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static Comment __CreateInstance(Comment.Internal native)
@@ -10463,11 +10463,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BlockContentComment __CreateInstance(global::System.IntPtr native)
+                public static new BlockContentComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BlockContentComment((BlockContentComment.Internal*) native);
+                    return new BlockContentComment((BlockContentComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BlockContentComment __CreateInstance(BlockContentComment.Internal native)
@@ -10586,11 +10586,11 @@ namespace CppSharp
                     internal static extern uint getBlocksCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new FullComment __CreateInstance(global::System.IntPtr native)
+                public static new FullComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new FullComment((FullComment.Internal*) native);
+                    return new FullComment((FullComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static FullComment __CreateInstance(FullComment.Internal native)
@@ -10773,11 +10773,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Argument __CreateInstance(global::System.IntPtr native)
+                    public static Argument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Argument((Argument.Internal*) native);
+                        return new Argument((Argument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Argument __CreateInstance(Argument.Internal native)
@@ -10863,11 +10863,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new BlockCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new BlockCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new BlockCommandComment((BlockCommandComment.Internal*) native);
+                    return new BlockCommandComment((BlockCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static BlockCommandComment __CreateInstance(BlockCommandComment.Internal native)
@@ -11023,11 +11023,11 @@ namespace CppSharp
                     InOut = 2
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ParamCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new ParamCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ParamCommandComment((ParamCommandComment.Internal*) native);
+                    return new ParamCommandComment((ParamCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ParamCommandComment __CreateInstance(ParamCommandComment.Internal native)
@@ -11166,11 +11166,11 @@ namespace CppSharp
                     internal static extern uint getPositionCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TParamCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new TParamCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TParamCommandComment((TParamCommandComment.Internal*) native);
+                    return new TParamCommandComment((TParamCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TParamCommandComment __CreateInstance(TParamCommandComment.Internal native)
@@ -11298,11 +11298,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimBlockLineComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimBlockLineComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimBlockLineComment((VerbatimBlockLineComment.Internal*) native);
+                    return new VerbatimBlockLineComment((VerbatimBlockLineComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimBlockLineComment __CreateInstance(VerbatimBlockLineComment.Internal native)
@@ -11431,11 +11431,11 @@ namespace CppSharp
                     internal static extern uint getLinesCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimBlockComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimBlockComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimBlockComment((VerbatimBlockComment.Internal*) native);
+                    return new VerbatimBlockComment((VerbatimBlockComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimBlockComment __CreateInstance(VerbatimBlockComment.Internal native)
@@ -11569,11 +11569,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new VerbatimLineComment __CreateInstance(global::System.IntPtr native)
+                public static new VerbatimLineComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new VerbatimLineComment((VerbatimLineComment.Internal*) native);
+                    return new VerbatimLineComment((VerbatimLineComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static VerbatimLineComment __CreateInstance(VerbatimLineComment.Internal native)
@@ -11679,11 +11679,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InlineContentComment __CreateInstance(global::System.IntPtr native)
+                public static new InlineContentComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InlineContentComment((InlineContentComment.Internal*) native);
+                    return new InlineContentComment((InlineContentComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InlineContentComment __CreateInstance(InlineContentComment.Internal native)
@@ -11805,11 +11805,11 @@ namespace CppSharp
                     internal static extern uint getContentCount_0(global::System.IntPtr instance);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new ParagraphComment __CreateInstance(global::System.IntPtr native)
+                public static new ParagraphComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new ParagraphComment((ParagraphComment.Internal*) native);
+                    return new ParagraphComment((ParagraphComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static ParagraphComment __CreateInstance(ParagraphComment.Internal native)
@@ -12008,11 +12008,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Argument>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Argument __CreateInstance(global::System.IntPtr native)
+                    public static Argument __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Argument((Argument.Internal*) native);
+                        return new Argument((Argument.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Argument __CreateInstance(Argument.Internal native)
@@ -12098,11 +12098,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new InlineCommandComment __CreateInstance(global::System.IntPtr native)
+                public static new InlineCommandComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new InlineCommandComment((InlineCommandComment.Internal*) native);
+                    return new InlineCommandComment((InlineCommandComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static InlineCommandComment __CreateInstance(InlineCommandComment.Internal native)
@@ -12232,11 +12232,11 @@ namespace CppSharp
                     internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLTagComment((HTMLTagComment.Internal*) native);
+                    return new HTMLTagComment((HTMLTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLTagComment __CreateInstance(HTMLTagComment.Internal native)
@@ -12409,11 +12409,11 @@ namespace CppSharp
                     public global::System.IntPtr __Instance { get; protected set; }
                     public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Attribute> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Attribute>();
 
-                    private readonly bool __ownsNativeInstance;
+                    private bool __ownsNativeInstance;
 
-                    public static Attribute __CreateInstance(global::System.IntPtr native)
+                    public static Attribute __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                     {
-                        return new Attribute((Attribute.Internal*) native);
+                        return new Attribute((Attribute.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                     }
 
                     public static Attribute __CreateInstance(Attribute.Internal native)
@@ -12515,11 +12515,11 @@ namespace CppSharp
                     }
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLStartTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLStartTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLStartTagComment((HTMLStartTagComment.Internal*) native);
+                    return new HTMLStartTagComment((HTMLStartTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLStartTagComment __CreateInstance(HTMLStartTagComment.Internal native)
@@ -12662,11 +12662,11 @@ namespace CppSharp
                     internal static extern void setTagName_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new HTMLEndTagComment __CreateInstance(global::System.IntPtr native)
+                public static new HTMLEndTagComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new HTMLEndTagComment((HTMLEndTagComment.Internal*) native);
+                    return new HTMLEndTagComment((HTMLEndTagComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static HTMLEndTagComment __CreateInstance(HTMLEndTagComment.Internal native)
@@ -12782,11 +12782,11 @@ namespace CppSharp
                     internal static extern void setText_0(global::System.IntPtr instance, global::System.IntPtr s);
                 }
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static new TextComment __CreateInstance(global::System.IntPtr native)
+                public static new TextComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new TextComment((TextComment.Internal*) native);
+                    return new TextComment((TextComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static TextComment __CreateInstance(TextComment.Internal native)
@@ -12918,11 +12918,11 @@ namespace CppSharp
                 public global::System.IntPtr __Instance { get; protected set; }
                 public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, RawComment> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, RawComment>();
 
-                private readonly bool __ownsNativeInstance;
+                private bool __ownsNativeInstance;
 
-                public static RawComment __CreateInstance(global::System.IntPtr native)
+                public static RawComment __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
                 {
-                    return new RawComment((RawComment.Internal*) native);
+                    return new RawComment((RawComment.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
                 }
 
                 public static RawComment __CreateInstance(RawComment.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppParser.cs
index 8ea2882d..d7df8830 100644
--- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppParser.cs
+++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppParser.cs
@@ -233,11 +233,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserOptions> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserOptions>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserOptions __CreateInstance(global::System.IntPtr native)
+            public static ParserOptions __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserOptions((ParserOptions.Internal*) native);
+                return new ParserOptions((ParserOptions.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserOptions __CreateInstance(ParserOptions.Internal native)
@@ -663,11 +663,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserDiagnostic> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserDiagnostic>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserDiagnostic __CreateInstance(global::System.IntPtr native)
+            public static ParserDiagnostic __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserDiagnostic((ParserDiagnostic.Internal*) native);
+                return new ParserDiagnostic((ParserDiagnostic.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserDiagnostic __CreateInstance(ParserDiagnostic.Internal native)
@@ -864,11 +864,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserResult> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserResult>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserResult __CreateInstance(global::System.IntPtr native)
+            public static ParserResult __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserResult((ParserResult.Internal*) native);
+                return new ParserResult((ParserResult.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserResult __CreateInstance(ParserResult.Internal native)
@@ -1043,11 +1043,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClangParser> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ClangParser>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ClangParser __CreateInstance(global::System.IntPtr native)
+            public static ClangParser __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ClangParser((ClangParser.Internal*) native);
+                return new ClangParser((ClangParser.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ClangParser __CreateInstance(ClangParser.Internal native)
diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Target.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Target.cs
index cd5fe50c..87143582 100644
--- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Target.cs
+++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Target.cs
@@ -173,11 +173,11 @@ namespace CppSharp
             public global::System.IntPtr __Instance { get; protected set; }
             public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserTargetInfo> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, ParserTargetInfo>();
 
-            private readonly bool __ownsNativeInstance;
+            private bool __ownsNativeInstance;
 
-            public static ParserTargetInfo __CreateInstance(global::System.IntPtr native)
+            public static ParserTargetInfo __CreateInstance(global::System.IntPtr native, bool ownsNativeInstance = false)
             {
-                return new ParserTargetInfo((ParserTargetInfo.Internal*) native);
+                return new ParserTargetInfo((ParserTargetInfo.Internal*) native) { __ownsNativeInstance = ownsNativeInstance };
             }
 
             public static ParserTargetInfo __CreateInstance(ParserTargetInfo.Internal native)
diff --git a/src/Generator/Generators/CLI/CLIHeadersTemplate.cs b/src/Generator/Generators/CLI/CLIHeadersTemplate.cs
index 621e1f85..c2d73b65 100644
--- a/src/Generator/Generators/CLI/CLIHeadersTemplate.cs
+++ b/src/Generator/Generators/CLI/CLIHeadersTemplate.cs
@@ -270,14 +270,23 @@ namespace CppSharp.Generators.CLI
 
             GenerateClassVariables(@class);
 
+            if (CLIGenerator.ShouldGenerateClassNativeField(@class))
+            {
+                PushBlock(CLIBlockKind.AccessSpecifier);
+                WriteLine("protected:");
+                PopBlock(NewLineKind.IfNotEmpty);
+
+                PushBlock(CLIBlockKind.Fields);
+                WriteLineIndent("bool {0};", Helpers.OwnsNativeInstanceIdentifier);
+                PopBlock();
+            }
+
             PushBlock(CLIBlockKind.AccessSpecifier);
             WriteLine("private:");
             var accBlock = PopBlock(NewLineKind.IfNotEmpty);
 
             PushBlock(CLIBlockKind.Fields);
             GenerateClassFields(@class);
-            if (CLIGenerator.ShouldGenerateClassNativeField(@class))
-                WriteLineIndent("bool {0};", Helpers.OwnsNativeInstanceIdentifier);
             var fieldsBlock = PopBlock();
 
             accBlock.CheckGenerate = () => !fieldsBlock.IsEmpty;
@@ -370,7 +379,11 @@ namespace CppSharp.Generators.CLI
 
             // Output a default constructor that takes the native pointer.
             WriteLine("{0}({1} native);", @class.Name, nativeType);
-            WriteLine("static {0}^ {1}(::System::IntPtr native);", @class.Name, Helpers.CreateInstanceIdentifier);
+            WriteLine("static {0}^ {1}(::System::IntPtr native);",
+                @class.Name, Helpers.CreateInstanceIdentifier);
+            if (@class.IsRefType)
+                WriteLine("static {0}^ {1}(::System::IntPtr native, bool {2});",
+                    @class.Name, Helpers.CreateInstanceIdentifier, Helpers.OwnsNativeInstanceIdentifier);
 
             foreach (var ctor in @class.Constructors)
             {
diff --git a/src/Generator/Generators/CLI/CLISourcesTemplate.cs b/src/Generator/Generators/CLI/CLISourcesTemplate.cs
index c1a36f1b..3c95529e 100644
--- a/src/Generator/Generators/CLI/CLISourcesTemplate.cs
+++ b/src/Generator/Generators/CLI/CLISourcesTemplate.cs
@@ -638,7 +638,14 @@ namespace CppSharp.Generators.CLI
 
             var hasBase = GenerateClassConstructorBase(@class);
 
-            InitialiseOwnsNativeInstance(@class, hasBase, false);
+            if (CLIGenerator.ShouldGenerateClassNativeField(@class))
+            {
+                PushIndent();
+                Write(hasBase ? "," : ":");
+                PopIndent();
+
+                WriteLine(" {0}(false)", Helpers.OwnsNativeInstanceIdentifier);
+            }
 
             WriteStartBraceIndent();
 
@@ -658,25 +665,33 @@ namespace CppSharp.Generators.CLI
 
             WriteCloseBraceIndent();
             NewLine();
-
             WriteLine("{0}^ {0}::{1}(::System::IntPtr native)", qualifiedIdentifier, Helpers.CreateInstanceIdentifier);
 
             WriteStartBraceIndent();
-            WriteLine("return gcnew ::{0}(({1}) native.ToPointer());", qualifiedIdentifier, nativeType);
-            WriteCloseBraceIndent();
-            NewLine();
-        }
 
-        private void InitialiseOwnsNativeInstance(Class @class, bool hasBase, bool ownsNativeInstance)
-        {
-            if (!CLIGenerator.ShouldGenerateClassNativeField(@class)) return;
+            if (@class.IsRefType)
+            {
+                WriteLine("return ::{0}::{1}(native, false);",
+                    qualifiedIdentifier, Helpers.CreateInstanceIdentifier);
+                WriteCloseBraceIndent();
+                NewLine();
 
-            PushIndent();
-            Write(hasBase ? "," : ":");
-            PopIndent();
+                WriteLine("{0}^ {0}::{1}(::System::IntPtr native, bool {2})",
+                    qualifiedIdentifier, Helpers.CreateInstanceIdentifier, Helpers.OwnsNativeInstanceIdentifier);
 
-            WriteLine(" {0}({1})", Helpers.OwnsNativeInstanceIdentifier,
-                ownsNativeInstance ? "true" : "false");
+                WriteStartBraceIndent();
+                WriteLine("::{0}^ result = gcnew ::{0}(({1}) native.ToPointer());", qualifiedIdentifier, nativeType);
+                if (@class.IsRefType)
+                    WriteLine("result->{0} = {0};", Helpers.OwnsNativeInstanceIdentifier);
+                WriteLine("return result;");
+            }
+            else
+            {
+                WriteLine("return gcnew ::{0}(({1}) native.ToPointer());", qualifiedIdentifier, nativeType);
+            }
+
+            WriteCloseBraceIndent();
+            NewLine();
         }
 
         private void GenerateStructMarshaling(Class @class, string nativeVar)
@@ -758,15 +773,15 @@ namespace CppSharp.Generators.CLI
             WriteLine(")");
 
             if (method.IsConstructor)
-            {
-                var hasBase = GenerateClassConstructorBase(@class, method: method);
-                InitialiseOwnsNativeInstance(@class, hasBase, true);
-            }
+                GenerateClassConstructorBase(@class, method: method);
 
             WriteStartBraceIndent();
 
             PushBlock(CLIBlockKind.MethodBody, method);
 
+            if (method.IsConstructor && @class.IsRefType)
+                WriteLine("{0} = true;", Helpers.OwnsNativeInstanceIdentifier);
+
             if (method.IsProxy)
                 goto SkipImpl;
 
diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs
index 994b7d27..14473c28 100644
--- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs
+++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs
@@ -1864,7 +1864,7 @@ namespace CppSharp.Generators.CSharp
             if (@class.IsRefType)
             {
                 PushBlock(CSharpBlockKind.Field);
-                WriteLine("private readonly bool {0};", Helpers.OwnsNativeInstanceIdentifier);
+                WriteLine("private bool {0};", Helpers.OwnsNativeInstanceIdentifier);
                 PopBlock(NewLineKind.BeforeNextBlock);
             }
 
@@ -1874,11 +1874,15 @@ namespace CppSharp.Generators.CSharp
             if (!@class.IsAbstractImpl)
             {
                 PushBlock(CSharpBlockKind.Method);
-                WriteLine("public static {0}{1} {2}(global::System.IntPtr native)",
+                WriteLine("public static {0}{1} {2}(global::System.IntPtr native{3})",
                     @class.HasNonIgnoredBase && !@class.BaseClass.IsAbstract ? "new " : string.Empty,
-                    @class.Name, Helpers.CreateInstanceIdentifier);
+                    @class.Name, Helpers.CreateInstanceIdentifier,
+                    @class.IsRefType ? ", bool ownsNativeInstance = false" : string.Empty);
                 WriteStartBraceIndent();
-                WriteLine("return new {0}(({1}.Internal*) native);", ctorCall, className);
+                WriteLine("return new {0}(({1}.Internal*) native){2};", ctorCall, className,
+                    @class.IsRefType
+                        ? string.Format(" {{ {0} = ownsNativeInstance }}", Helpers.OwnsNativeInstanceIdentifier)
+                        : string.Empty);
                 WriteCloseBraceIndent();
                 PopBlock(NewLineKind.BeforeNextBlock);
             }