Verdur
Verdur
CC#
Created by Verdur on 5/18/2024 in #help
Interface implementing generic parameters
Thank you, but that's not what I need unfortunately. I will ask other question in other topic
4 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
Thank you for help, I think this problem is now resolved
22 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
Yes, I can do that or use wrapper type for now.
22 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
Oh, thank you for sending a link, I was thinking about creating an issue myself 😅
22 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
No description
22 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
No description
22 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
Here's simple example to reproduce this bug: Models:
c#
[JsonDerivedType(typeof(Bar), nameof(Bar))]
public class Foo
{
public int IntField { get; set; }
}

public class Bar: Foo
{
public string StringField { get; set; } = null!;
}

public class FooWrapper
{
public Foo Foo { get; set; } = null!;
}
c#
[JsonDerivedType(typeof(Bar), nameof(Bar))]
public class Foo
{
public int IntField { get; set; }
}

public class Bar: Foo
{
public string StringField { get; set; } = null!;
}

public class FooWrapper
{
public Foo Foo { get; set; } = null!;
}
Hub:
c#
public class MyHub : Hub
{
public void SendFoo()
{
Foo foo = new Bar { IntField = 1, StringField = "hello" };

var wrapper = new FooWrapper { Foo = foo };
Clients.All.SendAsync("ReceiveFoo", wrapper);
Clients.All.SendAsync("ReceiveFoo", foo);
}
}
c#
public class MyHub : Hub
{
public void SendFoo()
{
Foo foo = new Bar { IntField = 1, StringField = "hello" };

var wrapper = new FooWrapper { Foo = foo };
Clients.All.SendAsync("ReceiveFoo", wrapper);
Clients.All.SendAsync("ReceiveFoo", foo);
}
}
When I'm sending foo, json serializator doesn't include $type property to json. When I'm sending wrapper, json serializator includes $type property to json.
22 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
Yes, I'm using System.Text.Json. There is no problem with manual serialization, but when I pass a value to signalr's SendAsync function it doesn't serialize it's value with $type property
22 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
Just checked it and looks like problem is in serializer indeed. It doesn't provide $type element if I'm serailizing base class, but if I serialize wrapper class that contains base class it does provide $type element
22 replies
CC#
Created by Verdur on 1/4/2024 in #help
✅ Complicated error with C# SignalR client
I have JsonDerivedType attribute on my base class, but connection.on still refuses to convert data to the derived classes, it just stops converting at the type you passed in generic
22 replies