Book a Demo

Author Topic: c# attributes above function/properties/classes  (Read 3643 times)

puromtec

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
c# attributes above function/properties/classes
« on: May 14, 2008, 01:52:00 am »
I am using 7.0.818 of EA to generate code in C# language. It appears that EA cannot handle the "attributes" above C# constructs (properties, classes, etc.), such as the following c# property example below with the attributed of type 'XmlElement':

Code: [Select]
[XmlElement(Type = typeof(CustomSerializer<SingleAnalysis>))]
        public List<SingleAnalysis> Analysis
        {
            get
            {
                if (analysis == null)
                    analysis = new List<SingleAnalysis>();
                return analysis;
            }
            set
            {
                analysis = value;
            }
        }

What happens is on synchronization -> source code, the '[ etc. ]' is removed. This is really a deal breaker for us. Is there anything we can do with EA settings in templates that will let the '[ etc ]' to remain in the .cs files?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: c# attributes above function/properties/classe
« Reply #1 on: May 14, 2008, 05:15:47 am »
Search the forum for attributes and C#. I think there was a way to do this, and it was posted (perhaps by one of the Sparxians).

I could be wrong about this, but if so the post was to the effect that it couldn't be done. Either way you will have your answer.

I think it was a long time ago, so remember to set the search parameters accordingly.

David
No, you can't have it!

davidmf

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: c# attributes above function/properties/classe
« Reply #2 on: May 14, 2008, 06:27:16 am »
Yep, there is a way to do this for classes (not however, for properties - that I know of).

Select a class from a class diagram, then using the context menu (right-mouse click) choose Add|Tagged Value to bring up the tag editor. If you add a tag called Attribute, you can give it one (or more separated by semi-colons) value(s).

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: c# attributes above function/properties/classe
« Reply #3 on: May 14, 2008, 09:16:07 am »
The tagged value mentioned above can be added to anything generated to code, including properties.