0

I've just inherited a system that is 100K+ lines of C#/.NET code. Over the past few years, many of the functions of the system have been subsumed by other systems. The only reason we keep running this system is that it provides a small subset of IOT/sensor functionality. Basically, it is now only used to configure sensors and to receive sensor traffic and log it to a database. I want to identify the actively executing code so I can pull it out and move it to its own, standalone system. And then I want to retire the existing legacy system.

I have been able to step through the system in Visual Studio in dev, but there's no way for me to simulate all of the sensors, errors, and types of sensor messages that the system sees in production so I doubt I'm seeing all of the code being executed.

Is there any way I can toggle a runtime switch, add global code, etc., to the existing solution so that it exports the programs and function names that it is executing in production? I'd rather not touch every single program/function with new debug code, but I fear this might be the only way to get the information I want.

Any other ideas?

Thank you, Terry

(I've tried stepping through the code in Visual Studio and examining stack traces, but this doesn't allow me to ensure that I've seen all code that is being executed in production. I've looked into the Reflection classes, but am unclear if this is a path to doing what I want since I don't want to have to insert debug code into each function/program.)

TBlair
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 04 '22 at 06:51
  • May I know whether your issue have been solved or not? if not, please share it in here, we can work together to figure it out. – Jingmiao Xu-MSFT Dec 06 '22 at 03:25

1 Answers1

0

If the code you want to extract does not use reflection and you have an easy route to transfer the code to .Net 5 and later, you could use Code Trimming to let .net remove all unused code. After that you could decompile the resulting assembly to see what you can remove. This is merely a rough idea. There may be easier ways to get the application trimming result.

Fabian
  • 1,100
  • 11
  • 14