-
Notifications
You must be signed in to change notification settings - Fork 183
feat: migrate .NET templates to System.Text.Json + add .NET 9.0 tests #1085
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
Open
Fellmonkey
wants to merge
8
commits into
appwrite:master
Choose a base branch
from
Fellmonkey:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3a3ca75
refactor: migrate from Newtonsoft.Json to System.Text.Json for serial…
Fellmonkey a49accc
feat: add initial tests for .NET 9.0 SDK
Fellmonkey 10a278c
fix: rename class from DotNet80Test to DotNet90Test in DotNet90Test file
Fellmonkey c74c9be
fix: update user-agent string interpolation to use string interpolati…
Fellmonkey 2852bfb
Merge branch 'appwrite:master' into master
Fellmonkey 7e48fca
feat: add ObjectToInferredTypesConverter template for DotNet
Fellmonkey bce53cb
Update tests/DotNet90Test.php
Fellmonkey 7e858d7
feat
Fellmonkey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ jobs: | |
Deno1303, | ||
DotNet60, | ||
DotNet80, | ||
DotNet90, | ||
FlutterStable, | ||
FlutterBeta, | ||
Go112, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
templates/dotnet/Package/Converters/ObjectToInferredTypesConverter.cs.twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace {{ spec.title | caseUcfirst }}.Converters | ||
{ | ||
public class ObjectToInferredTypesConverter : JsonConverter<object> | ||
{ | ||
public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
switch (reader.TokenType) | ||
{ | ||
case JsonTokenType.True: | ||
return true; | ||
case JsonTokenType.False: | ||
return false; | ||
case JsonTokenType.Number: | ||
if (reader.TryGetInt64(out long l)) | ||
{ | ||
return l; | ||
} | ||
return reader.GetDouble(); | ||
case JsonTokenType.String: | ||
if (reader.TryGetDateTime(out DateTime datetime)) | ||
{ | ||
return datetime; | ||
} | ||
return reader.GetString()!; | ||
case JsonTokenType.StartObject: | ||
return JsonSerializer.Deserialize<Dictionary<string, object>>(ref reader, options)!; | ||
case JsonTokenType.StartArray: | ||
return JsonSerializer.Deserialize<object[]>(ref reader, options)!; | ||
default: | ||
return JsonDocument.ParseValue(ref reader).RootElement.Clone(); | ||
} | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, object objectToWrite, JsonSerializerOptions options) | ||
{ | ||
JsonSerializer.Serialize(writer, objectToWrite, objectToWrite.GetType(), options); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.