Skip to content

Commit 748b34e

Browse files
authored
MutableJsonDocument namespace, IDisposable (#34126)
* move MutableJsonDocument and related to Azure.Core.Json namespace * Make MutableJsonDocument disposable * Make DynamicJson disposable * Add tests and update API listings * PR fb * Update namespace in perf project
1 parent dfc75e5 commit 748b34e

19 files changed

+184
-81
lines changed

sdk/core/Azure.Core.Experimental/api/Azure.Core.Experimental.net461.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ protected DynamicData() { }
118118
internal abstract void WriteTo(System.IO.Stream stream);
119119
public static void WriteTo(System.IO.Stream stream, Azure.Core.Dynamic.DynamicData data) { }
120120
}
121-
public partial class DynamicJson : Azure.Core.Dynamic.DynamicData, System.Dynamic.IDynamicMetaObjectProvider
121+
public sealed partial class DynamicJson : Azure.Core.Dynamic.DynamicData, System.Dynamic.IDynamicMetaObjectProvider, System.IDisposable
122122
{
123123
internal DynamicJson() { }
124+
public void Dispose() { }
124125
public static implicit operator bool (Azure.Core.Dynamic.DynamicJson value) { throw null; }
125126
public static implicit operator double (Azure.Core.Dynamic.DynamicJson value) { throw null; }
126127
public static implicit operator int (Azure.Core.Dynamic.DynamicJson value) { throw null; }
@@ -150,53 +151,57 @@ public void Reset() { }
150151
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
151152
}
152153
}
153-
public partial class MutableJsonDocument
154+
}
155+
namespace Azure.Core.Json
156+
{
157+
public sealed partial class MutableJsonDocument : System.IDisposable
154158
{
155159
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; }
160+
public Azure.Core.Json.MutableJsonElement RootElement { get { throw null; } }
161+
public void Dispose() { }
162+
public static Azure.Core.Json.MutableJsonDocument Parse(System.BinaryData utf8Json) { throw null; }
163+
public static Azure.Core.Json.MutableJsonDocument Parse(string json) { throw null; }
159164
public void WriteTo(System.IO.Stream stream, System.Buffers.StandardFormat format = default(System.Buffers.StandardFormat)) { }
160165
}
161166
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
162-
public partial struct MutableJsonElement
167+
public readonly partial struct MutableJsonElement
163168
{
164-
private object _dummy;
165-
private int _dummyPrimitive;
169+
private readonly object _dummy;
170+
private readonly int _dummyPrimitive;
166171
public System.Text.Json.JsonValueKind ValueKind { get { throw null; } }
167-
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator EnumerateArray() { throw null; }
172+
public Azure.Core.Json.MutableJsonElement.ArrayEnumerator EnumerateArray() { throw null; }
168173
public bool GetBoolean() { throw null; }
169174
public double GetDouble() { throw null; }
170175
public int GetInt32() { throw null; }
171176
public long GetInt64() { throw null; }
172-
public Azure.Core.Dynamic.MutableJsonElement GetProperty(string name) { throw null; }
177+
public Azure.Core.Json.MutableJsonElement GetProperty(string name) { throw null; }
173178
public float GetSingle() { throw null; }
174179
public string? GetString() { throw null; }
175180
public void RemoveProperty(string name) { }
176-
public void Set(Azure.Core.Dynamic.MutableJsonElement value) { }
181+
public void Set(Azure.Core.Json.MutableJsonElement value) { }
177182
public void Set(bool value) { }
178183
public void Set(double value) { }
179184
public void Set(int value) { }
180185
public void Set(long value) { }
181186
public void Set(object value) { }
182187
public void Set(float value) { }
183188
public void Set(string value) { }
184-
public Azure.Core.Dynamic.MutableJsonElement SetProperty(string name, object value) { throw null; }
189+
public Azure.Core.Json.MutableJsonElement SetProperty(string name, object value) { throw null; }
185190
public override string ToString() { throw null; }
186-
public bool TryGetProperty(string name, out Azure.Core.Dynamic.MutableJsonElement value) { throw null; }
191+
public bool TryGetProperty(string name, out Azure.Core.Json.MutableJsonElement value) { throw null; }
187192
[System.Diagnostics.DebuggerDisplayAttribute("{Current,nq}")]
188193
[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
194+
public partial struct ArrayEnumerator : System.Collections.Generic.IEnumerable<Azure.Core.Json.MutableJsonElement>, System.Collections.Generic.IEnumerator<Azure.Core.Json.MutableJsonElement>, System.Collections.IEnumerable, System.Collections.IEnumerator, System.IDisposable
190195
{
191196
private object _dummy;
192197
private int _dummyPrimitive;
193-
public Azure.Core.Dynamic.MutableJsonElement Current { get { throw null; } }
198+
public Azure.Core.Json.MutableJsonElement Current { get { throw null; } }
194199
object System.Collections.IEnumerator.Current { get { throw null; } }
195200
public void Dispose() { }
196-
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator GetEnumerator() { throw null; }
201+
public Azure.Core.Json.MutableJsonElement.ArrayEnumerator GetEnumerator() { throw null; }
197202
public bool MoveNext() { throw null; }
198203
public void Reset() { }
199-
System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.MutableJsonElement> System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.MutableJsonElement>.GetEnumerator() { throw null; }
204+
System.Collections.Generic.IEnumerator<Azure.Core.Json.MutableJsonElement> System.Collections.Generic.IEnumerable<Azure.Core.Json.MutableJsonElement>.GetEnumerator() { throw null; }
200205
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
201206
}
202207
}

sdk/core/Azure.Core.Experimental/api/Azure.Core.Experimental.net6.0.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ protected DynamicData() { }
118118
internal abstract void WriteTo(System.IO.Stream stream);
119119
public static void WriteTo(System.IO.Stream stream, Azure.Core.Dynamic.DynamicData data) { }
120120
}
121-
public partial class DynamicJson : Azure.Core.Dynamic.DynamicData, System.Dynamic.IDynamicMetaObjectProvider
121+
public sealed partial class DynamicJson : Azure.Core.Dynamic.DynamicData, System.Dynamic.IDynamicMetaObjectProvider, System.IDisposable
122122
{
123123
internal DynamicJson() { }
124+
public void Dispose() { }
124125
public static implicit operator bool (Azure.Core.Dynamic.DynamicJson value) { throw null; }
125126
public static implicit operator double (Azure.Core.Dynamic.DynamicJson value) { throw null; }
126127
public static implicit operator int (Azure.Core.Dynamic.DynamicJson value) { throw null; }
@@ -150,53 +151,57 @@ public void Reset() { }
150151
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
151152
}
152153
}
153-
public partial class MutableJsonDocument
154+
}
155+
namespace Azure.Core.Json
156+
{
157+
public sealed partial class MutableJsonDocument : System.IDisposable
154158
{
155159
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; }
160+
public Azure.Core.Json.MutableJsonElement RootElement { get { throw null; } }
161+
public void Dispose() { }
162+
public static Azure.Core.Json.MutableJsonDocument Parse(System.BinaryData utf8Json) { throw null; }
163+
public static Azure.Core.Json.MutableJsonDocument Parse(string json) { throw null; }
159164
public void WriteTo(System.IO.Stream stream, System.Buffers.StandardFormat format = default(System.Buffers.StandardFormat)) { }
160165
}
161166
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
162-
public partial struct MutableJsonElement
167+
public readonly partial struct MutableJsonElement
163168
{
164-
private object _dummy;
165-
private int _dummyPrimitive;
169+
private readonly object _dummy;
170+
private readonly int _dummyPrimitive;
166171
public System.Text.Json.JsonValueKind ValueKind { get { throw null; } }
167-
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator EnumerateArray() { throw null; }
172+
public Azure.Core.Json.MutableJsonElement.ArrayEnumerator EnumerateArray() { throw null; }
168173
public bool GetBoolean() { throw null; }
169174
public double GetDouble() { throw null; }
170175
public int GetInt32() { throw null; }
171176
public long GetInt64() { throw null; }
172-
public Azure.Core.Dynamic.MutableJsonElement GetProperty(string name) { throw null; }
177+
public Azure.Core.Json.MutableJsonElement GetProperty(string name) { throw null; }
173178
public float GetSingle() { throw null; }
174179
public string? GetString() { throw null; }
175180
public void RemoveProperty(string name) { }
176-
public void Set(Azure.Core.Dynamic.MutableJsonElement value) { }
181+
public void Set(Azure.Core.Json.MutableJsonElement value) { }
177182
public void Set(bool value) { }
178183
public void Set(double value) { }
179184
public void Set(int value) { }
180185
public void Set(long value) { }
181186
public void Set(object value) { }
182187
public void Set(float value) { }
183188
public void Set(string value) { }
184-
public Azure.Core.Dynamic.MutableJsonElement SetProperty(string name, object value) { throw null; }
189+
public Azure.Core.Json.MutableJsonElement SetProperty(string name, object value) { throw null; }
185190
public override string ToString() { throw null; }
186-
public bool TryGetProperty(string name, out Azure.Core.Dynamic.MutableJsonElement value) { throw null; }
191+
public bool TryGetProperty(string name, out Azure.Core.Json.MutableJsonElement value) { throw null; }
187192
[System.Diagnostics.DebuggerDisplayAttribute("{Current,nq}")]
188193
[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
194+
public partial struct ArrayEnumerator : System.Collections.Generic.IEnumerable<Azure.Core.Json.MutableJsonElement>, System.Collections.Generic.IEnumerator<Azure.Core.Json.MutableJsonElement>, System.Collections.IEnumerable, System.Collections.IEnumerator, System.IDisposable
190195
{
191196
private object _dummy;
192197
private int _dummyPrimitive;
193-
public Azure.Core.Dynamic.MutableJsonElement Current { get { throw null; } }
198+
public Azure.Core.Json.MutableJsonElement Current { get { throw null; } }
194199
object System.Collections.IEnumerator.Current { get { throw null; } }
195200
public void Dispose() { }
196-
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator GetEnumerator() { throw null; }
201+
public Azure.Core.Json.MutableJsonElement.ArrayEnumerator GetEnumerator() { throw null; }
197202
public bool MoveNext() { throw null; }
198203
public void Reset() { }
199-
System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.MutableJsonElement> System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.MutableJsonElement>.GetEnumerator() { throw null; }
204+
System.Collections.Generic.IEnumerator<Azure.Core.Json.MutableJsonElement> System.Collections.Generic.IEnumerable<Azure.Core.Json.MutableJsonElement>.GetEnumerator() { throw null; }
200205
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
201206
}
202207
}

sdk/core/Azure.Core.Experimental/api/Azure.Core.Experimental.netstandard2.0.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ protected DynamicData() { }
118118
internal abstract void WriteTo(System.IO.Stream stream);
119119
public static void WriteTo(System.IO.Stream stream, Azure.Core.Dynamic.DynamicData data) { }
120120
}
121-
public partial class DynamicJson : Azure.Core.Dynamic.DynamicData, System.Dynamic.IDynamicMetaObjectProvider
121+
public sealed partial class DynamicJson : Azure.Core.Dynamic.DynamicData, System.Dynamic.IDynamicMetaObjectProvider, System.IDisposable
122122
{
123123
internal DynamicJson() { }
124+
public void Dispose() { }
124125
public static implicit operator bool (Azure.Core.Dynamic.DynamicJson value) { throw null; }
125126
public static implicit operator double (Azure.Core.Dynamic.DynamicJson value) { throw null; }
126127
public static implicit operator int (Azure.Core.Dynamic.DynamicJson value) { throw null; }
@@ -150,53 +151,57 @@ public void Reset() { }
150151
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
151152
}
152153
}
153-
public partial class MutableJsonDocument
154+
}
155+
namespace Azure.Core.Json
156+
{
157+
public sealed partial class MutableJsonDocument : System.IDisposable
154158
{
155159
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; }
160+
public Azure.Core.Json.MutableJsonElement RootElement { get { throw null; } }
161+
public void Dispose() { }
162+
public static Azure.Core.Json.MutableJsonDocument Parse(System.BinaryData utf8Json) { throw null; }
163+
public static Azure.Core.Json.MutableJsonDocument Parse(string json) { throw null; }
159164
public void WriteTo(System.IO.Stream stream, System.Buffers.StandardFormat format = default(System.Buffers.StandardFormat)) { }
160165
}
161166
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
162-
public partial struct MutableJsonElement
167+
public readonly partial struct MutableJsonElement
163168
{
164-
private object _dummy;
165-
private int _dummyPrimitive;
169+
private readonly object _dummy;
170+
private readonly int _dummyPrimitive;
166171
public System.Text.Json.JsonValueKind ValueKind { get { throw null; } }
167-
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator EnumerateArray() { throw null; }
172+
public Azure.Core.Json.MutableJsonElement.ArrayEnumerator EnumerateArray() { throw null; }
168173
public bool GetBoolean() { throw null; }
169174
public double GetDouble() { throw null; }
170175
public int GetInt32() { throw null; }
171176
public long GetInt64() { throw null; }
172-
public Azure.Core.Dynamic.MutableJsonElement GetProperty(string name) { throw null; }
177+
public Azure.Core.Json.MutableJsonElement GetProperty(string name) { throw null; }
173178
public float GetSingle() { throw null; }
174179
public string? GetString() { throw null; }
175180
public void RemoveProperty(string name) { }
176-
public void Set(Azure.Core.Dynamic.MutableJsonElement value) { }
181+
public void Set(Azure.Core.Json.MutableJsonElement value) { }
177182
public void Set(bool value) { }
178183
public void Set(double value) { }
179184
public void Set(int value) { }
180185
public void Set(long value) { }
181186
public void Set(object value) { }
182187
public void Set(float value) { }
183188
public void Set(string value) { }
184-
public Azure.Core.Dynamic.MutableJsonElement SetProperty(string name, object value) { throw null; }
189+
public Azure.Core.Json.MutableJsonElement SetProperty(string name, object value) { throw null; }
185190
public override string ToString() { throw null; }
186-
public bool TryGetProperty(string name, out Azure.Core.Dynamic.MutableJsonElement value) { throw null; }
191+
public bool TryGetProperty(string name, out Azure.Core.Json.MutableJsonElement value) { throw null; }
187192
[System.Diagnostics.DebuggerDisplayAttribute("{Current,nq}")]
188193
[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
194+
public partial struct ArrayEnumerator : System.Collections.Generic.IEnumerable<Azure.Core.Json.MutableJsonElement>, System.Collections.Generic.IEnumerator<Azure.Core.Json.MutableJsonElement>, System.Collections.IEnumerable, System.Collections.IEnumerator, System.IDisposable
190195
{
191196
private object _dummy;
192197
private int _dummyPrimitive;
193-
public Azure.Core.Dynamic.MutableJsonElement Current { get { throw null; } }
198+
public Azure.Core.Json.MutableJsonElement Current { get { throw null; } }
194199
object System.Collections.IEnumerator.Current { get { throw null; } }
195200
public void Dispose() { }
196-
public Azure.Core.Dynamic.MutableJsonElement.ArrayEnumerator GetEnumerator() { throw null; }
201+
public Azure.Core.Json.MutableJsonElement.ArrayEnumerator GetEnumerator() { throw null; }
197202
public bool MoveNext() { throw null; }
198203
public void Reset() { }
199-
System.Collections.Generic.IEnumerator<Azure.Core.Dynamic.MutableJsonElement> System.Collections.Generic.IEnumerable<Azure.Core.Dynamic.MutableJsonElement>.GetEnumerator() { throw null; }
204+
System.Collections.Generic.IEnumerator<Azure.Core.Json.MutableJsonElement> System.Collections.Generic.IEnumerable<Azure.Core.Json.MutableJsonElement>.GetEnumerator() { throw null; }
200205
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
201206
}
202207
}

sdk/core/Azure.Core.Experimental/src/BinaryDataExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
using Azure.Core.Json;
56

67
namespace Azure.Core.Dynamic
78
{

sdk/core/Azure.Core.Experimental/src/DynamicJson.ArrayEnumerator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections;
55
using System.Collections.Generic;
66
using System.Diagnostics;
7+
using Azure.Core.Json;
78

89
namespace Azure.Core.Dynamic
910
{

0 commit comments

Comments
 (0)