diff --git a/src/Generator/Passes/FieldToPropertyPass.cs b/src/Generator/Passes/FieldToPropertyPass.cs new file mode 100644 index 00000000..f2151256 --- /dev/null +++ b/src/Generator/Passes/FieldToPropertyPass.cs @@ -0,0 +1,33 @@ +using CppSharp.AST; + +namespace CppSharp.Passes +{ + public class FieldToPropertyPass : TranslationUnitPass + { + public override bool VisitFieldDecl(Field field) + { + var @class = field.Namespace as Class; + if (@class == null) + return false; + + if (@class.IsValueType) + return false; + + if (ASTUtils.CheckIgnoreField(@class,field)) + return false; + + var prop = new Property() + { + Name = field.Name, + Namespace = field.Namespace, + QualifiedType = field.QualifiedType, + Field = field + }; + @class.Properties.Add(prop); + + field.ExplicityIgnored = true; + + return false; + } + } +}