Joseph Shirk
Joseph Shirk

Reputation: 55

Visual Studio code map does not work - how to transform vb code snippets into a dmgl directed graph / code map using xml and xslt

I can't get Visual Studio to model/map orphaned/discrete VB function code.

I am working with a legacy application that is written in VB.Net. Most of the application code/executable is opaque to the end user, but it has user-space customization behind forms that can interact with the form fields and the data model. What I need to do is map this user-defined code to look for bad interactions, such as circular logic.

TL, DR (the question): The objective is to get some kind of Entity-Relationship or dependency graph. I could draw these in Viso or something, but to do it for all the code is rather daunting.

It seems to me that there should be a way to easily establish patterns for functions and their internals, and reads and writes. I have not found anything so far. No one should try doing this with Excel - it's too much. I'm familiar with regular expressions, but in my experience, it wasn't really meant for a problem like this.

Is there some way?

ignore below if uninterested in details

I've tried using VS code map, but it needs references into the compiled parts of the application, which I don't have. So in VS, this user code is basically dead, orphaned code that isn't recognized. It has no class context and is only executed at run-time. It seems pretty difficult to do this way. So VS Code can syntax highlight it, but Visual Studio can't do anything with it, and the add-on tools like code map and dmg (directed graphs) don't see it.

As all of the user code are simply functions, I was hoping to simply transform it somehow into DMGL to see how they reference each other in this limited context. I could possibly do this using Excel or Regex, but this must be a major endeavor into re-inventing the wheel. I've even tried Object-Role Modeling, but it must be entered manually and is too cumbersome.

I've also looked at Roslyn, but it's the same problem as for Visual Studio

It probably would not be nice to copy all my suspicious functions here, but one could see the entire context at: Most likely culprits

The key to understanding the code shown is that there is a parent/header form representing Time Cards. Fields in the Timecards table are prefixed lmp* -- and there is a child sub form representing detail lines, called TimecardLines the database table, whose fields are prefixed lml*.

Examples

These two functions can be invoked when certain fields of a timecard line is edited by the user. I am not showing the code, only the interfaces. Each can reference and update fields that are managed by other functions. So it can be a nightmare to visualize possible cascading effects in textual form.

Items labeled as dependencies are calls to the compiled part of the application for which I have only the interface footprint, and that can't be analyzed other than as entry/exit points. Since they are immutable to me, I can't fix them, only avoid them where they are unnecessary.:

M1.Ax.Erp.Forms.Production.Timecard.TimecardLineView

Function lmlRoundedEndTime_ValueChanged(sender, e)

updates:

lmlLaborHours - implicitly calls: - lmlLaborHours_ValueChanged()

inputs:

lmlRoundedStartTime

dependency:

App.Ax("Shift").``CalculateHours``()

behavior setting:

xapLMUpdateActualWithRounded

implicitly calls:

lmpRoundedEndTime_ValueChanged()

Function lmlRoundedStartTime_ValueChanged(sender, e)

updates:

inputs:

lmlActualStartTime

dependencies:

App.Ax("Shift").``CalculateEndTime``()

behavior settings:

xapLMCalculateEndTime

When these are edited, the parent header is then updated, so a number of related parent functions can badly interact:

M1.Ax.Erp.Forms.Production.Timecard.TimecardView

Parent of: +Timecard entry issue: M1.Ax.Erp.Forms.Production.TimecardLineView

The following functions may be called by: TimecardLines_UpdateCompleted

Function lmpRoundedStartTime_ValueChanged(sender, e)

updates:

lmpPayrollHours

inputs:

lmpRoundedStartTime

dependencies:

App.Ax("TimecardFunctions").CalculateHours()

behavior settings:

xapDCPayCalculationMethod

Function lmpRoundedEndTime_ValueChanged(sender, e)

updates:

lmpPayrollHours

inputs:

lmpRoundedStartTime

dependencies:

App.Ax("TimecardFunctions").CalculateHours()

behavior settings:

xapDCPayCalculationMethod

And so on.

PS: I don't have the Reputation score to create the tag dmgl - it should be. If someone could tag it, that would be super.

Upvotes: 2

Views: 217

Answers (0)

Related Questions