Using clr:property with cs:attribute

in Help Center
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
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
0
Comments
Thanks for reporting 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).
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
Great, I made a local modification to the slice2cs generator for now.