Closed danijerez closed 1 year ago
Yeah, that was a bad refactor. Please check 3.1.1 where the methods are back (some with the deprecation attribute).
Thanks, is the new way documented somewhere?
I think there was a problem with 3.1.1 package. 3.1.2 should be ok. You should see the new extensions in CodegenCS.IO extending ICodegenOutputfile and ICodegenContext
I can't find an example of how to adapt the deprecated function
Please use CodegenCS.IO extensions: ICodegenTextWriter.SaveToFile() or ICodegenOutputFile.SaveToFolder()
Should I stop using CodegenTextWriter?
Yeah, I guess after a recent refactor things got a little confusing. I was trying to remove most I/O from the core library, it was being moved to a different assembly (and that's why the save methods were extensions) but then for some reasons I have aborted that idea, so maybe in next releases I might remove the deprecation attribute.
So... the old method is currently marked as obsolete but it still works:
var writer = new CodegenTextWriter();
writer.WriteLine("Hello, world");
writer.SaveToFile(@"C:\FullPath.cs");
The preferred way is using ICodegenContext and SaveToFolder extension:
using CodegenCS.IO;
var ctx = new CodegenContext();
var writer = ctx["FileName.cs"];
writer.WriteLine("Hello, world");
ctx.SaveToFolder(@"C:\"); // this extension is in CodegenCS.IO
Perfect, thanks! I was able to refactor the code
in version 3.1.0 the 'SaveToFile' function is not inside 'CodegenTextWriter', has it been refactored? Where can I find a changelog of the changes?