KevinDockx / JsonPatch.Dynamic

Support for dynamically typed objects for Marvin.JsonPatch (Json Patch Document RFC 6902 implementation for .NET)
MIT License
8 stars 6 forks source link

Error adding reference to PCL #10

Closed HappyNomad closed 7 years ago

HappyNomad commented 7 years ago

The following error prevented me from adding the library to my portable class library (PCL).

Could not install package Marvin.JsonPatch.Dynamic 1.0.0. You are trying to install this package into a project that targets .NETPortable,Version=v4.5,Profile=Profile7, but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I was able to add Marvin.JsonPatch to the same PCL.

KevinDockx commented 7 years ago

Hi,

this package is not meant to be added to a PCL project. It requires refs from full .NET, and is thus meant to be used at server level and/or for full .NET clients only. However, it can be used at server level with a client that uses Marvin.JsonPatch in PCL. That's the advised way: at server level (API), use Marvin.JsonPatch.Dynamic (or the .NET core version if you're using .NET core). At client level, use whatever fits the framework you're using. Have a look at this for more info: https://www.kevindockx.com/which-jsonpatch-flavour-should-i-use/

HappyNomad commented 7 years ago

I need to use the non-generic JsonPatchDocument class on the client-side (not full .NET) for nested objects. Nested objects are only supported by this non-generic, which is fine since I don't have the object type as a type parameter so need this version anyway.

For what does Marvin.JsonPatch.Dynamic require references from full .NET? If it's related to supporting dynamically typed objects, I have no need for this functionality. For my scenario, whatever pieces depend on full .NET can remain in the non-PCL Marvin.JsonPatch.Dynamic while the rest of the non-generic JsonPatchDocument class should move to the Marvin.JsonPatch PCL.

Please don't arbitrarily limit usage of the non-generic JsonPatchDocument. That may be fine in your scenarios, but it's not okay in general as I can see in my scenario.

KevinDockx commented 7 years ago

That would mean a change in JsonPatch, not in JsonPatch.Dynamic - this one is indeed aimed at dynamically typed objects. I added an issue on the JsonPatch issue list.

chriscoderdr commented 7 years ago

So I have my pcl with targeting .net standard 1.4 and have the same problem, how did you manage to fix the issue @HappyNomad ?

HappyNomad commented 7 years ago

@cgomezmendez Microsoft's JSON Patch library targets .NET Standard 1.4, so you can reference it. I had a Windows 8.1 app which can only reference .NET Standard 1.2. I tried @KevinDockx's version but ran into this issue. The writing is on the wall so I ported my app to UWP. Now all my libraries target .NET Standard 1.4. I now use Microsoft's, instead of @KevinDockx's, library and so don't have to deal with this issue.

KevinDockx commented 7 years ago

As @HappyNomad mentions: when targeting .NET Standard, it's best to use Microsoft.AspNetCore.JsonPatch. That's a port of this library, for .NET Core. Closing this issue.