Results 1 to 4 of 4

Thread: C# classes

  1. #1
    semerich is offline Registered User
    Join Date
    Jan 2006
    Posts
    2

    Lightbulb C# classes

    Does anyone have an interest in having the ICE class's data members be generated in C# as properties instead of public fields? The advantage is is that you can drop a class object with properties into a property grid & easily view the data. This make debugging [realtime programs] easier. It would be a "nice to have" to have ZeroC implement this as an option [for C# & VB]

  2. #2
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    I guess we could make this available as a metadata directive. I considered mapping to properties at one point, but couldn't see any advantage for a type whose code is generated.

    Cheers,

    Michi.

  3. #3
    semerich is offline Registered User
    Join Date
    Jan 2006
    Posts
    2

    Post C# properties instead of public fields

    Having C# public properties instead of public fields is something that we can really benefit from, so I took a stab at it. below is the replacement VisitDataMember in "slice2cs\Gen.cpp file. It seems to work just fine, & the default functionality remains the same. Could this be added to your code baseline ? vb.net would be easy to do also.

    THANKS
    Scott Emerich
    jscott.emerich@boeing.com


    Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
    {
    int baseTypes = 0;
    bool isClass = false;
    ContainedPtr cont = ContainedPtr::dynamicCast(p->container());
    assert(cont);
    if(StructPtr::dynamicCast(cont) && cont->hasMetaData("clr:class"))
    {
    baseTypes = DotNet::ICloneable;
    }
    else if(ExceptionPtr::dynamicCast(cont))
    {
    baseTypes = DotNet::ApplicationException;
    }
    else if(ClassDefPtr::dynamicCast(cont))
    {
    baseTypes = DotNet::ICloneable;
    isClass = true;
    }
    _out << sp << nl;

    string nameS = fixId(p->name(), baseTypes, isClass);
    string ty = typeToString(p->type());
    if (p->hasMetaData("clr:property") || cont->hasMetaData("clr:property"))
    {
    _out << "private " << ty << " _" << nameS << ";" << nl;
    emitAttributes(p);
    _out << "public " << ty << " " << nameS << nl;
    _out << "{ get { return _" << nameS << "; }" << nl;
    _out << " set { _" << nameS << " = value; } }" << nl;
    }
    else
    {
    emitAttributes(p);
    _out << "public " << ty << " " << nameS << ";";
    }
    }

  4. #4
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Thanks for that! I'll add something like this for the next release.

    Cheers,

    Michi.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to do classes in Python
    By bobc in forum Help Center
    Replies: 4
    Last Post: 04-06-2009, 06:22 PM
  2. Using classes with ICE
    By JvD in forum Help Center
    Replies: 1
    Last Post: 02-20-2009, 08:57 AM
  3. operator== of C++ classes
    By smu in forum Help Center
    Replies: 3
    Last Post: 06-21-2007, 06:08 PM
  4. About Classes transmit
    By level in forum Help Center
    Replies: 4
    Last Post: 09-22-2004, 08:21 PM
  5. Why operations on classes?
    By bernard in forum Comments
    Replies: 1
    Last Post: 02-21-2003, 10:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •