Sparx Systems Forum

Enterprise Architect => Bugs and Issues => Topic started by: Gusztav on September 25, 2013, 05:33:30 pm

Title: TemplateBinding error on model transformation
Post by: Gusztav on September 25, 2013, 05:33:30 pm
 :'(Hi,

I'm trying to transform a domain model to C# class model. The domain modelt contains some template classes and some classes subtituting the template parameter with a concretet type. Say the template class is TC<T> and the concrete one is CC. in this case I use a bind connector pointing from CC to TC, and in the Bindings panel, T is substituted with a type (sometime with a simple type like int, sometimes with classes). The diagram showing these classes shows UML-compliant.

The transformation, however, does not succeed. EA drops the following message:

There was an error parsing C:\<path> on line 1916.
Unexpected symbol: TemplateBinding


Taking a look at the log file, line 1916 contains "TemplateBinding", the intermediary definition of a template binding. This is the first template binding in the file.

I have no clue what may be wrong, since there is no additional information I'm aware of. Did any of you run into the same problem, and can you tell me a solution or workaround other than avoid using template classes in the domain model?

Gus
Title: Re: TemplateBinding error on model transformation
Post by: Gusztav on October 02, 2013, 03:01:48 am
For those interested in the answer, we have tracked down the problem. Our conclusions, confirmed by support are the followings:

What we could come up with is to have the name of the template parameter of generic classes transformed by MDA by adding a ClassParameter template to the set of MDA templates, but we could not access the type, constraint and default attribute of generic parameters, neither could we access parameter substitution data in classes derived from the generic and substituting the generic parameter with a concrete type.
Title: Re: TemplateBinding error on model transformation
Post by: Stephane B on October 25, 2013, 09:08:56 pm
Yep, I asked a similar(ly unanswered) question. Thanks for the Generalization tip ; missed it.
If I understand well, you are doing a two-step PIM to C#Specific Model to C# code. In this case, there could be a hacky solution to get your substitution parameter back:

1st, you tune the PIM to C#model transformation to put the value of your substitution parameter in a particular tagged value, say "ParameterSubstitution".

2nd, you tune the C# code template so that when it encounters such tagged value, it outputs "<"+%Tag:ParameterSubstitution%+">".

Did something resembling with imports. Should work. Let us know.

Stéphane
Title: Re: TemplateBinding error on model transformation
Post by: Gusztav on October 25, 2013, 09:13:19 pm
Hi Stéphane,

Thanks for the tip! We also managed to invent this option and could get our transformation to work. Actually the problem with tagged values shadowing some other fields is that, as to my eyes, that you practically do not have any means to keep them sync'd, just as if you were entering List<Foo>, for example, for the return type of a method: renaming foo won't have an effect on the type. Do you have any suggestions for keeping these information in sync? I'd pleased to get some hints. :)

Cheers,
Gus