You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Overview
If a source generator transforms an input file that's given to it via AdditionalFiles and then the input file is deleted, the generated source remains.
[Generator]publicclassControllerGenerator:ISourceGenerator{publicvoidExecute(GeneratorExecutionContextcontext){foreach(var file in context.AdditionalFiles){stringinputFilename= Path.GetFileNameWithoutExtension(file.Path);stringoutputFilename=inputFilename+".g.cs";
context.AddSource(outputFilename,$"class {inputFilename}");}}}
Place two files in examplesubfolder\: one.json and two.json.
Compile MyProject.
VS shows two generated files: one.g.cs and two.g.cs
Delete two.json from examplesubfolder\
VS still shows two generated files: one.g.cs and two.g.cs, even though two.json has been deleted. The only way to fix this is to restart VS. Rebuilding MyProject or doing a clean and then build doesn't work.
Expected Behavior:
When two.json is deleted, its corresponding two.g.cs file should disappear from within VS.
Actual Behavior:
When two.json is deleted, the corresponding two.g.cs file remains visible in VS.
The text was updated successfully, but these errors were encountered:
Eli-Black-Work
changed the title
Source generators don't hide generated C# when source file is deleted
Source generators don't run when a file in AdditionalFiles is deleted
Mar 29, 2022
@Bosch-Eli-Black trying this in 17.3 Preview 1.1 I do see the file disappear under the Solution Explorer and the generated content does disappear from intellisense as expected. I don't think we made any recent fixes here that would have fixed this. You're still seeing this as best you know?
And oh I should also say @Bosch-Eli-Black the delay for updating the solution explorer list is intentionally very slow, so it might take a few seconds after everything else has settled down.
Version Used:
VS 17.2.0 Preview 2.0
Overview
If a source generator transforms an input file that's given to it via
AdditionalFiles
and then the input file is deleted, the generated source remains.Steps to Reproduce:
Set up a project, like so:
MyProject.csproj
Set up a generator, like so:
MyGenerator
examplesubfolder\
:one.json
andtwo.json
.MyProject
.one.g.cs
andtwo.g.cs
two.json
fromexamplesubfolder\
one.g.cs
andtwo.g.cs
, even thoughtwo.json
has been deleted. The only way to fix this is to restart VS. RebuildingMyProject
or doing a clean and then build doesn't work.Expected Behavior:
When
two.json
is deleted, its correspondingtwo.g.cs
file should disappear from within VS.Actual Behavior:
When
two.json
is deleted, the correspondingtwo.g.cs
file remains visible in VS.The text was updated successfully, but these errors were encountered: