0

I'm hoping someone will be able to point me in the right direction. We are in the process of converting some of the fields in our database from int to bigint. This in terms means we need to update the appropriate fields in our code base from int to long. The problem is our code base is MASSIVE. We have hundreds of projects and manually searching through them would be tedious. So I want to build an application that when provided with an assembly, can search through all of the code for a specific string (in this case the field name). I've used reflection to invoke methods and get property values etc but can I use it to search the actual code of a compiled assembly for a value? The value could be in anything - a property, a constant, a method, etc. I've also looked at ildasm but it doesn't seem to provide me with a way to search for a specific string value. Any thoughts?

Shane McGarry
  • 513
  • 1
  • 6
  • 19
  • 1
    I would suggest looking into `Roslyn` which is Microsofts compiler as a service. You may hook into its AST (Abstract Syntax Tree) which will help you parse your code and search for properties, constants, methods, etc. You can look at it here: http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx – Yuval Itzchakov Jun 12 '14 at 16:00
  • I guess that explains how it got "massive" :/ This is technical debt, the longer you wait the more expensive it gets. The time to start refactoring is today. – Hans Passant Jun 12 '14 at 17:01

2 Answers2

1

There are several products that can do this for you:

Red Gate's Reflector (http://www.red-gate.com/products/dotnet-development/reflector/), Paid

Telerik's JustDecompile (http://www.telerik.com/products/decompiler.aspx), Free

JetBrains' dotPeek (http://www.jetbrains.com/decompiler/), Free

I primarily use Reflector out of habit because 1.) I paid for it a while ago and 2.) I've been using it since it was free, so hard habit to break. It can also allow you to export assemblies directly to source files and you can manipulate it from there.

dotnetnate
  • 769
  • 4
  • 11
0

You can use Reflector to search inside assemblies.

http://www.red-gate.com/products/dotnet-development/reflector/

Oscar
  • 13,594
  • 8
  • 47
  • 75