Book a Demo

Author Topic: Importing C# classes with multiple parts...  (Read 4017 times)

jump-jet

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Importing C# classes with multiple parts...
« on: July 28, 2011, 02:52:07 am »
I'm using version 9 (build 908 - Professional) to import some C# source files from Visual Studio 2010.

I'm getting unexpected results when I import the source files for a class that uses the 'partial' keyword to allow the source for the class to be split into multiple source files.  When I do this, instead of getting a single class within the EA model containing the sum of the methods from the parts, I'm getting separate class definitions within the EA model, each with the same name, where each class contains the methods etc from a single part file.

Here's the hierarchy:

(in source file 1...)

namespace A
{
    public partial class X    {
        public void DoStuff2() {}
    }
}


(in source file 2...)

namespace A
{
    public partial class X    {
        public void DoStuff1() {}
    }
}


When these files are imported, I get two instances of a class called X.  One contains method DoStuff2(), the other contains DoStuff1().

Is the EA behaviour by-design or is it wrong?  It looks plainly wrong to me.  Is there any way to merge the multiple classes within the EA model so that the model correctly shows a single class?  I can easily copy the members from one of the classes to the other, but can the relationships on a class be moved onto another?

Dave Razzetti

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Importing C# classes with multiple parts...
« Reply #1 on: July 28, 2011, 11:23:01 am »
Hello Dave,
This is the current intended behavior.  It is necessary to maintain each part as it's own separate class element to allow round-trip code engineering (each class in EA is linked to a single file).  Unfortunately there is no way to show a unified representation of these parts as a whole at this time.

jump-jet

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Importing C# classes with multiple parts...
« Reply #2 on: July 28, 2011, 10:01:15 pm »
Hi Aaron,

Thanks for the reply.  Your response makes sense from the round-trip point of view, but makes no sense at all from my perspective.

I'm using EA to reverse-engineer a large application (no code documentation, no design documentation.  Sigh...).

I'm only interested in extracting the class information from the application's source-code files back into EA.  I'm never going to want to generate fresh code from EA.

With each part of the concrete class being modelled as a separate class entity in EA, I'm left with having to place each separate part onto diagrams (such as sequence diagrams) in order to be able to reference the methods within the class.  This feels like a cludge and looks strange on the diagrams.

Could you add a feature request:  When importing and where the user chooses "Create Package per Namespace" then the user be offered an option (checkbox) "Join partial class parts together".

I'd be happy if the default was 'No', but I'd really like an option to be able to combine the parts into a single entity within EA.

Dave Razzetti