Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: jrEA on February 16, 2007, 10:08:32 am

Title: Generics
Post by: jrEA on February 16, 2007, 10:08:32 am
If I have the following code:

public interface IMyInterface<T>
{
 T GetMyObject();
}

public class MyClass : IMyInterface<MyObject>
{
 MyObject GetMyObject();
}

I do not know how to make in EA so that the GetMyObject method in MyClass class changes the return type from T to MyObject automatically when the IMyInterface<MyObject> was specified.

Any ideas?
Title: Re: Generics
Post by: «Midnight» on February 16, 2007, 10:25:15 am
Neither do I, but I need to figure this out soon. In the meantime you might want to try the same first steps I will use.HTH, David
Title: Re: Generics
Post by: JohnWSaundersIII on February 18, 2007, 04:15:38 pm
I just tried some things, and I can't even find a way to create a generic interface. The interface element doesn't have the detail tab which includes the "Templates" section.

I also tried using a class with a <<interface>> stereotype, but that is generated as a class, not as an interface.

John
Title: Re: Generics
Post by: Aaron B on February 18, 2007, 08:45:30 pm
Unfortunately, Generic Interfaces cannot currently be modelled in EA, but we are aware of this limitation and hope to address this in a future release.
Title: Re: Generics
Post by: CleverCoder on August 27, 2007, 11:36:00 am
So... seeing as how C# 3.0 is right around the corner, when do you suppose formal generic support (mainly generic methods) be supported? ;D
Title: Re: Generics
Post by: Martin Terreni on August 27, 2007, 12:16:00 pm
We'll probably have the same problem and I think I'll just solve ti through code generation templates for now...
Title: Re: Generics
Post by: Jeff Odell on April 16, 2008, 08:22:25 pm
Hi Martin -

Did you make any progress in resolving this issue?

I submitted a bug around reverse engineering C# 3.0 constructs.  I received the following:

We do not currently support the C# 3.0 language extensions including partial methods.

 >:(

I have registered this as a feature request on your behalf.


I've replied asking this be prioritized as this makes class modeling and the VS Integration pretty useless on my next two projects.

If you need this feature please put in a prioity request to see if we can get it moving.
Title: Re: Generics
Post by: JohnWSaundersIII on April 16, 2008, 11:55:02 pm
Seeing activity on this thread made me try again. It's still not supported properly.

Depending on how long C# 3.0 support will take, Sparx may wish to consider fixing this problem before finishing C# 3.0 support. As much as generic interfaces are required in order to support LINQ, generic interfaces have existed in C# since Visual Studio 2005. Generic collection interfaces are used fairly heavily. IList<T> would be nice to have.
Title: Re: Generics
Post by: «Midnight» on April 17, 2008, 12:45:09 am
I've had some (very limited) success using parameterized classes for this. I have no idea what would happen if this approach were used in an 'industrial strength' application though.
Title: Re: Generics
Post by: JohnWSaundersIII on April 17, 2008, 05:38:07 am
What did your parameterized class generate to? Not a generic interface, right?
Title: Re: Generics
Post by: «Midnight» on April 17, 2008, 08:17:40 am
No, not a generic interface.

But I was able to create classes that had (Of T) -ish syntax, and correctly generate the code. As I said though, I don't know how far this would take me in a complex system model. My application domain was quite subtle, and sensitive to several factors (including generics), but it was also very limited in scope. It is possible that I just found a sweet spot that worked in my specific situation but would break elsewhere.

Sorry I can't offer much help or hope.

The real bottom line is that generics and partials need solid support, keyed to specific languages, and versions as appropriate. At a minimum recent versions of the Java and the .Net world need this, and that covers a pretty large segment of the potential user base.

David