Skip to content

Conversation

annelo-msft
Copy link
Member

@annelo-msft annelo-msft commented Jan 4, 2024

Add types in the System.ClientModel namespace -- i.e. those for end-users of ClientModel clients -- to System.ClientModel library. This includes:

  • ClientResult, ClientResult<T> and OptionalClientResult<T>
  • KeyCredential
  • ClientRequestException

It also includes PipelineResponse, which is needed to support most of these types.

A discussion of the types contained in this PR can be found in the System.ClientModel README.

// Note: this is GetValue instead of GetKey to allow consistent naming
// across credential types. For example, for NamedKeyCredential, we would have
// GetValues with two out params to enable atomicity in reading credential values.
public string GetValue() => Volatile.Read(ref _key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Azure.Core types I think we purposely didn't expose methods/properties for the key values due to security concerns. Is this not a concern?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline - we will move to Deconstruct APIs here, as it will give us consistency across credential types as new types like NamedKeyCredential come online, pending a strong concern from the BCL team (Anne to dig up context on the prior concern).

@annelo-msft
Copy link
Member Author

Bad merge - will open new PR

@annelo-msft annelo-msft closed this Jan 4, 2024
@annelo-msft
Copy link
Member Author

Replaced by #41016

private const string DefaultMessage = "Service request failed.";

private readonly PipelineResponse? _response;
private int _status;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need both the response and status? PipelineResponse already has status.

return messageBuilder.ToString();
}

private static void BufferResponse(PipelineResponse response)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should not be here. I think many callers will want to buffer a response, and so maybe we just add this helper method to PipelineResponse?


private static void BufferResponse(PipelineResponse response)
{
if (response.ContentStream is null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also check if the response is not already buffered?


namespace System.ClientModel;

public abstract class ClientResult
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this abstract given no members are abstract?

public abstract class PipelineResponse : IDisposable
{
// TODO(matell): The .NET Framework team plans to add BinaryData.Empty in dotnet/runtime#49670, and we can use it then.
private static readonly BinaryData s_emptyBinaryData = new(Array.Empty<byte>());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BinaryData.Empty is already there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants