1

I need detect when exist any modification in c# code automaticaly generate with CSharpCodeProvider after generation.

Exist any build in solution? I can make my solution (adding a CRC in a comment)... but I search a built in solution provide by .NET framework.

I check #Pragma checksum, but its only detect modifications between source and binary.

Victor Sanchez
  • 583
  • 9
  • 28
  • 1
    Modification when, to what? To the source, to the compiled binary? Please explain your [Threat Model](http://en.wikipedia.org/wiki/Threat_model) as any solution will depend on what you are specifically trying to protect against. – Scott Chamberlain Dec 19 '14 at 20:15
  • This is important? I need check that only Source files generated via CSeharpCodeProvider are stored in my TFS server – Victor Sanchez Dec 20 '14 at 11:59
  • I think you need to explain a lot more about how you're using CSharpCodeProvider. "I need check that only Source files generated via CSeharpCodeProvider are stored in my TFS server." That statement makes no sense to me - CSharpCodeProvider does not (as far as I know) generate source files. – RenniePet Dec 20 '14 at 13:50
  • What? RenniePet you can show more info in: http://msdn.microsoft.com/en-us/library/saf5ce06(v=vs.110).aspx – Victor Sanchez Dec 20 '14 at 19:41
  • You can use CSharpCodeProvider to generate source files.... so I guess you are generating a text file which overwrites a previous text file which was checked into TFS. Any diff program including ones built into VS for checking into TFS can compare whether the file has changed. So are you asking how to use diff? – kjbartel Dec 22 '14 at 14:36

1 Answers1

1

Maybe I'm overlooking something but I don't see why you don't apply the KISS approach. Simply use File.Copy() to make a backup copy of the previously generated file. Then it becomes a simple string compare with the aid of File.ReadAllText() on the new and the old file. And do whatever it is you want to do when they are different.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Your "kiss approach" now is my "only approach"... but don't is "kiss". Generate a CRC, is not tribial... I need remove spaces, tabs, comments... and calculate a CRC using SHA1 (or similar). – Victor Sanchez Dec 29 '14 at 13:48
  • Getting the same CRC does *not* guarantee that the files are the same. – Hans Passant Dec 29 '14 at 13:57