AdaskoTheBeAsT / Typewriter

Automatic TypeScript template generation from C# source files
http://frhagn.github.io/Typewriter
Apache License 2.0
62 stars 12 forks source link

Generated files are in wrong encoding #40

Closed qbunia closed 7 months ago

qbunia commented 7 months ago

When classes are generated they have windows-1250 encoding instead of original file encoding UTF8. How I can fix this issue?

qbunia commented 7 months ago

Newest version broke the extension. Im getting error: 23:50:07.885 ERROR: Error processing queue: Illegal characters in path. at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath) at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) at Typewriter.Generation.Template.WriteFile(String outputPath, String outputContent) at Typewriter.Generation.Template.SaveFile(File file, String output, Boolean& success) at Typewriter.Generation.Template.RenderFile(File file) at Typewriter.Generation.Controllers.GenerationController.<>c__DisplayClass5_1.<OnTemplateChanged>b__1() at Typewriter.Generation.Controllers.EventQueue.ProcessQueue()

AdaskoTheBeAsT commented 7 months ago

to investigate I need path in which template exists

qbunia commented 7 months ago

Its C:\Users\Qbusoft\Desktop\DoctorsOfficeGit\AngularTest\src\models

qbunia commented 7 months ago

@AdaskoTheBeAsT did you manage to fix the issue?

AdaskoTheBeAsT commented 7 months ago

please download latest version

qbunia commented 7 months ago

On latest version it doesnt work. I tested it.

AdaskoTheBeAsT commented 7 months ago

this is version which I have image

when I generate some file out of tst file without BOM and when I check its encoding in notepad++ it clearly says it is UTF-8

image

same when I use default

image

qbunia commented 7 months ago

The problem is that with newest version I cannot generate anything. I mentioned the bug below.

AdaskoTheBeAsT commented 7 months ago

can you enable long paths on your machine?

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] "LongPathsEnabled"=dword:00000001

qbunia commented 7 months ago

Unfortunately its not possible.

AdaskoTheBeAsT commented 6 months ago

please check this one https://github.com/AdaskoTheBeAsT/Typewriter/releases/tag/v2.25.0

qbunia commented 6 months ago

Getting same error: 07:30:07.263 ERROR: Error processing queue: Illegal characters in path. at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath) at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) at Typewriter.Generation.Template.WriteFile(String outputPath, String outputContent) at Typewriter.Generation.Template.SaveFile(File file, String output, Boolean& success) at Typewriter.Generation.Template.RenderFile(File file) at Typewriter.Generation.Controllers.GenerationController.<>c__DisplayClass5_1.<OnTemplateChanged>b__1() at Typewriter.Generation.Controllers.EventQueue.ProcessQueue()

AdaskoTheBeAsT commented 6 months ago

in settings - do you use option .OutputDirectory() ? if yes is the path either written as

settings.OutputDirectory(@"C:\Users\Qbusoft\Desktop\DoctorsOfficeGit\AngularTest\src\models")

or

settings.OutputDirectory("C:\\Users\\Qbusoft\\Desktop\\DoctorsOfficeGit\\AngularTest\\src\\models")
qbunia commented 6 months ago

I dont use OutputDirectory at all in settings. My settings:

Template(Settings settings) { settings.IncludeProject("Models"); settings.OutputExtension = ".d.ts"; settings.DisableStrictNullGeneration(); settings.SkipAddingGeneratedFilesToProject = true; }

qbunia commented 6 months ago

@AdaskoTheBeAsT Did you get my last message?

AdaskoTheBeAsT commented 6 months ago

as I checked your file is working on my machine - so it is strictly related either with machine and/or also project related stuff - I can't recreate issue on my machine

qbunia commented 5 months ago

It turned out I had to actually set LongPathsEnabled to 0 to make it work.