Results 1 to 3 of 3

Thread: Using clr:property with cs:attribute

  1. #1
    JVerwey is offline Registered User
    Name: Johan Verwey
    Organization: Immersion
    Project: WPF editor for C++ Simulation
    Join Date
    Jan 2009
    Posts
    7

    Using clr:property with cs:attribute

    Hi,

    I would like to be able to apply attributes to properties in my generated class.

    // Foo.ice
    ["clrroperty"]
    class Foo
    {
    ["cs:attribute:MyLibrary.MyOtherNameSpace.MyAtt rib"]
    int X;
    }

    This results in the following C# code:

    //Foo.cs

    class Foo
    {
    [MyLibrary.MyOtherNameSpace.MyAttrib]
    private int X_prop;
    public X
    {
    ...getter + setter ...
    }
    }

    The first problem is that the attribute is being applied on the private member instead of the property. Is there any way around this?

    Is their any way to include the namespace so I do not have to fully qualify each attribute?

    Thanks
    Johan

  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,445
    Welcome to the forum!

    Quote Originally Posted by JVerwey View Post
    The first problem is that the attribute is being applied on the private member instead of the property.
    Thanks for reporting this.

    Is there any way around this?
    We'll certainly fix this problem for the next release, but we don't have a target date yet. Until then, you could patch the translator source and rebuild it (I think the fix is fairly simple).

    Is their any way to include the namespace so I do not have to fully qualify each attribute?
    I'm afraid not. The translator doesn't interpret or process the given attributes, it simply copies them from the Slice definitions into the generated code.

    Regards,
    Mark

  3. #3
    JVerwey is offline Registered User
    Name: Johan Verwey
    Organization: Immersion
    Project: WPF editor for C++ Simulation
    Join Date
    Jan 2009
    Posts
    7

    Thanks

    Great, I made a local modification to the slice2cs generator for now.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. strcuts and ["clr:property"]
    By kwaclaw in forum Bug Reports
    Replies: 2
    Last Post: 09-24-2007, 03:43 AM
  2. Replies: 6
    Last Post: 06-12-2006, 08:30 AM
  3. problem with cs:class attribute
    By kovacm in forum Bug Reports
    Replies: 7
    Last Post: 08-25-2005, 11:12 PM
  4. CS: compiler warning
    By DeepDiver in forum Bug Reports
    Replies: 2
    Last Post: 01-10-2005, 07:31 PM
  5. General praise, CLR and C# bindings
    By Ctaesis in forum Comments
    Replies: 2
    Last Post: 01-05-2004, 12:26 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
  •