-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Update JsonData in Experimental #32613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
305c51c
9e3f2e2
32d1970
0eff1da
43cd339
d394764
d196588
be4cc72
4fe4d95
7ac745b
d638359
cc1de18
a2b2fc5
eb74ae2
3f1adb9
c4ebd66
17f842b
1766a04
fa019d9
a0ed823
f2864fc
4f714bb
b13740f
1b5df72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,91 +106,39 @@ public readonly partial struct Value | |
| [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]public bool TryGetValue<T>(out T value) { throw null; } | ||
| } | ||
| } | ||
| namespace Azure.Core | ||
| namespace Azure.Core.Dynamic | ||
| { | ||
| public static partial class BinaryDataExtensions | ||
| { | ||
| public static dynamic ToDynamic(this System.BinaryData data) { throw null; } | ||
| } | ||
| [System.Diagnostics.DebuggerDisplayAttribute("{DebuggerDisplay,nq}")] | ||
| public partial class JsonData : System.Dynamic.IDynamicMetaObjectProvider, System.IEquatable<Azure.Core.JsonData> | ||
| public partial class JsonData : System.Dynamic.IDynamicMetaObjectProvider, System.IEquatable<Azure.Core.Dynamic.JsonData> | ||
| { | ||
| public JsonData() { } | ||
| public JsonData(object? value) { } | ||
| public JsonData(object? value, System.Text.Json.JsonSerializerOptions options, System.Type? type = null) { } | ||
| public JsonData(System.Text.Json.JsonDocument jsonDocument) { } | ||
| public Azure.Core.JsonData this[int arrayIndex] { get { throw null; } set { } } | ||
| public Azure.Core.JsonData this[string propertyName] { get { throw null; } set { } } | ||
| public System.Collections.Generic.IEnumerable<Azure.Core.JsonData> Items { get { throw null; } } | ||
| public System.Text.Json.JsonValueKind Kind { get { throw null; } } | ||
| public int Length { get { throw null; } } | ||
| public System.Collections.Generic.IEnumerable<string> Properties { get { throw null; } } | ||
| public void Add(bool value) { } | ||
| public void Add(double value) { } | ||
| public void Add(int value) { } | ||
| public void Add(long value) { } | ||
| public Azure.Core.JsonData Add(object? serializable) { throw null; } | ||
| public Azure.Core.JsonData Add(object? serializable, System.Text.Json.JsonSerializerOptions options) { throw null; } | ||
| public void Add(float value) { } | ||
| public void Add(string? value) { } | ||
| public Azure.Core.JsonData AddEmptyArray() { throw null; } | ||
| public Azure.Core.JsonData AddEmptyObject() { throw null; } | ||
| public Azure.Core.JsonData Add<T>(T[] serializable) { throw null; } | ||
| public Azure.Core.JsonData Add<T>(T[] serializable, System.Text.Json.JsonSerializerOptions options) { throw null; } | ||
| public static Azure.Core.JsonData EmptyArray() { throw null; } | ||
| public static Azure.Core.JsonData EmptyObject() { throw null; } | ||
| public bool Equals(Azure.Core.JsonData other) { throw null; } | ||
| internal JsonData() { } | ||
| public bool Equals(Azure.Core.Dynamic.JsonData other) { throw null; } | ||
| public override bool Equals(object? obj) { throw null; } | ||
| public static Azure.Core.JsonData FromBytes(byte[] utf8Json) { throw null; } | ||
| public static Azure.Core.JsonData FromBytes(System.ReadOnlyMemory<byte> utf8Json) { throw null; } | ||
| public static Azure.Core.JsonData FromObject<T>(T value, System.Text.Json.JsonSerializerOptions? options = null) { throw null; } | ||
| public static Azure.Core.JsonData FromStream(System.IO.Stream utf8Json) { throw null; } | ||
| public static System.Threading.Tasks.Task<Azure.Core.JsonData> FromStreamAsync(System.IO.Stream utf8JsonStream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } | ||
| public static Azure.Core.JsonData FromString(string json) { throw null; } | ||
| public Azure.Core.JsonData? Get(string propertyName) { throw null; } | ||
| public override int GetHashCode() { throw null; } | ||
| public T Get<T>(string propertyName) { throw null; } | ||
| public T Get<T>(string propertyName, System.Text.Json.JsonSerializerOptions options) { throw null; } | ||
| public static bool operator ==(Azure.Core.JsonData? left, string? right) { throw null; } | ||
| public static bool operator ==(string? left, Azure.Core.JsonData? right) { throw null; } | ||
| public static explicit operator bool (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator double (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator int (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator long (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator bool? (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator double? (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator int? (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator long? (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator float? (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator float (Azure.Core.JsonData json) { throw null; } | ||
| public static explicit operator string (Azure.Core.JsonData json) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (bool value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (double value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (int value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (long value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (bool? value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (double? value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (int? value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (long? value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (float? value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (float value) { throw null; } | ||
| public static implicit operator Azure.Core.JsonData (string? value) { throw null; } | ||
| public static bool operator !=(Azure.Core.JsonData? left, string? right) { throw null; } | ||
| public static bool operator !=(string? left, Azure.Core.JsonData? right) { throw null; } | ||
| public void Set(string propertyName, bool value) { } | ||
| public void Set(string propertyName, double value) { } | ||
| public void Set(string propertyName, int value) { } | ||
| public void Set(string propertyName, long value) { } | ||
| public Azure.Core.JsonData Set(string propertyName, object? serializable) { throw null; } | ||
| public Azure.Core.JsonData Set(string propertyName, object? serializable, System.Text.Json.JsonSerializerOptions options) { throw null; } | ||
| public void Set(string propertyName, float value) { } | ||
| public void Set(string propertyName, string? value) { } | ||
| public Azure.Core.JsonData SetEmptyArray(string propertyName) { throw null; } | ||
| public Azure.Core.JsonData SetEmptyObject(string propertyName) { throw null; } | ||
| public Azure.Core.JsonData Set<T>(string propertyName, T[] serializable) { throw null; } | ||
| public Azure.Core.JsonData Set<T>(string propertyName, T[] serializable, System.Text.Json.JsonSerializerOptions options) { throw null; } | ||
| public static bool operator ==(Azure.Core.Dynamic.JsonData? left, int right) { throw null; } | ||
annelo-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public static bool operator ==(Azure.Core.Dynamic.JsonData? left, string? right) { throw null; } | ||
| public static bool operator ==(int left, Azure.Core.Dynamic.JsonData? right) { throw null; } | ||
| public static bool operator ==(string? left, Azure.Core.Dynamic.JsonData? right) { throw null; } | ||
| public static implicit operator bool (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator double (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator int (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator long (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator bool? (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator double? (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator int? (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator long? (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator float? (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator float (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static implicit operator string (Azure.Core.Dynamic.JsonData json) { throw null; } | ||
| public static bool operator !=(Azure.Core.Dynamic.JsonData? left, int right) { throw null; } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we want equality operators for the same set of primitives that we have the casts for?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These will be addressed in a follow-up PR. My goal was to merge this to make something available early for CloudMachine to start working with. |
||
| public static bool operator !=(Azure.Core.Dynamic.JsonData? left, string? right) { throw null; } | ||
| public static bool operator !=(int left, Azure.Core.Dynamic.JsonData? right) { throw null; } | ||
| public static bool operator !=(string? left, Azure.Core.Dynamic.JsonData? right) { throw null; } | ||
| System.Dynamic.DynamicMetaObject System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(System.Linq.Expressions.Expression parameter) { throw null; } | ||
| public string ToJsonString() { throw null; } | ||
| public override string ToString() { throw null; } | ||
| public T To<T>() { throw null; } | ||
| public T To<T>(System.Text.Json.JsonSerializerOptions options) { throw null; } | ||
| public long WriteTo(System.IO.Stream stream) { throw null; } | ||
| public System.Threading.Tasks.Task<long> WriteToAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) { throw null; } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
|
|
||
| namespace Azure.Core.Dynamic | ||
| { | ||
| /// <summary> | ||
| /// Extensions to BinaryData. | ||
| /// </summary> | ||
| public static class BinaryDataExtensions | ||
| { | ||
| /// <summary> | ||
annelo-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// </summary> | ||
| public static dynamic ToDynamic(this BinaryData data) | ||
| { | ||
| return JsonData.Parse(data); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Dynamic; | ||
| using System.Text.Json; | ||
|
|
||
| namespace Azure.Core.Dynamic | ||
| { | ||
| /// <summary> | ||
| /// A mutable representation of a JSON value. | ||
| /// </summary> | ||
| public partial class JsonData : IDynamicMetaObjectProvider, IEquatable<JsonData> | ||
annelo-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| /// <summary> | ||
| /// Converts the value to a <see cref="bool"/> | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator bool(JsonData json) => json.GetBoolean(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="int"/> | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator int(JsonData json) => json.GetInt32(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="long"/> | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator long(JsonData json) => json.GetLong(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="string"/> | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator string?(JsonData json) => json.GetString(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="float"/> | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator float(JsonData json) => json.GetFloat(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="double"/> | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator double(JsonData json) => json.GetDouble(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="bool"/> | ||
annelo-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator bool?(JsonData json) => json.Kind == JsonValueKind.Null ? null : json.GetBoolean(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="int"/> or null. | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator int?(JsonData json) => json.Kind == JsonValueKind.Null ? null : json.GetInt32(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="long"/> or null. | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator long?(JsonData json) => json.Kind == JsonValueKind.Null ? null : json.GetLong(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="float"/> or null. | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator float?(JsonData json) => json.Kind == JsonValueKind.Null ? null : json.GetFloat(); | ||
|
|
||
| /// <summary> | ||
| /// Converts the value to a <see cref="double"/> or null. | ||
| /// </summary> | ||
| /// <param name="json">The value to convert.</param> | ||
| public static implicit operator double?(JsonData json) => json.Kind == JsonValueKind.Null ? null : json.GetDouble(); | ||
|
|
||
| /// <summary> | ||
| /// Returns true if a <see cref="JsonData"/> has the same value as a given string, | ||
| /// and false otherwise. | ||
| /// </summary> | ||
| /// <param name="left">The <see cref="JsonData"/> to compare.</param> | ||
| /// <param name="right">The <see cref="string"/> to compare.</param> | ||
| /// <returns>True if the given JsonData represents the given string, and false otherwise.</returns> | ||
| public static bool operator ==(JsonData? left, string? right) | ||
| { | ||
| if (left is null && right is null) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| if (left is null || right is null) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return left.Kind == JsonValueKind.String && ((string?)left._value) == right; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns false if a <see cref="JsonData"/> has the same value as a given string, | ||
| /// and true otherwise. | ||
| /// </summary> | ||
| /// <param name="left">The <see cref="JsonData"/> to compare.</param> | ||
| /// <param name="right">The <see cref="string"/> to compare.</param> | ||
| /// <returns>False if the given JsonData represents the given string, and false otherwise</returns> | ||
| public static bool operator !=(JsonData? left, string? right) => !(left == right); | ||
|
|
||
| /// <summary> | ||
| /// Returns true if a <see cref="JsonData"/> has the same value as a given string, | ||
| /// and false otherwise. | ||
| /// </summary> | ||
| /// <param name="left">The <see cref="string"/> to compare.</param> | ||
| /// <param name="right">The <see cref="JsonData"/> to compare.</param> | ||
| /// <returns>True if the given JsonData represents the given string, and false otherwise.</returns> | ||
| public static bool operator ==(string? left, JsonData? right) | ||
| { | ||
| if (left is null && right is null) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| if (left is null || right is null) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return right.Kind == JsonValueKind.String && ((string?)right._value) == left; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns false if a <see cref="JsonData"/> has the same value as a given string, | ||
| /// and true otherwise. | ||
| /// </summary> | ||
| /// <param name="left">The <see cref="string"/> to compare.</param> | ||
| /// <param name="right">The <see cref="JsonData"/> to compare.</param> | ||
| /// <returns>False if the given JsonData represents the given string, and false otherwise</returns> | ||
| public static bool operator !=(string? left, JsonData? right) => !(left == right); | ||
|
|
||
| /// <summary> | ||
| /// Returns true if a <see cref="JsonData"/> has the same value as a given int, | ||
| /// and false otherwise. | ||
| /// </summary> | ||
| /// <param name="left">The <see cref="JsonData"/> to compare.</param> | ||
| /// <param name="right">The <see cref="int"/> to compare.</param> | ||
| /// <returns>True if the given JsonData represents the given int, and false otherwise.</returns> | ||
| public static bool operator ==(JsonData? left, int right) | ||
| { | ||
| if (left is null) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return left.Kind == JsonValueKind.Number && ((int)left) == right; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns false if a <see cref="JsonData"/> has the same value as a given int, | ||
| /// and true otherwise. | ||
| /// </summary> | ||
| /// <param name="left">The <see cref="JsonData"/> to compare.</param> | ||
| /// <param name="right">The <see cref="int"/> to compare.</param> | ||
| /// <returns>False if the given JsonData represents the given string, and false otherwise</returns> | ||
| public static bool operator !=(JsonData? left, int right) => !(left == right); | ||
|
|
||
| /// <summary> | ||
| /// Returns true if a <see cref="JsonData"/> has the same value as a given int, | ||
| /// and false otherwise. | ||
| /// </summary> | ||
| /// <param name="left">The <see cref="int"/> to compare.</param> | ||
| /// <param name="right">The <see cref="JsonData"/> to compare.</param> | ||
| /// <returns>True if the given JsonData represents the given int, and false otherwise.</returns> | ||
| public static bool operator ==(int left, JsonData? right) | ||
| { | ||
| if (right is null) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return right.Kind == JsonValueKind.Number && ((int)right) == left; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns false if a <see cref="JsonData"/> has the same value as a given int, | ||
| /// and true otherwise. | ||
| /// </summary> | ||
| /// <param name="left">The <see cref="int"/> to compare.</param> | ||
| /// <param name="right">The <see cref="JsonData"/> to compare.</param> | ||
| /// <returns>False if the given JsonData represents the given int, and false otherwise</returns> | ||
| public static bool operator !=(int left, JsonData? right) => !(left == right); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.