visualeyes / halcyon

A HAL implementation for ASP.NET
MIT License
81 stars 30 forks source link

Exception adding OutputFormatter in .netcore 3.0 #74

Open batizar opened 4 years ago

batizar commented 4 years ago

I am trying to use this package with asp.net core 3.0 and running into some issues.

Adding the OutputFormatter in ConfigureServices throws an exception, I am guessing changes in .netcore 3.0 json implementations must be the reason.

`c.OutputFormatters.Add(new JsonHalOutputFormatter(new[] { "application/hal+json", "application/vnd.example.hal+json", "application/vnd.example.hal.v1+json" }));

System.TypeLoadException: 'Could not load type 'Microsoft.AspNetCore.Mvc.Formatters.JsonSerializerSettingsProvider' from assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.'

Is there any fix for this? Will there be a .netcore 3.0 upgrade for this package?

Thanks.

Flogex commented 4 years ago

We met the same problem during our upgrade to ASP.NET Core 3.0.

This library is not maintained anymore AFAIK, hence we decided to fork this project and implement the required changes ourselves. Maybe that's an appropriate way for you, too.

rcollina commented 4 years ago

@Flogex any chance you have forked this project in a public repo?

Lutando commented 4 years ago

@Flogex any pointers on how you fixed it?

Flogex commented 4 years ago

@rcollina @Lutando Take a look at this commit: https://github.com/Flogex/halcyon/commit/4df3cb1b3f49ee443feb0b4d4c2be21cadb3b727.

In ASP.NET Core 3.0, Newtonsoft.Json was removed from the framework itself, but can be used by referencing the Microsoft.AspNetCore.Mvc.NewtonsoftJson package. In JsonHalOutputFormatter.cs, the JsonOutputFormatter class is replaced by NewtonsoftJsonOutputFormatter.

Note that if you want to maintain this library yourself, you will likely migrate from the old project.json to .csproj. See the previous commits.