1
Vote

duplicate *.generated.cs-file after renaming view

description

I've renamed a view "Chart.cshtml" to "ChartDisplay.cshtml" and then renamed "Configuration.cshtml" to "Chart.cshtml". As a result I get two generated files "Chart.generated.cs" and "Chart1.generated.cs" where the first one is the renamed file that still contains a class "Configuration" (the name the view did have before renaming).

I'm using TFS as a source code repository (didn't test if that also happens without source control, because working without source control is not an option for me).

A simple workaround is to delete the "Chart.generated.cs" and keep "Chart1.generated.cs" - but I don't really want to have that "1" inside the file name (I have some doubts whether I will end up with additional file with in the future).

comments

davidebbo wrote Mar 21, 2013 at 6:23 PM

Try deleting all the generated files and then regenerate it by right clicking on cshtml and choosing 'Run Custom Tool' (or just resave the file).

Matzen wrote Mar 21, 2013 at 7:57 PM

Thanks for the quick Response, but deleting both files and re-running the tool generates a file called "Chart1.generated.cs" (including the "1"). It seems the tool still "sees" the old file inside TFS (the deleted one) and tries to avoid that file name. Does Razor Generator check fthe file System only to prevent overwriting existing files or does it also check the source control?

davidebbo wrote Mar 21, 2013 at 9:35 PM

RazorGenerator has no special logic for this, as it's a standard VS generator. So I think any behavior relating to TFS is probably standard behvaior. And admittedly I'm not really sure how that all works with TFS.