void CSClassWriter::WriteManagedProperties(String& sourceOut)
{
    String source;

    if (klass_->HasProperties())
    {
        Vector<String> pnames;
        klass_->GetPropertyNames(pnames);

        for (unsigned j = 0; j < pnames.Size(); j++)
        {
            JSBProperty* prop = klass_->GetProperty(pnames[j]);

            JSBFunctionType* fType = NULL;
            JSBFunctionType* getType = NULL;
            JSBFunctionType* setType = NULL;

            if (CSTypeHelper::OmitFunction(prop->getter_) || CSTypeHelper::OmitFunction(prop->setter_))
                continue;

            if (prop->getter_ && !prop->getter_->Skip())
            {
                fType = getType = prop->getter_->GetReturnType();
            }
            if (prop->setter_ && !prop->setter_->Skip())
            {
                setType = prop->setter_->GetParameters()[0];

                if (!fType)
                    fType = setType;
                else if (fType->type_->ToString() != setType->type_->ToString())
                    continue;
            }

            if (!fType)
                continue;

            String line = klass_->IsInterface() ? "" : "public ";

            JSBClass* baseClass = klass_->GetBaseClass();
            if (baseClass)
            {
                if (baseClass->MatchProperty(prop, true))
                {
                    // always new so we don't have to deal with virtual/override on properties
                    line += "new ";
                }
            }

            String type = CSTypeHelper::GetManagedTypeString(fType, false);
            line += ToString("%s %s\n", type.CString(), prop->name_.CString());
            source += IndentLine(line);
            source += IndentLine("{\n");

            Indent();

            if (prop->getter_)
            {
                if (klass_->IsInterface())
                {
                    source += IndentLine("get;\n");
                }
                else
                {
                    source += IndentLine("get\n");
                    source += IndentLine("{\n");

                    Indent();

                    source += IndentLine(ToString("return %s();\n", prop->getter_->GetName().CString()));

                    Dedent();

                    source += IndentLine("}\n");
                }
            }

            if (prop->setter_)
            {
                if (klass_->IsInterface())
                {
                    source += IndentLine("set;\n");
                }
                else
                {
                    source += IndentLine("set\n");
                    source += IndentLine("{\n");

                    Indent();

                    source += IndentLine(ToString("%s(value);\n", prop->setter_->GetName().CString()));

                    Dedent();

                    source += IndentLine("}\n");

                }

            }

            Dedent();

            source += IndentLine("}\n\n");
        }

    }

    sourceOut += source;

}