Skip to content

Commit

Permalink
Prototype moving JsonData to be backed by JsonDocument (#33063)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
annelo-msft authored Feb 2, 2023
1 parent 26ca9c3 commit e7dea2a
Show file tree
Hide file tree
Showing 38 changed files with 4,450 additions and 1,516 deletions.
203 changes: 203 additions & 0 deletions sdk/core/Azure.Core.Experimental/api/Azure.Core.Experimental.net461.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
namespace Azure
{
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct Value
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public Value(System.ArraySegment<byte> segment) { throw null; }
public Value(System.ArraySegment<char> segment) { throw null; }
public Value(bool value) { throw null; }
public Value(byte value) { throw null; }
public Value(char value) { throw null; }
public Value(System.DateTime value) { throw null; }
public Value(System.DateTimeOffset value) { throw null; }
public Value(double value) { throw null; }
public Value(short value) { throw null; }
public Value(int value) { throw null; }
public Value(long value) { throw null; }
public Value(bool? value) { throw null; }
public Value(byte? value) { throw null; }
public Value(char? value) { throw null; }
public Value(System.DateTimeOffset? value) { throw null; }
public Value(System.DateTime? value) { throw null; }
public Value(double? value) { throw null; }
public Value(short? value) { throw null; }
public Value(int? value) { throw null; }
public Value(long? value) { throw null; }
public Value(sbyte? value) { throw null; }
public Value(float? value) { throw null; }
public Value(ushort? value) { throw null; }
public Value(uint? value) { throw null; }
public Value(ulong? value) { throw null; }
public Value(object? value) { throw null; }
public Value(sbyte value) { throw null; }
public Value(float value) { throw null; }
public Value(ushort value) { throw null; }
public Value(uint value) { throw null; }
public Value(ulong value) { throw null; }
public System.Type? Type { get { throw null; } }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public T As<T>() { throw null; }
public static Azure.Value Create<T>(T value) { throw null; }
public static explicit operator System.ArraySegment<byte> (in Azure.Value value) { throw null; }
public static explicit operator System.ArraySegment<char> (in Azure.Value value) { throw null; }
public static explicit operator bool (in Azure.Value value) { throw null; }
public static explicit operator byte (in Azure.Value value) { throw null; }
public static explicit operator char (in Azure.Value value) { throw null; }
public static explicit operator System.DateTime (in Azure.Value value) { throw null; }
public static explicit operator System.DateTimeOffset (in Azure.Value value) { throw null; }
public static explicit operator decimal (in Azure.Value value) { throw null; }
public static explicit operator double (in Azure.Value value) { throw null; }
public static explicit operator short (in Azure.Value value) { throw null; }
public static explicit operator int (in Azure.Value value) { throw null; }
public static explicit operator long (in Azure.Value value) { throw null; }
public static explicit operator bool? (in Azure.Value value) { throw null; }
public static explicit operator byte? (in Azure.Value value) { throw null; }
public static explicit operator char? (in Azure.Value value) { throw null; }
public static explicit operator System.DateTimeOffset? (in Azure.Value value) { throw null; }
public static explicit operator System.DateTime? (in Azure.Value value) { throw null; }
public static explicit operator decimal? (in Azure.Value value) { throw null; }
public static explicit operator double? (in Azure.Value value) { throw null; }
public static explicit operator short? (in Azure.Value value) { throw null; }
public static explicit operator int? (in Azure.Value value) { throw null; }
public static explicit operator long? (in Azure.Value value) { throw null; }
public static explicit operator sbyte? (in Azure.Value value) { throw null; }
public static explicit operator float? (in Azure.Value value) { throw null; }
public static explicit operator ushort? (in Azure.Value value) { throw null; }
public static explicit operator uint? (in Azure.Value value) { throw null; }
public static explicit operator ulong? (in Azure.Value value) { throw null; }
public static explicit operator sbyte (in Azure.Value value) { throw null; }
public static explicit operator float (in Azure.Value value) { throw null; }
public static explicit operator ushort (in Azure.Value value) { throw null; }
public static explicit operator uint (in Azure.Value value) { throw null; }
public static explicit operator ulong (in Azure.Value value) { throw null; }
public static implicit operator Azure.Value (System.ArraySegment<byte> value) { throw null; }
public static implicit operator Azure.Value (System.ArraySegment<char> value) { throw null; }
public static implicit operator Azure.Value (bool value) { throw null; }
public static implicit operator Azure.Value (byte value) { throw null; }
public static implicit operator Azure.Value (char value) { throw null; }
public static implicit operator Azure.Value (System.DateTime value) { throw null; }
public static implicit operator Azure.Value (System.DateTimeOffset value) { throw null; }
public static implicit operator Azure.Value (decimal value) { throw null; }
public static implicit operator Azure.Value (double value) { throw null; }
public static implicit operator Azure.Value (short value) { throw null; }
public static implicit operator Azure.Value (int value) { throw null; }
public static implicit operator Azure.Value (long value) { throw null; }
public static implicit operator Azure.Value (bool? value) { throw null; }
public static implicit operator Azure.Value (byte? value) { throw null; }
public static implicit operator Azure.Value (char? value) { throw null; }
public static implicit operator Azure.Value (System.DateTimeOffset? value) { throw null; }
public static implicit operator Azure.Value (System.DateTime? value) { throw null; }
public static implicit operator Azure.Value (decimal? value) { throw null; }
public static implicit operator Azure.Value (double? value) { throw null; }
public static implicit operator Azure.Value (short? value) { throw null; }
public static implicit operator Azure.Value (int? value) { throw null; }
public static implicit operator Azure.Value (long? value) { throw null; }
public static implicit operator Azure.Value (sbyte? value) { throw null; }
public static implicit operator Azure.Value (float? value) { throw null; }
public static implicit operator Azure.Value (ushort? value) { throw null; }
public static implicit operator Azure.Value (uint? value) { throw null; }
public static implicit operator Azure.Value (ulong? value) { throw null; }
public static implicit operator Azure.Value (sbyte value) { throw null; }
public static implicit operator Azure.Value (float value) { throw null; }
public static implicit operator Azure.Value (ushort value) { throw null; }
public static implicit operator Azure.Value (uint value) { throw null; }
public static implicit operator Azure.Value (ulong value) { throw null; }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool TryGetValue<T>(out T value) { throw null; }
}
}
namespace Azure.Core.Dynamic
{
public static partial class BinaryDataExtensions
{
public static dynamic ToDynamic(this System.BinaryData data) { throw null; }
}
public abstract partial class DynamicData
{
protected DynamicData() { }
internal abstract void WriteTo(System.IO.Stream stream);
public static void WriteTo(System.IO.Stream stream, Azure.Core.Dynamic.DynamicData data) { }
}
public partial class DynamicJson : Azure.Core.Dynamic.DynamicData, System.Dynamic.IDynamicMetaObjectProvider
{
internal DynamicJson() { }
public static implicit operator bool (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator double (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator int (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator long (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator bool? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator double? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator int? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator long? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator float? (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator float (Azure.Core.Dynamic.DynamicJson value) { throw null; }
public static implicit operator string (Azure.Core.Dynamic.DynamicJson value) { throw null; }
System.Dynamic.DynamicMetaObject System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(System.Linq.Expressions.Expression parameter) { throw null; }
public override string ToString() { throw null; }
[System.Diagnostics.DebuggerDisplayAttribute("{Current,nq}")]
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
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
{
private object _dummy;
private int _dummyPrimitive;
public Azure.Core.Dynamic.DynamicJson Current { get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
public void Dispose() { }
public Azure.Core.Dynamic.DynamicJson.ArrayEnumerator GetEnumerator() { throw null; }
public bool MoveNext() { throw null; }
public void Reset() { }
System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.DynamicJson> System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.DynamicJson>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
}
public partial class MutableJsonDocument
{
internal MutableJsonDocument() { }
public Azure.Core.Dynamic.MutableJsonElement RootElement { get { throw null; } }
public static Azure.Core.Dynamic.MutableJsonDocument Parse(System.BinaryData utf8Json) { throw null; }
public static Azure.Core.Dynamic.MutableJsonDocument Parse(string json) { throw null; }
public void WriteTo(System.IO.Stream stream, System.Buffers.StandardFormat format = default(System.Buffers.StandardFormat)) { }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct MutableJsonElement
{
private object _dummy;
private int _dummyPrimitive;
public System.Text.Json.JsonValueKind ValueKind { get { throw null; } }
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator EnumerateArray() { throw null; }
public bool GetBoolean() { throw null; }
public double GetDouble() { throw null; }
public int GetInt32() { throw null; }
public long GetInt64() { throw null; }
public Azure.Core.Dynamic.MutableJsonElement GetProperty(string name) { throw null; }
public float GetSingle() { throw null; }
public string? GetString() { throw null; }
public void RemoveProperty(string name) { }
public void Set(Azure.Core.Dynamic.MutableJsonElement value) { }
public void Set(bool value) { }
public void Set(double value) { }
public void Set(int value) { }
public void Set(long value) { }
public void Set(object value) { }
public void Set(float value) { }
public void Set(string value) { }
public Azure.Core.Dynamic.MutableJsonElement SetProperty(string name, object value) { throw null; }
public override string ToString() { throw null; }
public bool TryGetProperty(string name, out Azure.Core.Dynamic.MutableJsonElement value) { throw null; }
[System.Diagnostics.DebuggerDisplayAttribute("{Current,nq}")]
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
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
{
private object _dummy;
private int _dummyPrimitive;
public Azure.Core.Dynamic.MutableJsonElement Current { get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
public void Dispose() { }
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator GetEnumerator() { throw null; }
public bool MoveNext() { throw null; }
public void Reset() { }
System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.MutableJsonElement> System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.MutableJsonElement>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
}
}
Loading

0 comments on commit e7dea2a

Please sign in to comment.