Book a Demo

Author Topic: reverse engineer source code with comments  (Read 6527 times)

Shaun Flynn

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
reverse engineer source code with comments
« on: October 17, 2019, 12:26:47 am »
Does anyone know how I can reverse engineer the source code comments into notes in the EA model?

I have the options turned on, however the comments in the form of /// blah above operations classes etc do not appear to come across into the notes.

Any pointers would be greatly appreciated as the tool purports to support this, so I am probably being dull!

Thanks
Shaun

bknoth2

  • EA User
  • **
  • Posts: 129
  • Karma: +2/-0
    • View Profile
Re: reverse engineer source code with comments
« Reply #1 on: October 17, 2019, 02:25:37 am »
Reverse engineering comments works for me in C++ (and has for years). I suggest generating code from a test class to see the form of the comments. Change a comment in that code and reverse engineer it to see if the comment changed in EA. That should give you some hints.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: reverse engineer source code with comments
« Reply #2 on: October 17, 2019, 09:42:32 am »
What language? Where are the comments in relation to the elements being imported into the model? What version of EA?

Shaun Flynn

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: reverse engineer source code with comments
« Reply #3 on: October 25, 2019, 01:16:49 am »
I am using c# so I have a file that looks like the following:-

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Classes {
   /// <summary>
   /// This is class s1
   /// </summary>
   public class Class1 {

      /// <summary>
      /// An Attribute
      /// </summary>
      private int AnAttribute;

      public Class1(){

      }

      ~Class1(){

      }

      /// <summary>
      /// An Operation
      /// </summary>
      public void AnOperation(){

      }

   }//end Class1

}//end namespace Classes

When I import it into EA none of the comments (Class, Attribute or Operation) are copied into the Notes for the element.

For information - I have the "Generate" and "Reverse" options ticked in the Source Code Engineering options in the preferences.

Thanks
Shaun

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: reverse engineer source code with comments
« Reply #4 on: October 25, 2019, 01:27:25 am »
Did you try bknoth2's suggestion? I don't think so.

q.

Shaun Flynn

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: reverse engineer source code with comments
« Reply #5 on: October 25, 2019, 01:30:02 am »
Yes I did.

And no it didn't work.

Shaun Flynn

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: reverse engineer source code with comments
« Reply #6 on: October 25, 2019, 01:41:02 am »
To clarify...

I produced an EA model with the Class, operation and attribute (with comments in the notes field).
Then forward generated the code.
The code was generated as in the post above.

I then changed one of the comments in the code and reverse engineered back into EA.
The comment was not updated.

I then deleted the class in the EA model and reverse engineered back into the model from the EA generated source file.
This gave me no comments against the class, operation or attribute.

Thanks
S

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: reverse engineer source code with comments
« Reply #7 on: October 25, 2019, 03:45:02 am »
I see. Sorry for being suspicious. Actually comments are comments and there is no syntactical relation to anything in the language. That's mimicked by some meta-text placed in the comment. I'm not sure whether EA's internal compiler will handle that (I thought that by bknoth2's comment EA is somehow able to do it). Someone else, please...

q.

P.S. Just noticed that you're both having different languages C# and C++
« Last Edit: October 25, 2019, 03:46:48 am by qwerty »

Shaun Flynn

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: reverse engineer source code with comments
« Reply #8 on: October 29, 2019, 09:36:48 pm »
Anyone got any words of wisdom on this topic for me please?

Thanks
S

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: reverse engineer source code with comments
« Reply #9 on: October 29, 2019, 11:56:33 pm »
I just tried it out of fun. And I had no issue when synching. Comments came back as expected.

q.

Shaun Flynn

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: reverse engineer source code with comments
« Reply #10 on: October 29, 2019, 11:59:12 pm »
Hey qwerty, what version are you using? and was it c# or c++ you were trying it with?

Thanks
S

Shaun Flynn

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: reverse engineer source code with comments
« Reply #11 on: October 30, 2019, 01:17:16 am »
Interesting enough the comments are copied into the notes if we use the format:-

   // <summary>
   // This is class s1
   // </summary>

But not if we use the format:-

   /// <summary>
   /// This is class s1
   /// </summary>

which is the standard xml comment format.
We use these as they allow auto generation of documentation for DoxyGen.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: reverse engineer source code with comments
« Reply #12 on: October 30, 2019, 01:25:29 am »
As I said: EA uses its own compiler. Either you write a pre-processor for EA (hmpf) or you stick to EA rules. Last option: send a feature request. Only recommended if you got lots of time to wait for a solution.

q.