Skip to content

Commit 20c9a70

Browse files
committed
Review updates
1 parent 09e9435 commit 20c9a70

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

Diff for: src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs

+19-1
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,36 @@ private static ValueComparer CreateStringDictionaryComparer(
168168

169169
// This ensures that the element reader/writers are not null when using Cosmos dictionary type mappings, but
170170
// is never actually used because Cosmos does not (yet) read and write JSON using this mechanism.
171+
/// <summary>
172+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
173+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
174+
/// any release. You should only use it directly in your code with extreme caution and knowing that
175+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
176+
/// </summary>
171177
#pragma warning disable EF1001
172-
private sealed class PlaceholderJsonStringKeyedDictionaryReaderWriter<TElement>(JsonValueReaderWriter elementReaderWriter)
178+
public sealed class PlaceholderJsonStringKeyedDictionaryReaderWriter<TElement>(JsonValueReaderWriter elementReaderWriter)
173179
: JsonValueReaderWriter<IEnumerable<KeyValuePair<string, TElement>>>, ICompositeJsonValueReaderWriter
174180
#pragma warning restore EF1001
175181
{
176182
private readonly JsonValueReaderWriter<TElement> _elementReaderWriter = (JsonValueReaderWriter<TElement>)elementReaderWriter;
177183

184+
/// <summary>
185+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
186+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
187+
/// any release. You should only use it directly in your code with extreme caution and knowing that
188+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
189+
/// </summary>
178190
public override IEnumerable<KeyValuePair<string, TElement>> FromJsonTyped(
179191
ref Utf8JsonReaderManager manager,
180192
object? existingObject = null)
181193
=> throw new NotImplementedException("JsonValueReaderWriter infrastructure is not supported on Cosmos.");
182194

195+
/// <summary>
196+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
197+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
198+
/// any release. You should only use it directly in your code with extreme caution and knowing that
199+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
200+
/// </summary>
183201
public override void ToJsonTyped(Utf8JsonWriter writer, IEnumerable<KeyValuePair<string, TElement>> value)
184202
=> throw new NotImplementedException("JsonValueReaderWriter infrastructure is not supported on Cosmos.");
185203

Diff for: test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs

+35-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public virtual Task Basic_cosmos_model()
2929
eb.HasPartitionKey("PartitionId");
3030
eb.HasKey("Id", "PartitionId");
3131
eb.ToContainer("DataContainer");
32+
eb.Property<Dictionary<string, string[]>>("Map");
33+
eb.Property<List<Dictionary<string, int>>>("List");
3234
eb.UseETagConcurrency();
3335
eb.HasNoDiscriminator();
3436
eb.Property(d => d.Blob).ToJsonProperty("JsonBlob");
@@ -94,6 +96,38 @@ public virtual Task Basic_cosmos_model()
9496
Assert.NotNull(partitionId.GetValueComparer());
9597
Assert.NotNull(partitionId.GetKeyValueComparer());
9698

99+
var map = dataEntity.FindProperty("Map")!;
100+
Assert.Equal(typeof(Dictionary<string, string[]>), map.ClrType);
101+
Assert.Null(map.PropertyInfo);
102+
Assert.Null(map.FieldInfo);
103+
Assert.True(map.IsNullable);
104+
Assert.False(map.IsConcurrencyToken);
105+
Assert.False(map.IsPrimitiveCollection);
106+
Assert.Equal(ValueGenerated.Never, map.ValueGenerated);
107+
Assert.Equal(PropertySaveBehavior.Save, map.GetAfterSaveBehavior());
108+
Assert.Equal(PropertySaveBehavior.Save, map.GetBeforeSaveBehavior());
109+
Assert.Equal("Map", CosmosPropertyExtensions.GetJsonPropertyName(map));
110+
Assert.Null(map.GetValueGeneratorFactory());
111+
Assert.Null(map.GetValueConverter());
112+
Assert.NotNull(map.GetValueComparer());
113+
Assert.NotNull(map.GetKeyValueComparer());
114+
115+
var list = dataEntity.FindProperty("List")!;
116+
Assert.Equal(typeof(List<Dictionary<string, int>>), list.ClrType);
117+
Assert.Null(list.PropertyInfo);
118+
Assert.Null(list.FieldInfo);
119+
Assert.True(list.IsNullable);
120+
Assert.False(list.IsConcurrencyToken);
121+
Assert.False(list.IsPrimitiveCollection);
122+
Assert.Equal(ValueGenerated.Never, list.ValueGenerated);
123+
Assert.Equal(PropertySaveBehavior.Save, list.GetAfterSaveBehavior());
124+
Assert.Equal(PropertySaveBehavior.Save, list.GetBeforeSaveBehavior());
125+
Assert.Equal("List", CosmosPropertyExtensions.GetJsonPropertyName(list));
126+
Assert.Null(list.GetValueGeneratorFactory());
127+
Assert.Null(list.GetValueConverter());
128+
Assert.NotNull(list.GetValueComparer());
129+
Assert.NotNull(list.GetKeyValueComparer());
130+
97131
var eTag = dataEntity.FindProperty("_etag")!;
98132
Assert.Equal(typeof(string), eTag.ClrType);
99133
Assert.Null(eTag.PropertyInfo);
@@ -143,7 +177,7 @@ public virtual Task Basic_cosmos_model()
143177

144178
Assert.Equal(2, dataEntity.GetKeys().Count());
145179

146-
Assert.Equal([id, partitionId, blob, storeId, jObject, eTag], dataEntity.GetProperties());
180+
Assert.Equal([id, partitionId, blob, list, map, storeId, jObject, eTag], dataEntity.GetProperties());
147181
});
148182

149183
protected override void BuildBigModel(ModelBuilder modelBuilder, bool jsonColumns)

0 commit comments

Comments
 (0)