-
Notifications
You must be signed in to change notification settings - Fork 33
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
Unexpected exception when using KiotaJsonSerializer
#397
Comments
Maybe the new extensions should have used something like: internal static async Task<string> SerializeAsJsonString(this IParsable value, CancellationToken cancellationToken)
{
using var writer = new JsonSerializationWriter();
writer.WriteObjectValue(null, value);
using var stream = writer.GetSerializedContent();
using var reader = new StreamReader(stream);
return await reader.ReadToEndAsync(cancellationToken);
} |
This is currently being registered here. And we're in the process of moving it there so the generated code is truely portable.
Which mean that if you use the Json methods (static or extension) before the client, or in the future the request adapter, has been newed up, you'll run into this error. Now, while the extension methods can register the serialization provider if it's missing because of where they are defined, the static methods can't. Thoughts? |
What does this means if you would use 2 kiota clients in one application GitHub and Graph for instance? Do we get double registrations? Or will they be overridden? This might lead to issues if you setup custom factories? I think the the KiotaJsonSerializer and the extension methods need to work indepently of the client. Maybe the registered factories should be set in the client and not in a singleton. |
Those are the default serialization providers. The app developer can always pass a different set to the request adapter (at least with our implementations) which will be local to this request adapter. |
Would you be ok with me detaching the Iparsable extensions from the registry? To make sure they will work not matter the registry is filled? |
For the Json extension methods defined in the Json package, yes. People won't have access to the method if they have not imported the dependency. So I think it's safe to assume they'll want to use this implementation. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
Sample code:
Results in:
This makes me wonder where and how the factories are registered, and if this is even needed for the extension methods.
The text was updated successfully, but these errors were encountered: