AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Error details has platform-specific linebreaks

Open sherlock1982 opened this issue 1 year ago • 3 comments

Assemblies affected ASP.NET Core OData 8.2.4

Describe the bug Validation error contains the field details. It might be something like this for the error: Content\r\nInvalid on a Windows server. On a Linux server it will be: Content\nInvalid

Expected behavior I'm not that experienced in the RFC but I would expect it to be consistent? The important thing is who parses it not who produces.

sherlock1982 avatar Feb 09 '24 16:02 sherlock1982

Can you please provide a bit more detail on this issue? What validation error are you referring to exactly here? Is there a sample?

julealgon avatar Feb 09 '24 17:02 julealgon

Can you please provide a bit more detail on this issue? What validation error are you referring to exactly here? Is there a sample?

+1

xuzhg avatar Feb 12 '24 19:02 xuzhg

@sherlock1982 can you share more details to let us help you resolve the problem?

FYI. OData JSON serializer is using its own JSON writer which depends on 'TextWriter'. For TextWriter, it has the NewLine configuration using https://learn.microsoft.com/en-us/dotnet/api/system.io.textwriter.newline?view=net-8.0https://learn.microsoft.com/en-us/dotnet/api/system.io.textwriter.newline?view=net-8.0.

If you want to config it, you can create a JOSN writer factory (by implementing https://github.com/OData/odata.net/blob/main/src/Microsoft.OData.Core/Json/IJsonWriterFactory.cs) to config the TextWriter, then return a IJsonWriter to finish the writing. Thanks.

xuzhg avatar Feb 13 '24 17:02 xuzhg