Results 1 to 2 of 2

Thread: slice2cs issue with member initialization

  1. #1
    romank is offline Registered User
    Name: Roman Kiseliov
    Organization: Personal
    Project: DB facade
    Join Date
    Sep 2010
    Posts
    1

    Exclamation slice2cs issue with member initialization

    Given

    Code:
    module M
    {
        ["clr:property"]
        class A
        {
            int f = 1;
        };
    };
    slice2cs generates

    Code:
    class A
    {
       private int f_prop;
    
       public virtual int f 
       {
            get 
            { 
                 return f_prop; 
            }; 
    
            set 
            { 
                 f_prop = value; 
            }; 
       }
    
       A()
       {
            this.f = 1;
       }
    }
    Using virtual property in constructor is a bad practice. slice2cs must generate initialization code by using only data members:
    Code:
    class A
    {
       private int f_prop;
    
       public virtual int f 
       {
            get 
            { 
                 return f_prop; 
            }; 
    
            set 
            { 
                 f_prop = value; 
            }; 
       }
    
       A()
       {
            this.f_prop = 1;
       }
    }
    Last edited by romank; 09-28-2010 at 10:11 AM.

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Roman,

    Welcome to the forum, and thanks for the report!

    Regards,
    Mark

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 06-09-2010, 07:06 AM
  2. slice2cs commandline parsing issue
    By kwaclaw in forum Bug Reports
    Replies: 4
    Last Post: 10-23-2007, 12:42 AM
  3. Replies: 7
    Last Post: 07-16-2007, 02:17 AM
  4. Initialization of IceSSL
    By rhochmuth in forum Help Center
    Replies: 1
    Last Post: 05-13-2004, 07:05 PM
  5. class with operations, Initialization
    By StuartA in forum Help Center
    Replies: 6
    Last Post: 02-22-2004, 06:58 PM

Posting Permissions

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