Skip to content

Commit

Permalink
Mark NullableResponseOfT.Value as nullable (#35560)
Browse files Browse the repository at this point in the history
  • Loading branch information
christothes authored Jul 28, 2023
1 parent 8a3d98d commit 30d6134
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net461.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public abstract partial class NullableResponse<T>
{
protected NullableResponse() { }
public abstract bool HasValue { get; }
public abstract T Value { get; }
public abstract T? Value { get; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -267,6 +267,7 @@ public abstract partial class Response<T> : Azure.NullableResponse<T>
protected Response() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool HasValue { get { throw null; } }
public override T Value { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down
3 changes: 2 additions & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public abstract partial class NullableResponse<T>
{
protected NullableResponse() { }
public abstract bool HasValue { get; }
public abstract T Value { get; }
public abstract T? Value { get; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -267,6 +267,7 @@ public abstract partial class Response<T> : Azure.NullableResponse<T>
protected Response() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool HasValue { get { throw null; } }
public override T Value { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down
3 changes: 2 additions & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public abstract partial class NullableResponse<T>
{
protected NullableResponse() { }
public abstract bool HasValue { get; }
public abstract T Value { get; }
public abstract T? Value { get; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -267,6 +267,7 @@ public abstract partial class Response<T> : Azure.NullableResponse<T>
protected Response() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool HasValue { get { throw null; } }
public override T Value { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down
3 changes: 2 additions & 1 deletion sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public abstract partial class NullableResponse<T>
{
protected NullableResponse() { }
public abstract bool HasValue { get; }
public abstract T Value { get; }
public abstract T? Value { get; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -267,6 +267,7 @@ public abstract partial class Response<T> : Azure.NullableResponse<T>
protected Response() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool HasValue { get { throw null; } }
public override T Value { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down
3 changes: 2 additions & 1 deletion sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public abstract partial class NullableResponse<T>
{
protected NullableResponse() { }
public abstract bool HasValue { get; }
public abstract T Value { get; }
public abstract T? Value { get; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -267,6 +267,7 @@ public abstract partial class Response<T> : Azure.NullableResponse<T>
protected Response() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool HasValue { get { throw null; } }
public override T Value { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object? obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/src/NullableResponseOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class NullableResponse<T>
/// <summary>
/// Gets the value returned by the service. Accessing this property will throw if <see cref="HasValue"/> is false.
/// </summary>
public abstract T Value { get; }
public abstract T? Value { get; }

/// <summary>
/// Returns the HTTP response returned by the service.
Expand Down
5 changes: 4 additions & 1 deletion sdk/core/Azure.Core/src/ResponseOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public abstract class Response<T> : NullableResponse<T>
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool HasValue => true;

/// <inheritdoc />
public override T Value => Value;

/// <summary>
/// Returns the value of this <see cref="Response{T}"/> object.
/// </summary>
Expand All @@ -35,7 +38,7 @@ public static implicit operator T(Response<T> response)
#pragma warning restore CA1065
}

return response.Value;
return response.Value!;
}

/// <inheritdoc />
Expand Down

0 comments on commit 30d6134

Please sign in to comment.