svenheden / csharp-models-to-typescript

C# models to TypeScript
88 stars 58 forks source link

dotnet EOL warning suppression #70

Closed CharlieSaunders closed 3 months ago

CharlieSaunders commented 1 year ago

Adding a property to the dotnet run process that will suppress EOL Framework warnings based on the bool from the config.

When using the package on older frameworks, the dotnet run process; rightly, displays that the framework being used has reached EOL. This however means that the JSON generated is invalid as it contains warnings IE:

C:\dotnet\sdk\7.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp2.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [C:\path\to\the\node_modules\csharp-models-to-typescript\lib\csharp-models-to-json\csharp-models-to-json.csproj] [{foo:bar}]

Which when ran through JSON.parse; index.js: 70, errors with "Unexpected token C in JSON at position 0".

Adding this additional parameter on the config; suppressEolFrameworkErrors, suppresses those EOL warnings and only the generated JSON is sent for parsing.

digocesar commented 3 months ago

@svenheden and/or @SafeerH. If dotnet process has this option to ignore EOL error, is not better to always pass this parameter to do not emmit the EOL error? We had updated main to .Net 8.0, but this parameter can avoid the component stops working in the future, as happened recently.

svenheden commented 3 months ago

If dotnet process has this option to ignore EOL error, is not better to always pass this parameter to do not emmit the EOL error?

Yes that sounds like a good idea. I can't think of a scenario where you'd want to show that EOL error causing the JSON to be corrupted.

SafeerH commented 3 months ago

The root cause for the problem is the way of extracting the JSON from the console output. If there's anything else apart from the JSON string in the Console output (stdout), the program breaks. Also relates to #61 So, I think we need to find a broader solution that will isolate the JSON irrespective of other console outputs. I'm thinking of printing the JSON between markers, that will help us isolate the JSON. I will try this approach and let you guys know. Thanks!

UPDATE: Created a PR #78 with the solution. I hope this will resolve #61, #70 and similar issues.

digocesar commented 3 months ago

Hi @CharlieSaunders. Thanks for your help. This PR is not needed anymore as the #78 solved the problem.