-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support using any dictionary as JsonExtensionData #31645
Comments
Triage: we should generalize this to support all dictionary types that the serializer supports as extension data. Supported types can be found here dotnet/docs#15807 (comment). Changing the title to reflect this. |
Adding request for ImmutableDictionary from @mwikstrom in #32408:
|
Hey there, I'd love to pick this up and take a look at getting these types serializing. Could the issue be assigned to me? |
@Romanx, certainly. Please let me know if you run into any issue or have any questions. |
@layomia I can't seem to get the project to build. I've forked and cloned the repo, built everything following this. when I opened vs using If i unload that project then I get get everything to build but i can't seem to get the tests to run and looking in the test output from VS i'm seeing Following that path i find that my output is being put into a folder I may be being dense and have missed something obvious but any help would be appreciated for a first timer! |
@Romanx can you share the output if running Did you build the repo before running :: From root:
git clean -xdf
git pull upstream master & git push origin master
:: Build Debug libraries on top of Release runtime:
build -subset clr+libs -runtimeConfiguration Release |
Hey, The results from
I was running VS After building in 16.6 the ref project errors went away but the test error looking for the dll in the wrong directory persisted. |
Anipik it seems like the path is missing the TFM, was this fixed with yesterday's PR as well? I think if you don't open with |
cc @Anipik |
I managed to get the tests running on my machine after marking sure my default program for I started taking a look using the The reason that these types work in the context of normal json collections for is that a specific JsonConverter is used and the read items are stored in an intermediate dictionary and then converted into the correct output type when the collection has been fully read. That method would not work here without work since the items we need to add are not in order since they're the items without a matched property. It would be good to be able to reuse the JsonConverter method since the conversions are already there and any new types would work however the JsonConverter uses the ReadStack for state which I think would cause the reading to break. I'm not sure the best course of action from here, creating an interim dictionary and then converting to the output type at the end seems to be right idea however where to start with that is the next question. Adding a dictionary to the Hopefully that ramble makes some sense 😄 |
@Romanx, yes it does 😄
After deserialization, logic similar to what you've seen in the dictionary converters can be used to instantiate and populate the desired dictionary type. I expect this conversion to take place in the converter for the object, not one of the dictionary converters.
Glad you were able to get this to work. |
I'm sure you'll get a notification but i've just pushed up the branch and opened the PR for this. I'm aware there's likely to be changes so I'll wait for them. Thanks for being so kind and helpful with this 👍 I'm not wild about the internal |
@Romanx I assume you don't work on that anymore. This will be much easier to fix once populating objects is supported. There is a chance I will address this as part of that work but no promises (even if I don't it's going to be much easier to do). |
No problem removing me from this @krwq. After the PR got closed I didn't go back to taking a look at this but good to know there may be hope for this yet! :) |
IMHO,
IReadOnlyDictionary
should work identical toIDictionary
when using withJsonExtensionData
attribute.Currently it fails with error:
This is analogous to collection properties which can be defined as
List<T>
,IList<T>
orIReadOnlyList<T>
etc.The text was updated successfully, but these errors were encountered: