-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
System.Text.Json - Collection was of a fixed size. Error on IEnumerable property #31089
Comments
Minimal steps to repro: https://dotnetfiddle.net/hdhEDG. Toggle comments on line 10 and 11; it works with |
Thank you for the report. We understand the issue and @layomia is working on a fix. Moved this to 5.0 since there is a workaround: make the backing data an IEnumerable and have the string property be the one doing the transformation. |
Fixed in dotnet/corefx#42420. @WayneHiller, can you please verify that the issue you reported has been fixed by using the latest nightly build of .NET Core 5.0 (or by adding a PackageReference to the latest S.T.Json NuGet package, from this feed: https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json - version |
I guess I need to wait until tomorrow to get version 5.0.0-alpha.1.19563.1, it is not avail yet |
@WayneHiller it should be available. This worked for me:
Note, as @ahsonkhan mentioned, you'll need to pick it up from our nightly feed. Make sure you have a nuget.config with something like |
@ericstj Thanks adding it directly to the csproj file worked. However I am still getting the error. Will aspnet core use the new System.Text.Json assembly by just adding it to the project? |
It should, if you're still reproducing the issue can you share an isolated repro project for us to try? |
It is pretty basic. I just created a new aspnet core 3 webapi project and added this controller:
Added the newest System.Text.Json to the project:
And then called POST to http://localhost:5000/test from Postman: And the result is:
|
Confirmed that this isn't fixed. Looking at this issue and the fix, I don't think the fix was addressing the original issue but instead was addressing a related thing that @layomia found when investigating the original issue. If I recall, @layomia mentioned that to fix the original issue we couldn't rely on the Getter to return back a mutable collection, even if we previously set a mutable collection with the setter. We needed to build up the muttable collection first, then only set once. I don't see the fix doing this. |
Thanks @ericstj. dotnet/corefx#42420 fixes a different issue (discovered while debugging this one) described in that PR's description and illustrated in https://dotnetfiddle.net/hdhEDG. I've updated the PR's description to make it less confusing.
This is indeed the fix for this issue, which is not implemented just yet. |
I have a class with this:
The Networks property is used by Dapper to read/write to and from the database.
The NetworkCodeList is sent/received to and from a web page.
I am getting an error when ASP.NET is Deserializing the object. This worked fine with Json.Net.
Any ideas what I can do here?
The text was updated successfully, but these errors were encountered: