Skip to content

Commit e7dea2a

Browse files
authored
Prototype moving JsonData to be backed by JsonDocument (#33063)
* Add WriteTo(), ==operators, and PR FB * export API * Add DocumentSentiment large JSON sample and add parse and read benchmarks * initial attempt to move to JsonElement * some fixes * updates * nit * nits * starting to experiment with changelist approach * an approach to object assignment * start working with array elements * saving changes from before break... * sm formatting pr fb * ApiView FB per generality of DynamicData * nits * small thoughts * first steps toward abstracting ChangeTracker * In flight changes while implementing AddPropertyToObject * adding tests with simple modifications to structural elements * Implementing WriteTo() * Added nested objects * refactor * missed changes * In TDD spirit, add failing WriteTo test * Test passes * quick refactor * update add property test * Update WriteTo to handle property additions at the root element * Handle property additions on arbitrary objects * handle standard property removals * Support Replace with object * Support Replace with object * refactor where we serialize structural changes to centralize * Implement reference semantics for JsonDataElement * experiment with checking ancestors for structural changes. * Update WriteTo to handle structural changes. * add high water mark logic * add validation to all reads and add failing test for ignoring pre-structural change. * Incorporate HWM logic in all change lookups; make PriorChangeToReplacedPropertyIsIgnored * remove double-check of object and array elements * some tidy up * Reimplement GetProperty in terms of TryGetProperty() * Handle WriteTo for structural changes. * add some tests of structural changes * refactor tests * Bug fix to WriteTo for bools and test refactoring * bug fix to WriteTo for booleans * Add support for nulls and fix ToLower() bug * add perf benchmark prior to working on perf * missed file * update Parse() to use Memory<byte> * move subclasses to separate files for ease of reading * refactor to add dynamic layer * Add cast operators to JsonDataElement to pass dynamic GetIntProperty test * Add support for dynamic nested property access * enable set via dynamic layer * Enable setting nested properties via dynamic layer * nit * Renames prior to dynamic refactor * start adding separate dynamic layer * Move dynamic meta object to dyanmic types. * API updates * todos and nits * rename test to match types * remove outer DynamicJson class * add BindConvert to dynamic layer * Add BindGetIndex to dynamic layer * save multitarget attempt * Add target frameworks to Experimental to allow ifdefs by target framework. * PR feedback; use more efficient Deserialize call when available in ConvertTo() * refactor per PR fb * Add BindSetIndex to dynamic layer * Fix bug in mutable ToString() where changes to descendants weren't accounted for * Fix WriteTo() bug for string elements and add failing test for handling nulls * Handle null values * PR fb * Add support for floats and longs * remove HasValue, per pr fb * export API changes * Support adding properties on dynamic member assignments * reshuffle methods around * some changes before adding support for IEnumerable * Add ArrayEnumerator to MutableJsonElement * missed file; dynamic portion not complete * Bug fix to dynamic ArrayEnumerator; foreach over array now passes * export API and misc test updates * nit; cleanup * Make MutableJsonDocument serializable * Make DynamicJson serializable; enable reference semantics for added properties * Make tests pass for net6.0 & net7.0; will address net461 separately * Fixes for some net461 issues * Fix Add and Set property for net461 * Work around BindBinaryOperation in net461; move inline TODOs to GH issue * Export API
1 parent 26ca9c3 commit e7dea2a

38 files changed

+4450
-1516
lines changed
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
namespace Azure
2+
{
3+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
4+
public readonly partial struct Value
5+
{
6+
private readonly object _dummy;
7+
private readonly int _dummyPrimitive;
8+
public Value(System.ArraySegment<byte> segment) { throw null; }
9+
public Value(System.ArraySegment<char> segment) { throw null; }
10+
public Value(bool value) { throw null; }
11+
public Value(byte value) { throw null; }
12+
public Value(char value) { throw null; }
13+
public Value(System.DateTime value) { throw null; }
14+
public Value(System.DateTimeOffset value) { throw null; }
15+
public Value(double value) { throw null; }
16+
public Value(short value) { throw null; }
17+
public Value(int value) { throw null; }
18+
public Value(long value) { throw null; }
19+
public Value(bool? value) { throw null; }
20+
public Value(byte? value) { throw null; }
21+
public Value(char? value) { throw null; }
22+
public Value(System.DateTimeOffset? value) { throw null; }
23+
public Value(System.DateTime? value) { throw null; }
24+
public Value(double? value) { throw null; }
25+
public Value(short? value) { throw null; }
26+
public Value(int? value) { throw null; }
27+
public Value(long? value) { throw null; }
28+
public Value(sbyte? value) { throw null; }
29+
public Value(float? value) { throw null; }
30+
public Value(ushort? value) { throw null; }
31+
public Value(uint? value) { throw null; }
32+
public Value(ulong? value) { throw null; }
33+
public Value(object? value) { throw null; }
34+
public Value(sbyte value) { throw null; }
35+
public Value(float value) { throw null; }
36+
public Value(ushort value) { throw null; }
37+
public Value(uint value) { throw null; }
38+
public Value(ulong value) { throw null; }
39+
public System.Type? Type { get { throw null; } }
40+
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public T As<T>() { throw null; }
41+
public static Azure.Value Create<T>(T value) { throw null; }
42+
public static explicit operator System.ArraySegment<byte> (in Azure.Value value) { throw null; }
43+
public static explicit operator System.ArraySegment<char> (in Azure.Value value) { throw null; }
44+
public static explicit operator bool (in Azure.Value value) { throw null; }
45+
public static explicit operator byte (in Azure.Value value) { throw null; }
46+
public static explicit operator char (in Azure.Value value) { throw null; }
47+
public static explicit operator System.DateTime (in Azure.Value value) { throw null; }
48+
public static explicit operator System.DateTimeOffset (in Azure.Value value) { throw null; }
49+
public static explicit operator decimal (in Azure.Value value) { throw null; }
50+
public static explicit operator double (in Azure.Value value) { throw null; }
51+
public static explicit operator short (in Azure.Value value) { throw null; }
52+
public static explicit operator int (in Azure.Value value) { throw null; }
53+
public static explicit operator long (in Azure.Value value) { throw null; }
54+
public static explicit operator bool? (in Azure.Value value) { throw null; }
55+
public static explicit operator byte? (in Azure.Value value) { throw null; }
56+
public static explicit operator char? (in Azure.Value value) { throw null; }
57+
public static explicit operator System.DateTimeOffset? (in Azure.Value value) { throw null; }
58+
public static explicit operator System.DateTime? (in Azure.Value value) { throw null; }
59+
public static explicit operator decimal? (in Azure.Value value) { throw null; }
60+
public static explicit operator double? (in Azure.Value value) { throw null; }
61+
public static explicit operator short? (in Azure.Value value) { throw null; }
62+
public static explicit operator int? (in Azure.Value value) { throw null; }
63+
public static explicit operator long? (in Azure.Value value) { throw null; }
64+
public static explicit operator sbyte? (in Azure.Value value) { throw null; }
65+
public static explicit operator float? (in Azure.Value value) { throw null; }
66+
public static explicit operator ushort? (in Azure.Value value) { throw null; }
67+
public static explicit operator uint? (in Azure.Value value) { throw null; }
68+
public static explicit operator ulong? (in Azure.Value value) { throw null; }
69+
public static explicit operator sbyte (in Azure.Value value) { throw null; }
70+
public static explicit operator float (in Azure.Value value) { throw null; }
71+
public static explicit operator ushort (in Azure.Value value) { throw null; }
72+
public static explicit operator uint (in Azure.Value value) { throw null; }
73+
public static explicit operator ulong (in Azure.Value value) { throw null; }
74+
public static implicit operator Azure.Value (System.ArraySegment<byte> value) { throw null; }
75+
public static implicit operator Azure.Value (System.ArraySegment<char> value) { throw null; }
76+
public static implicit operator Azure.Value (bool value) { throw null; }
77+
public static implicit operator Azure.Value (byte value) { throw null; }
78+
public static implicit operator Azure.Value (char value) { throw null; }
79+
public static implicit operator Azure.Value (System.DateTime value) { throw null; }
80+
public static implicit operator Azure.Value (System.DateTimeOffset value) { throw null; }
81+
public static implicit operator Azure.Value (decimal value) { throw null; }
82+
public static implicit operator Azure.Value (double value) { throw null; }
83+
public static implicit operator Azure.Value (short value) { throw null; }
84+
public static implicit operator Azure.Value (int value) { throw null; }
85+
public static implicit operator Azure.Value (long value) { throw null; }
86+
public static implicit operator Azure.Value (bool? value) { throw null; }
87+
public static implicit operator Azure.Value (byte? value) { throw null; }
88+
public static implicit operator Azure.Value (char? value) { throw null; }
89+
public static implicit operator Azure.Value (System.DateTimeOffset? value) { throw null; }
90+
public static implicit operator Azure.Value (System.DateTime? value) { throw null; }
91+
public static implicit operator Azure.Value (decimal? value) { throw null; }
92+
public static implicit operator Azure.Value (double? value) { throw null; }
93+
public static implicit operator Azure.Value (short? value) { throw null; }
94+
public static implicit operator Azure.Value (int? value) { throw null; }
95+
public static implicit operator Azure.Value (long? value) { throw null; }
96+
public static implicit operator Azure.Value (sbyte? value) { throw null; }
97+
public static implicit operator Azure.Value (float? value) { throw null; }
98+
public static implicit operator Azure.Value (ushort? value) { throw null; }
99+
public static implicit operator Azure.Value (uint? value) { throw null; }
100+
public static implicit operator Azure.Value (ulong? value) { throw null; }
101+
public static implicit operator Azure.Value (sbyte value) { throw null; }
102+
public static implicit operator Azure.Value (float value) { throw null; }
103+
public static implicit operator Azure.Value (ushort value) { throw null; }
104+
public static implicit operator Azure.Value (uint value) { throw null; }
105+
public static implicit operator Azure.Value (ulong value) { throw null; }
106+
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool TryGetValue<T>(out T value) { throw null; }
107+
}
108+
}
109+
namespace Azure.Core.Dynamic
110+
{
111+
public static partial class BinaryDataExtensions
112+
{
113+
public static dynamic ToDynamic(this System.BinaryData data) { throw null; }
114+
}
115+
public abstract partial class DynamicData
116+
{
117+
protected DynamicData() { }
118+
internal abstract void WriteTo(System.IO.Stream stream);
119+
public static void WriteTo(System.IO.Stream stream, Azure.Core.Dynamic.DynamicData data) { }
120+
}
121+
public partial class DynamicJson : Azure.Core.Dynamic.DynamicData, System.Dynamic.IDynamicMetaObjectProvider
122+
{
123+
internal DynamicJson() { }
124+
public static implicit operator bool (Azure.Core.Dynamic.DynamicJson value) { throw null; }
125+
public static implicit operator double (Azure.Core.Dynamic.DynamicJson value) { throw null; }
126+
public static implicit operator int (Azure.Core.Dynamic.DynamicJson value) { throw null; }
127+
public static implicit operator long (Azure.Core.Dynamic.DynamicJson value) { throw null; }
128+
public static implicit operator bool? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
129+
public static implicit operator double? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
130+
public static implicit operator int? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
131+
public static implicit operator long? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
132+
public static implicit operator float? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
133+
public static implicit operator float (Azure.Core.Dynamic.DynamicJson value) { throw null; }
134+
public static implicit operator string (Azure.Core.Dynamic.DynamicJson value) { throw null; }
135+
System.Dynamic.DynamicMetaObject System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(System.Linq.Expressions.Expression parameter) { throw null; }
136+
public override string ToString() { throw null; }
137+
[System.Diagnostics.DebuggerDisplayAttribute("{Current,nq}")]
138+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
139+
public partial struct ArrayEnumerator : System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.DynamicJson>, System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.DynamicJson>, System.Collections.IEnumerable, System.Collections.IEnumerator, System.IDisposable
140+
{
141+
private object _dummy;
142+
private int _dummyPrimitive;
143+
public Azure.Core.Dynamic.DynamicJson Current { get { throw null; } }
144+
object System.Collections.IEnumerator.Current { get { throw null; } }
145+
public void Dispose() { }
146+
public Azure.Core.Dynamic.DynamicJson.ArrayEnumerator GetEnumerator() { throw null; }
147+
public bool MoveNext() { throw null; }
148+
public void Reset() { }
149+
System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.DynamicJson> System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.DynamicJson>.GetEnumerator() { throw null; }
150+
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
151+
}
152+
}
153+
public partial class MutableJsonDocument
154+
{
155+
internal MutableJsonDocument() { }
156+
public Azure.Core.Dynamic.MutableJsonElement RootElement { get { throw null; } }
157+
public static Azure.Core.Dynamic.MutableJsonDocument Parse(System.BinaryData utf8Json) { throw null; }
158+
public static Azure.Core.Dynamic.MutableJsonDocument Parse(string json) { throw null; }
159+
public void WriteTo(System.IO.Stream stream, System.Buffers.StandardFormat format = default(System.Buffers.StandardFormat)) { }
160+
}
161+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
162+
public partial struct MutableJsonElement
163+
{
164+
private object _dummy;
165+
private int _dummyPrimitive;
166+
public System.Text.Json.JsonValueKind ValueKind { get { throw null; } }
167+
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator EnumerateArray() { throw null; }
168+
public bool GetBoolean() { throw null; }
169+
public double GetDouble() { throw null; }
170+
public int GetInt32() { throw null; }
171+
public long GetInt64() { throw null; }
172+
public Azure.Core.Dynamic.MutableJsonElement GetProperty(string name) { throw null; }
173+
public float GetSingle() { throw null; }
174+
public string? GetString() { throw null; }
175+
public void RemoveProperty(string name) { }
176+
public void Set(Azure.Core.Dynamic.MutableJsonElement value) { }
177+
public void Set(bool value) { }
178+
public void Set(double value) { }
179+
public void Set(int value) { }
180+
public void Set(long value) { }
181+
public void Set(object value) { }
182+
public void Set(float value) { }
183+
public void Set(string value) { }
184+
public Azure.Core.Dynamic.MutableJsonElement SetProperty(string name, object value) { throw null; }
185+
public override string ToString() { throw null; }
186+
public bool TryGetProperty(string name, out Azure.Core.Dynamic.MutableJsonElement value) { throw null; }
187+
[System.Diagnostics.DebuggerDisplayAttribute("{Current,nq}")]
188+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
189+
public partial struct ArrayEnumerator : System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.MutableJsonElement>, System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.MutableJsonElement>, System.Collections.IEnumerable, System.Collections.IEnumerator, System.IDisposable
190+
{
191+
private object _dummy;
192+
private int _dummyPrimitive;
193+
public Azure.Core.Dynamic.MutableJsonElement Current { get { throw null; } }
194+
object System.Collections.IEnumerator.Current { get { throw null; } }
195+
public void Dispose() { }
196+
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator GetEnumerator() { throw null; }
197+
public bool MoveNext() { throw null; }
198+
public void Reset() { }
199+
System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.MutableJsonElement> System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.MutableJsonElement>.GetEnumerator() { throw null; }
200+
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
201+
}
202+
}
203+
}

0 commit comments

Comments
 (0)