AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Consider exposing Newtonsoft converters

Open stevendarby opened this issue 3 years ago • 5 comments

The Microsoft.AspNetCore.OData.NewtonsoftJson package is great for adding Newtonsoft converters for OData classes to MVC

It would also be handy to be able to use these converters outside of an MVC context, for example unit testing.

However, they are all internal so this isn't easily possible.

Please consider if they can be made public. If this isn't possible or desirable (e.g. perhaps they reference internal classes and you don't want to cascade a change to public in lots of classes) then consider a public extension method on SerializerSettings which adds them.

https://github.com/OData/AspNetCoreOData/blob/9225d1eba1601bf1470b7e611cdd595fa479dbfc/src/Microsoft.AspNetCore.OData.NewtonsoftJson/ODataNewtonsoftJsonMvcBuilderExtensions.cs#L83-L94

You could then refactor the above code to use the new extension method to avoid duplication.

I can raise a PR for this if you think it's a valid proposal.

stevendarby avatar Jul 01 '22 22:07 stevendarby

@stevendarby can you please provide me an example on how you accomplish "The Microsoft.AspNetCore.OData.NewtonsoftJson package is great for adding Newtonsoft converters for OData classes to MVC"

We are trying to use a custom converter to convert "System.Net.NetworkInformation.PhysicalAddress" -> string and wea re not able to....

NeoMorfeo avatar Jul 28 '23 10:07 NeoMorfeo

Wrong place to ask this.

But I would like to know if maintainers of this repo could triage my year old issue?

stevendarby avatar Jul 28 '23 22:07 stevendarby

@xuzhg

stevendarby avatar Nov 03 '23 21:11 stevendarby

@xuzhg this has never been triaged?

stevendarby avatar Mar 07 '24 01:03 stevendarby

@stevendarby I'm curious to know how exposing these would help with unit testing. Can you elaborate?

julealgon avatar Mar 07 '24 13:03 julealgon