Book a Demo

Author Topic: MDG 3.5 Code Generation Bug  (Read 6705 times)

Tad Anderson

  • EA User
  • **
  • Posts: 52
  • Karma: +1/-0
  • The more I learn the less I know....
    • View Profile
MDG 3.5 Code Generation Bug
« on: April 19, 2008, 12:50:24 pm »
Code Gen Bug:
In the MDG 3.5 if you change the UML class model and then generate the code, it is not syncing with the current code in place.  It is instead re-writing the entire class including the namespace.  This is in C#.

I have pasted a sample file showing the replicated code.  This did not happen with VS 2005 and previous versions of MDG.  

Create a class, add a method or two, add a UML diagram, sync a SPARX/MDG Link Package with a Visual Studio Project, add a new method to the UML class, and do either generate code, or forward engineering using the package sync tool.  

Please see screenshot below for SPARX Product version details.

Submission Form:
I tried to submit this with your form, but it would not allow submission.  See Screen Shot

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevelopmentCase.DAL;

namespace DevelopmentCase
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Class1 C1 = new Class1();
            C1.test();
        }

        public string TestText1(string InputText)
        {
            throw new System.NotImplementedException();
        }
    }

      namespace DevelopmentCase {
            /// <summary>
            /// Interaction logic for Window1.xaml
            /// </summary>
            public partial class Window1 : Window {



                  ~Window1(){

                  }

                  public override void Dispose(){

                  }


                  public Window1(){

                  }

                  ///
                  /// <param name="sender"></param>
                  /// <param name="e"></param>
                  private void button1_Click(object sender, RoutedEventArgs e){

                  }

                  ///
                  /// <param name="InputText"></param>
                  public string TestText12(string InputText){

                        return "";
                  }

                  ///
                  /// <param name="InputText"></param>
                  public string TestText123(string InputText){

                        return "";
                  }


            }//end Window1

      }//end namespace DevelopmentCase

      
      
}

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: MDG 3.5 Code Generation Bug
« Reply #1 on: April 22, 2008, 08:16:45 am »
What I'm seeing is that your namespace structure in the model doesn't match the namespace structure in code.  (Model has two DevelopmentCase packages below the namespace root.)  Try setting the top one as a namespace root and trying again.

Tad Anderson

  • EA User
  • **
  • Posts: 52
  • Karma: +1/-0
  • The more I learn the less I know....
    • View Profile
Re: MDG 3.5 Code Generation Bug
« Reply #2 on: April 22, 2008, 08:51:58 am »
Quote
What I'm seeing is that your namespace structure in the model doesn't match the namespace structure in code.  (Model has two DevelopmentCase packages below the namespace root.)  Try setting the top one as a namespace root and trying again.

The second namespace is the code generation issue that I am referring to.  I only have one in the code before trying to generate changes made to the model.  The code I am showing is the results of the bug.

The exact same model ane code work ok in VSTS 2005.  Try recreating the scenario I mention in the form.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: MDG 3.5 Code Generation Bug
« Reply #3 on: April 22, 2008, 09:39:45 am »
Let me attempt to clarify why I think this is happening.

You will find that you have a model structure something like this.

Package <- Project Root or namespace root.
 + DevelopmentCase     <- (Package A) Both of these namespaces are being generated
    + DevelopmentCase <- to code resulting in the duplicate code generated.
       + Window1


Set the top level package (Marked A) as a namespace root to prevent it from being generated and prevent the problem.

I'm not sure what in the steps you've followed has resulted in the bad package structure.  I'll trust that our MDG expert will be able to find that.  I'm just offering a solution.

Tad Anderson

  • EA User
  • **
  • Posts: 52
  • Karma: +1/-0
  • The more I learn the less I know....
    • View Profile
Re: MDG 3.5 Code Generation Bug
« Reply #4 on: April 22, 2008, 10:39:55 am »
All that does is stop the entire class from being duplicated, including the namespace, and propagated the duplication to the method level.

I have renamed DevelopmentCase to Class Model so I now have

Model
  -Class Model
     -Development Case

The code still is not syncing up, and this duplicate package name behavior is not happening in VSTS 2005.

I did find one resolution, turning on auto sync seems to work ok.  It is only happening from the manual generation.

Thanks for taking the time to get back to me, Tad

D.Rousseau

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: MDG 3.5 Code Generation Bug
« Reply #5 on: May 16, 2008, 07:08:06 pm »
Quote
Set the top level package (Marked A) as a namespace root to prevent it from being generated and prevent the problem.

I'm faced the same problem. Proposed solution is not a workaround : this is the problem's origin !
Everyone can reproduce it : when a package is connected on a VS project, namespace root is automatically set on this package. If you try to clear it, package is immediatly disconnected ! And, more amazing, if you try to set again the namespace root on it, connection is restored ! :o
In fact, I think that it is cause of the bug : connection on package forces namespace root on it.
I've logged a bug yesterday with this title "MDG Link synchronization with C# force namespace root", I'm waiting for an answer...


RemcoR

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: MDG 3.5 Code Generation Bug
« Reply #6 on: June 05, 2008, 09:21:42 am »
Any updates on this issue?