Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4ce6b17
Add support for Dictionary<non-string,> using TypeConverter.
jozkee Feb 14, 2020
a863dc4
Extend test to check dictionary as a property
jozkee Feb 14, 2020
9f8c14c
Merge branch 'master' of https://github.com/dotnet/runtime into TKey_…
jozkee Feb 14, 2020
46e0b32
Add support for non-string Tkey on Dictionary using custom KeyConverter.
jozkee Feb 15, 2020
e3cda2e
Fix object reference when TKey is string.
jozkee Feb 15, 2020
2830584
Improve performance on KeyConverter.
jozkee Feb 19, 2020
7b127ee
Extend KeyConverter support to DictionaryOfString
jozkee Feb 20, 2020
3bc38ec
Add tests for complex TValues and extension data (string)
jozkee Feb 20, 2020
eba5269
Add GetKeyConverter methods
jozkee Feb 20, 2020
0bac2b3
Do not call ReadKey on TryRead string key to avoid allocation.
jozkee Feb 20, 2020
820dc8c
Add support for object TKey and enum (TODO make enum actually work)
jozkee Feb 21, 2020
344a219
Add naive implementation for Enum. Add test file.
jozkee Feb 22, 2020
9caa700
Clean-up directories.
jozkee Feb 22, 2020
fd601af
Remove DictionaryOfStringTValue converter and add support for continu…
jozkee Feb 24, 2020
a76df85
Implement JsonConverter<T> fon KeyConverter<TKey>.
jozkee Feb 25, 2020
84378a0
Refactor code and add tests.
jozkee Feb 26, 2020
54e8ed3
Merge branch 'master' of https://github.com/dotnet/runtime into TKey_…
jozkee Feb 26, 2020
584ab67
Change NSE message to display the dintionary type instead of TKey type.
jozkee Feb 26, 2020
7cdfca9
Add TODO to broken test.
jozkee Feb 26, 2020
012008b
Code clean-up.
jozkee Feb 26, 2020
0a525d0
Unescape keys before parsing them on async deserialization.
jozkee Feb 27, 2020
a58baf2
Move WritePropertyName methods for int and Guid to their respective f…
jozkee Feb 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add naive implementation for Enum. Add test file.
  • Loading branch information
jozkee committed Feb 22, 2020
commit 344a219841ecb010bb88a8a0b737e160a12f578b
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ internal sealed class EnumKeyConverter<TEnum>: KeyConverter<TEnum> where TEnum :
{
public override bool ReadKey(ref Utf8JsonReader reader, out TEnum value)
{
throw new NotImplementedException();
string enumValue = reader.GetString()!;
value = Enum.Parse<TEnum>(enumValue);

return true;//?
}

protected override void WriteKeyAsT(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options)
{
//string keyName = value.ToString();
//writer.WritePropertyName(keyName);
string keyName = value.ToString();
writer.WritePropertyName(keyName);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using Xunit;

namespace System.Text.Json.Serialization.Tests
{
public static partial class DictionaryKeyConverterTests
{
[Fact]
public static void TestDictionaryTKeyTValue() { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<Compile Include="Serialization\CustomConverterTests.Callback.cs" />
<Compile Include="Serialization\CyclicTests.cs" />
<Compile Include="Serialization\DictionaryTests.cs" />
<Compile Include="Serialization\DictionaryTests.KeyConverter.cs" />
<Compile Include="Serialization\DictionaryTests.KeyPolicy.cs" />
<Compile Include="Serialization\EnumConverterTests.cs" />
<Compile Include="Serialization\EnumTests.cs" />
Expand Down