Go Back   ZeroC Forums > Comments

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 01-20-2006
semerich 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]
Reply With Quote
  #2 (permalink)  
Old 01-20-2006
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 909
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.
Reply With Quote
  #3 (permalink)  
Old 02-08-2006
semerich 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 << ";";
}
}
Reply With Quote
  #4 (permalink)  
Old 02-08-2006
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 909
Thanks for that! I'll add something like this for the next release.

Cheers,

Michi.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deprecating Classes in ICE kamran Help Center 1 09-07-2006 06:57 PM
no Slice classes in Ice-E? n2503v Help Center 1 10-06-2005 02:30 AM
About Classes transmit level Help Center 4 09-22-2004 09:21 PM
Classes vs. Exceptions andreynech Comments 7 02-28-2003 11:12 AM
Why operations on classes? bernard Comments 1 02-21-2003 11:36 AM


All times are GMT -4. The time now is 08:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.