Home Help Center

Using clr:property with cs:attribute

JVerweyJVerwey Member Johan VerweyOrganization: ImmersionProject: WPF editor for C++ Simulation
Hi,

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

// Foo.ice
["clr:property"]
class Foo
{
["cs:attribute:MyLibrary.MyOtherNameSpace.MyAttrib"]
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

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Welcome to the forum!
    JVerwey wrote: »
    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
  • JVerweyJVerwey Member Johan VerweyOrganization: ImmersionProject: WPF editor for C++ Simulation
    Thanks

    Great, I made a local modification to the slice2cs generator for now.
Sign In or Register to comment.