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
Create simple incremental generator (it generates source code based on *.txt files as input)
Simple incremental generator (took from docs):
[Generator]publicclassGenerator:IIncrementalGenerator{publicvoidInitialize(IncrementalGeneratorInitializationContextinitContext){// define the execution pipeline here via a series of transformations:// find all additional files that end with .txtIncrementalValuesProvider<AdditionalText>textFiles=initContext.AdditionalTextsProvider.Where(file =>file.Path.EndsWith(".txt"));// read their contents and save their nameIncrementalValuesProvider<(stringname,stringcontent)>namesAndContents=textFiles.Select((text,cancellationToken)=>(name:Path.GetFileNameWithoutExtension(text.Path),content:text.GetText(cancellationToken).ToString()));// generate a class that contains their values as const stringsinitContext.RegisterSourceOutput(namesAndContents,(spc,nameAndContent)=>{File.AppendAllText("E:\\Generator.log","I am called\n");spc.AddSource($"ConstStrings.{nameAndContent.name}",$@" public static partial class ConstStrings {{ public const string {nameAndContent.name} = ""{nameAndContent.content}""; }}");});}}
Expected Behavior:
Each time when I add or change any *.txt file I should see new file at E:\\Generator.log path.
Actual Behavior:
Incremental generator is invoked only once at build stage. But seems it is not invoked when I add new *.txt file or edit its content.
NOTE:
It worked well in VS 17.10, seems stopped working in 17.11
The text was updated successfully, but these errors were encountered:
Version Used: Visual Studio 17.11.1
Steps to Reproduce:
*.txt
files as input)Simple incremental generator (took from docs):
Expected Behavior:
Each time when I add or change any
*.txt
file I should see new file atE:\\Generator.log
path.Actual Behavior:
Incremental generator is invoked only once at build stage. But seems it is not invoked when I add new
*.txt
file or edit its content.NOTE:
It worked well in VS 17.10, seems stopped working in 17.11
The text was updated successfully, but these errors were encountered: