Skip to content

Commit 6ea7082

Browse files
authored
Add required fields to ClientConnection (Azure#51338)
1 parent 3b5ceda commit 6ea7082

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

sdk/core/System.ClientModel/api/System.ClientModel.net8.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public readonly partial struct ClientConnection
129129
public System.ClientModel.Primitives.CredentialKind CredentialKind { get { throw null; } }
130130
public string Id { get { throw null; } }
131131
public string Locator { get { throw null; } }
132+
public System.Collections.Generic.IReadOnlyDictionary<string, string> Metadata { get { throw null; } }
132133
public override string ToString() { throw null; }
133134
public bool TryGetLocatorAsUri(out System.Uri? uri) { throw null; }
134135
}

sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public readonly partial struct ClientConnection
128128
public System.ClientModel.Primitives.CredentialKind CredentialKind { get { throw null; } }
129129
public string Id { get { throw null; } }
130130
public string Locator { get { throw null; } }
131+
public System.Collections.Generic.IReadOnlyDictionary<string, string> Metadata { get { throw null; } }
131132
public override string ToString() { throw null; }
132133
public bool TryGetLocatorAsUri(out System.Uri? uri) { throw null; }
133134
}

sdk/core/System.ClientModel/src/Convenience/ClientConnection.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
3+
using System.Collections.ObjectModel;
34

45
namespace System.ClientModel.Primitives;
56

@@ -28,6 +29,7 @@ public ClientConnection(string id, string locator, object credential, Credential
2829
Locator = locator;
2930
Credential = credential;
3031
CredentialKind = credentialKind;
32+
Metadata = new Dictionary<string, string>();
3133
}
3234

3335
/// <summary>
@@ -45,6 +47,7 @@ public ClientConnection(string id, string locator)
4547
Id = id;
4648
Locator = locator;
4749
CredentialKind = CredentialKind.None;
50+
Metadata = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>());
4851
}
4952

5053
/// <summary>
@@ -59,6 +62,23 @@ internal ClientConnection(string id, string locator, CredentialKind credentialKi
5962
Id = id;
6063
Locator = locator;
6164
CredentialKind = credentialKind;
65+
Metadata = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>());
66+
}
67+
68+
/// <summary>
69+
/// Initializes a new instance of the <see cref="ClientConnection"/> struct with the specified subclient ID.
70+
/// It is only for the JSON serializer.
71+
/// </summary>
72+
/// <param name="metadata">The connection metadata.</param>
73+
/// <param name="id">The identifier for the connection.</param>
74+
/// <param name="locator">The endpoint or resource identifier.</param>
75+
/// <param name="credentialKind">The kind of connection used by the client</param>
76+
internal ClientConnection(IReadOnlyDictionary<string, string> metadata, string id, string locator, CredentialKind credentialKind)
77+
{
78+
Id = id;
79+
Locator = locator;
80+
CredentialKind = credentialKind;
81+
Metadata = metadata;
6282
}
6383

6484
/// <summary>
@@ -96,4 +116,7 @@ public bool TryGetLocatorAsUri(out Uri? uri)
96116
/// </summary>
97117
/// <returns>A string in the format 'Id => Locator'.</returns>
98118
public override string ToString() => $"{Id} => {Locator}";
119+
120+
/// <summary> Metadata of the connection. </summary>
121+
public IReadOnlyDictionary<string, string> Metadata { get; }
99122
}

0 commit comments

Comments
 (0)