Skip to content
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

Mark NullableResponseOfT.Value as nullable #35560

Merged
merged 5 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -117,7 +117,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 @@ -256,6 +256,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; } }
christothes marked this conversation as resolved.
Show resolved Hide resolved
[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 @@ -117,7 +117,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 @@ -256,6 +256,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; } }
christothes marked this conversation as resolved.
Show resolved Hide resolved
[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 @@ -117,7 +117,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 @@ -256,6 +256,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 @@ -117,7 +117,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 @@ -256,6 +256,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 @@ -117,7 +117,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 @@ -256,6 +256,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.
christothes marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
public abstract T Value { get; }
public abstract T? Value { get; }
christothes marked this conversation as resolved.
Show resolved Hide resolved

/// <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 />
christothes marked this conversation as resolved.
Show resolved Hide resolved
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!;
christothes marked this conversation as resolved.
Show resolved Hide resolved
}

/// <inheritdoc />
Expand Down