Closed prabhav-mehra closed 11 months ago
This is just a guess, but it sounds like the code generator is running on the original file and the generated file because the generated file has the same extension that code generator operates on.
You probably need to either generate to a file with a different extension (which doesn't sound like it would be practical in your scenario), or not automatically apply the code generator to all XML files.
@reduckted yep thats correct. That’s probably what’s happening. Is it possible I can change the name of the generated file, or change the location of the genrated file. So test.xml (the original file) creates 1 generated_test.xml file and hardcode the generated_test somewhere. And make it generator run on only test.xml or/and generate the generated file to some folder.
@reduckted I tried different things to achieve what you had suggested, couldn't get it to work. Is there any example I can refer to get the same result?
I have a VSIX extension which runs on a .xml file of a particular format and creates another .xml (expecting only one file) in some different format using the provided file content.
Now when I run this extension on a .xml file, it goes in a loop when creating the generated .xml file with the filename in the format of {fileName}1^n.xml
Suppose I run the extension on a test.xml, it sets the custom tool and creates test1.xml, test11.xml, test111.xml and so on, until I terminate the program.
When I change the GetDefaultExtension to ".cs" this doesn't happen and then it only creates one file.
Providing some code below. This is fairly similar to one from the SingleFileGenerator sample. I haven't gotten that to work for some reason to see if it's only a .xml thing, something related to my source generator or some error on files except the ".cs" extension.