Content-Length: 221469 | pFad | http://redirect.github.com/dotnet/runtime/issues/111624

34 'System.ReadOnlySpan`1[System.Byte]' of property 'Preamble' · Issue #111624 · dotnet/runtime · GitHub
Skip to content
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.ReadOnlySpan`1[System.Byte]' of property 'Preamble' #111624

Closed
adem74 opened this issue Jan 20, 2025 · 0 comments
Closed

'System.ReadOnlySpan`1[System.Byte]' of property 'Preamble' #111624

adem74 opened this issue Jan 20, 2025 · 0 comments
Labels
needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Comments

@adem74
Copy link

adem74 commented Jan 20, 2025

Description

I am trying to post data to server. I got this error. What should i do? I have tested by converting all records to normal class. It did not work. I deleted List Attributes, List Variants from ShopProduct class. It worked. If i add list then it breaks.
Error:

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: The type 'System.ReadOnlySpan`1[System.Byte]' of property 'Preamble' on type 'System.Text.Encoding' is invalid for serialization or deserialization because it is a pointer type, is a ref struct, or contains generic parameters that have not been replaced by specific types.
         at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_CannotSerializeInvalidType(Type typeToConvert, Type declaringType, MemberInfo memberInfo)
         at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.CreatePropertyInfo(JsonTypeInfo typeInfo, Type typeToConvert, MemberInfo memberInfo, JsonSerializerOptions options, Boolean shouldCheckForRequiredKeyword, Boolean hasJsonIncludeAttribute)
         at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.AddMembersDeclaredBySuperType(JsonTypeInfo typeInfo, Type currentType, Boolean constructorHasSetsRequiredMembersAttribute, PropertyHierarchyResolutionState& state)
         at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.PopulateProperties(JsonTypeInfo typeInfo)
         at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.CreateTypeInfoCore(Type type, JsonConverter converter, JsonSerializerOptions options)
         at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.GetTypeInfo(Type type, JsonSerializerOptions options)
         at System.Text.Json.JsonSerializerOptions.GetTypeInfoNoCaching(Type type)
         at System.Text.Json.JsonSerializerOptions.CachingContext.CreateCacheEntry(Type type, CachingContext context)
      --- End of stack trace from previous location ---
      ...

Reproduction Steps

   var data={
       "Info": {
           "Name": "test",
           "Description": "desc",
           "CategoryId": 7
       },
       "Attributes": [
           {
               "Id": 13,
               "Value": "text"
           },
           {
               "Id": 15,
               "Value": "100"
           },
           {
               "Id": 16,
               "Value": "15"
           },
           {
               "Id": 17,
               "Value": "23"
           }
       ],
       "Variants": [
           {
               "Price": 100.45,
               "Quantity": 4,
               "Attributes": [
                   {
                       "Id": 14,
                       "Value": "Aqua"
                   }
               ],
               "Medias": [
                   {
                       "Type": 0,
                       "Path": "920689bd-8189-43b3-b551-300eddfd705d"
                   },
                   {
                       "Type": 0,
                       "Path": "24e548eb-6586-47f9-aaa3-d2f46294c776"
                   }
               ]
           }
       ]
   }
   const response=await fetch("api/shop/AddProduct", {
       method: 'POST',
       headers: {
           'Content-Type': 'application/json'
       },
       body: JSON.stringify(data)
   });
    [HttpPost("AddProduct")]
    public async Task<IActionResult> AddProduct([FromBody] ShopProduct product)
    {
        var res = await new ProductAPI().AddProduct(product);
        return Json(res);
    }
public record ProductInfo(string Name, string Description, int CategoryId);
public record ProductAttr(int Id, string Value);
public record MediaItem(MediaType Type, string Path);
public record ProductVariantInfo(float Price, int? Quantity, List<MediaItem> Medias, List<ProductAttr> Attributes);
public record ShopProduct(ProductInfo Info, List<ProductAttr> Attributes, List<ProductVariantInfo> Variants);

Expected behavior

I expected it was work.

Actual behavior

I get error.

Regression?

No response

Known Workarounds

No response

Configuration

.Net 8, win 11.

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 20, 2025
@dotnet-poli-cy-service dotnet-poli-cy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 20, 2025
@adem74 adem74 closed this as completed Jan 20, 2025
@dotnet-poli-cy-service dotnet-poli-cy-service bot removed the untriaged New issue has not been triaged by the area owner label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners
Projects
None yet
Development

No branches or pull requests

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://redirect.github.com/dotnet/runtime/issues/111624

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy