ngocnicholas / airtable.net

Airtable .NET API Client
MIT License
138 stars 34 forks source link

System.Text.Json 7.0 causes problems for .Net 6.0 Consumers #73

Open nilvon9wo opened 1 year ago

nilvon9wo commented 1 year ago

I have no problem adding the airtable.net NuGet to my .Net 6.0 Azure Function, possibly because AirtableApiClient.csproj contains <TargetFramework>netstandard2.0</TargetFramework>.

However, when I attempt to instantiate AirtableBase, I get an unexpected exception with message "{"Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.":"System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"}".

Even if I explicitly add "System.Text.Json" as a NuGet to the project -- which the NuGet Package Manager surprisingly allows -- this error persists.

I tried to us an older version of the airtable.net NuGet, but it did not seem to contain the UpdateMultipleRecords overload public async Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> UpdateMultipleRecords( string tableIdOrName, AirtableRecord[] records, bool typecast = false, bool returnFieldsByFieldId = false, PerformUpsert performUpsert = null), which I wanted to use.

By cloning the repo, I was able to simply modify the csproj file to use <PackageReference Include="System.Text.Json" Version="[6.*,7.0)" />, and could then use this method successfully.

Moreover, I've had no compliation issues.

I don't know what features I'm missing and may/may-not need/want later, but I know I'd rather not maintain my own fork of this repository and need to worry about keeping it up to date and merge conflicts.

If this project really needs System.Text.Json v7.0, please consider supporting multiple .Net Framework versions. See: https://learn.microsoft.com/en-us/nuget/create-packages/multiple-target-frameworks-project-file

tobyduncombe-ic commented 1 year ago

Hi, I'm not associated with this library but I took a look at your PR out of curiosity. I notice that the main change seems to be bumping the target framework for airtable.net from netstandard2.0 to net6. This would break the library entirely for all users of .NET Framework and anyone using net5 or below.

It's my understanding that all current versions of .NET, whether Core, Framework, or newer, should be able to target netstandard2.0. So I don't think a target framework change is the correct fix for the issue you are having.

Happy to be corrected if I've got something wrong.

nilvon9wo commented 1 year ago

Hi @tobyduncombe-ic ,

I did not necessarily mean for that draft PR to be a complete solution to this issue. I just created the branch for myself to fix the problem for myself. I think that PR got created accidently as I only wanted a PR against the master on my own fork, not against this repo, so I could see my own changes and not if any other changes were required.

I couldn't find anything in Github to change the target away from "base", however I've closed the PR to eliminate confusion.

In the context of what I was doing, I'm using .Net 6.0 and I was not in a position to test whether it would work with anything earlier or later. I'm doubtful whether downgrading System.Text.Json alone would even fix this for netstandard2.0 consumers. Moveover, I've noticed while working on .Net 7.0 projects, referencing .Net 6.0 packages or earlier can also break things, so simply merging that may now break this for other consumers using .Net 7.0.

A proper fix, as mentioned above should include supporting multiple .Net Frameworks, but I'm not prepared to make that right now.

nilvon9wo commented 1 year ago

I've created a PR which should fix this properly: https://github.com/ngocnicholas/airtable.net/pull/75

nilvon9wo commented 1 year ago

Is there a protocol I should follow to get a response to my PR?

ngocnicholas commented 1 year ago

I don't know any protocol like this. I cannot think of a satisfying solution for this issue at the moment. I am working on adding webhooks to the library and will look into this PR next. Thanks for using Airtable.net.

nilvon9wo commented 1 year ago

image

robertreppel commented 8 months ago

@nilvon9wo thank you very much for your workaround! Ran into the same issue when trying to use airtable.net for an Azure Function App.

ngocnicholas commented 1 month ago

Next version of Airtable.net will use System.Text.Json 8.0.4 which will work with .net 6.0.