Skip to content

Commit daa1bb6

Browse files
Jimin/review comments (Azure#50729)
* update factory * address review comments 2 * Exclude EBN attribute checking * update api-compact baseline * revert api listing change * Make retention policy factory mode * update contract * make none policy internal * expose ThreadCreationDateRetentionPolicy
1 parent 3935de2 commit daa1bb6

33 files changed

+266
-110
lines changed

sdk/communication/Azure.Communication.Chat/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ CreateChatThreadOptions createChatThreadOptions = new CreateChatThreadOptions("H
7070
createChatThreadOptions.Metadata.Add("MetadataKey1", "MetadataValue1");
7171
createChatThreadOptions.Metadata.Add("MetadataKey2", "MetadataValue2");
7272

73-
createChatThreadOptions.RetentionPolicy = new ThreadCreationDateRetentionPolicy(40);
73+
createChatThreadOptions.RetentionPolicy = ChatRetentionPolicy.ThreadCreationDate(40);
7474

7575
CreateChatThreadResult createChatThreadResult = await chatClient.CreateChatThreadAsync(createChatThreadOptions);
7676
ChatThreadProperties chatThread = createChatThreadResult.ChatThread;
@@ -96,7 +96,7 @@ UpdateChatThreadPropertiesOptions updateChatThreadPropertiesOptions = new Update
9696
updateChatThreadPropertiesOptions.Topic = "Launch meeting";
9797
updateChatThreadPropertiesOptions.Metadata.Add("UpdateMetadataKey", "UpdateMetadataValue");
9898

99-
updateChatThreadPropertiesOptions.RetentionPolicy = new NoneRetentionPolicy();
99+
updateChatThreadPropertiesOptions.RetentionPolicy = ChatRetentionPolicy.None();
100100

101101
await chatThreadClient.UpdatePropertiesAsync(updateChatThreadPropertiesOptions);
102102
```
@@ -202,7 +202,7 @@ createChatThreadOptions.Participants.Add(chatParticipant);
202202
createChatThreadOptions.Metadata.Add("MetadataKey1", "MetadataValue1");
203203
createChatThreadOptions.Metadata.Add("MetadataKey2", "MetadataValue2");
204204

205-
createChatThreadOptions.RetentionPolicy = new ThreadCreationDateRetentionPolicy(60);
205+
createChatThreadOptions.RetentionPolicy = ChatRetentionPolicy.ThreadCreationDate(60);
206206

207207
CreateChatThreadResult createChatThreadResult = await chatClient.CreateChatThreadAsync(createChatThreadOptions);
208208
string threadId = createChatThreadResult.ChatThread.Id;
@@ -246,7 +246,7 @@ UpdateChatThreadPropertiesOptions updateChatThreadPropertiesOptions = new Update
246246
updateChatThreadPropertiesOptions.Topic = "new topic !";
247247
updateChatThreadPropertiesOptions.Metadata.Add("UpdateMetadataKey", "UpdateMetadataValue");
248248

249-
updateChatThreadPropertiesOptions.RetentionPolicy = new ThreadCreationDateRetentionPolicy(60);
249+
updateChatThreadPropertiesOptions.RetentionPolicy = ChatRetentionPolicy.ThreadCreationDate(60);
250250

251251
await chatThreadClient.UpdatePropertiesAsync(updateChatThreadPropertiesOptions);
252252
```

sdk/communication/Azure.Communication.Chat/api/Azure.Communication.Chat.net8.0.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,13 @@ public static partial class ChatModelFactory
130130
public static Azure.Communication.Chat.AddChatParticipantsResult AddChatParticipantsResult(System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatError> invalidParticipants = null) { throw null; }
131131
public static Azure.Communication.Chat.ChatAttachment ChatAttachment(string id, Azure.Communication.Chat.ChatAttachmentType attachmentType, string name, System.Uri uri, System.Uri previewUri) { throw null; }
132132
public static Azure.Communication.Chat.ChatError ChatError(string code = null, string message = null, string target = null, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatError> details = null, Azure.Communication.Chat.ChatError innerError = null) { throw null; }
133-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
134133
public static Azure.Communication.Chat.ChatMessage ChatMessage(string id, Azure.Communication.Chat.ChatMessageType type, string sequenceId, string version, Azure.Communication.Chat.ChatMessageContent content, string senderDisplayName, System.DateTimeOffset createdOn, string senderId, System.DateTimeOffset? deletedOn, System.DateTimeOffset? editedOn) { throw null; }
135-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
136134
public static Azure.Communication.Chat.ChatMessage ChatMessage(string id, Azure.Communication.Chat.ChatMessageType type, string sequenceId, string version, Azure.Communication.Chat.ChatMessageContent content, string senderDisplayName, System.DateTimeOffset createdOn, string senderId, System.DateTimeOffset? deletedOn, System.DateTimeOffset? editedOn, System.Collections.Generic.IReadOnlyDictionary<string, string> metadata) { throw null; }
137135
public static Azure.Communication.Chat.ChatMessageContent ChatMessageContent(string message, string topic, Azure.Communication.CommunicationUserIdentifier communicationUserIdentifier, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants) { throw null; }
138136
public static Azure.Communication.Chat.ChatMessageContent ChatMessageContent(string message, string topic, Azure.Communication.CommunicationUserIdentifier communicationUserIdentifier, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatAttachment> attachments = null) { throw null; }
139-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
140137
public static Azure.Communication.Chat.ChatMessageReadReceipt ChatMessageReadReceipt(Azure.Communication.CommunicationIdentifier sender, string chatMessageId, System.DateTimeOffset readOn) { throw null; }
141138
public static Azure.Communication.Chat.ChatParticipant ChatParticipant(Azure.Communication.CommunicationIdentifier user, string displayName, System.DateTimeOffset? shareHistoryTime) { throw null; }
142139
public static Azure.Communication.Chat.ChatParticipant ChatParticipant(Azure.Communication.CommunicationIdentifier user, string displayName, System.DateTimeOffset? shareHistoryTime, System.Collections.Generic.IDictionary<string, string> metadata) { throw null; }
143-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
144140
public static Azure.Communication.Chat.ChatThreadItem ChatThreadItem(string id, string topic, System.DateTimeOffset? deletedOn, System.DateTimeOffset? lastMessageReceivedOn) { throw null; }
145141
public static Azure.Communication.Chat.ChatThreadProperties ChatThreadProperties(string id, string topic, System.DateTimeOffset createdOn, Azure.Communication.CommunicationIdentifier createdBy, System.DateTimeOffset deletedOn) { throw null; }
146142
public static Azure.Communication.Chat.CreateChatThreadResult CreateChatThreadResult(Azure.Communication.Chat.ChatThreadProperties chatThread, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatError> invalidParticipants) { throw null; }
@@ -156,7 +152,10 @@ public ChatParticipant(Azure.Communication.CommunicationIdentifier identifier) {
156152
}
157153
public abstract partial class ChatRetentionPolicy
158154
{
159-
protected ChatRetentionPolicy() { }
155+
protected ChatRetentionPolicy(Azure.Communication.Chat.RetentionPolicyKind kind) { }
156+
public Azure.Communication.Chat.RetentionPolicyKind Kind { get { throw null; } }
157+
public static Azure.Communication.Chat.ChatRetentionPolicy None() { throw null; }
158+
public static Azure.Communication.Chat.ChatRetentionPolicy ThreadCreationDate(int deleteThreadAfterDays) { throw null; }
160159
}
161160
public partial class ChatThreadClient
162161
{
@@ -234,10 +233,6 @@ internal CreateChatThreadResult() { }
234233
public Azure.Communication.Chat.ChatThreadProperties ChatThread { get { throw null; } }
235234
public System.Collections.Generic.IReadOnlyList<Azure.Communication.Chat.ChatError> InvalidParticipants { get { throw null; } }
236235
}
237-
public partial class NoneRetentionPolicy : Azure.Communication.Chat.ChatRetentionPolicy
238-
{
239-
public NoneRetentionPolicy() { }
240-
}
241236
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
242237
public readonly partial struct RetentionPolicyKind : System.IEquatable<Azure.Communication.Chat.RetentionPolicyKind>
243238
{
@@ -269,10 +264,10 @@ public partial class SendChatMessageResult
269264
internal SendChatMessageResult() { }
270265
public string Id { get { throw null; } }
271266
}
272-
public partial class ThreadCreationDateRetentionPolicy : Azure.Communication.Chat.ChatRetentionPolicy
267+
public sealed partial class ThreadCreationDateRetentionPolicy : Azure.Communication.Chat.ChatRetentionPolicy
273268
{
274-
public ThreadCreationDateRetentionPolicy(int deleteThreadAfterDays) { }
275-
public int DeleteThreadAfterDays { get { throw null; } set { } }
269+
public ThreadCreationDateRetentionPolicy(int deleteThreadAfterDays) : base (default(Azure.Communication.Chat.RetentionPolicyKind)) { }
270+
public int DeleteThreadAfterDays { get { throw null; } }
276271
}
277272
public partial class TypingNotificationOptions
278273
{

sdk/communication/Azure.Communication.Chat/api/Azure.Communication.Chat.netstandard2.0.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,13 @@ public static partial class ChatModelFactory
130130
public static Azure.Communication.Chat.AddChatParticipantsResult AddChatParticipantsResult(System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatError> invalidParticipants = null) { throw null; }
131131
public static Azure.Communication.Chat.ChatAttachment ChatAttachment(string id, Azure.Communication.Chat.ChatAttachmentType attachmentType, string name, System.Uri uri, System.Uri previewUri) { throw null; }
132132
public static Azure.Communication.Chat.ChatError ChatError(string code = null, string message = null, string target = null, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatError> details = null, Azure.Communication.Chat.ChatError innerError = null) { throw null; }
133-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
134133
public static Azure.Communication.Chat.ChatMessage ChatMessage(string id, Azure.Communication.Chat.ChatMessageType type, string sequenceId, string version, Azure.Communication.Chat.ChatMessageContent content, string senderDisplayName, System.DateTimeOffset createdOn, string senderId, System.DateTimeOffset? deletedOn, System.DateTimeOffset? editedOn) { throw null; }
135-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
136134
public static Azure.Communication.Chat.ChatMessage ChatMessage(string id, Azure.Communication.Chat.ChatMessageType type, string sequenceId, string version, Azure.Communication.Chat.ChatMessageContent content, string senderDisplayName, System.DateTimeOffset createdOn, string senderId, System.DateTimeOffset? deletedOn, System.DateTimeOffset? editedOn, System.Collections.Generic.IReadOnlyDictionary<string, string> metadata) { throw null; }
137135
public static Azure.Communication.Chat.ChatMessageContent ChatMessageContent(string message, string topic, Azure.Communication.CommunicationUserIdentifier communicationUserIdentifier, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants) { throw null; }
138136
public static Azure.Communication.Chat.ChatMessageContent ChatMessageContent(string message, string topic, Azure.Communication.CommunicationUserIdentifier communicationUserIdentifier, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatAttachment> attachments = null) { throw null; }
139-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
140137
public static Azure.Communication.Chat.ChatMessageReadReceipt ChatMessageReadReceipt(Azure.Communication.CommunicationIdentifier sender, string chatMessageId, System.DateTimeOffset readOn) { throw null; }
141138
public static Azure.Communication.Chat.ChatParticipant ChatParticipant(Azure.Communication.CommunicationIdentifier user, string displayName, System.DateTimeOffset? shareHistoryTime) { throw null; }
142139
public static Azure.Communication.Chat.ChatParticipant ChatParticipant(Azure.Communication.CommunicationIdentifier user, string displayName, System.DateTimeOffset? shareHistoryTime, System.Collections.Generic.IDictionary<string, string> metadata) { throw null; }
143-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
144140
public static Azure.Communication.Chat.ChatThreadItem ChatThreadItem(string id, string topic, System.DateTimeOffset? deletedOn, System.DateTimeOffset? lastMessageReceivedOn) { throw null; }
145141
public static Azure.Communication.Chat.ChatThreadProperties ChatThreadProperties(string id, string topic, System.DateTimeOffset createdOn, Azure.Communication.CommunicationIdentifier createdBy, System.DateTimeOffset deletedOn) { throw null; }
146142
public static Azure.Communication.Chat.CreateChatThreadResult CreateChatThreadResult(Azure.Communication.Chat.ChatThreadProperties chatThread, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatError> invalidParticipants) { throw null; }
@@ -156,7 +152,10 @@ public ChatParticipant(Azure.Communication.CommunicationIdentifier identifier) {
156152
}
157153
public abstract partial class ChatRetentionPolicy
158154
{
159-
protected ChatRetentionPolicy() { }
155+
protected ChatRetentionPolicy(Azure.Communication.Chat.RetentionPolicyKind kind) { }
156+
public Azure.Communication.Chat.RetentionPolicyKind Kind { get { throw null; } }
157+
public static Azure.Communication.Chat.ChatRetentionPolicy None() { throw null; }
158+
public static Azure.Communication.Chat.ChatRetentionPolicy ThreadCreationDate(int deleteThreadAfterDays) { throw null; }
160159
}
161160
public partial class ChatThreadClient
162161
{
@@ -234,10 +233,6 @@ internal CreateChatThreadResult() { }
234233
public Azure.Communication.Chat.ChatThreadProperties ChatThread { get { throw null; } }
235234
public System.Collections.Generic.IReadOnlyList<Azure.Communication.Chat.ChatError> InvalidParticipants { get { throw null; } }
236235
}
237-
public partial class NoneRetentionPolicy : Azure.Communication.Chat.ChatRetentionPolicy
238-
{
239-
public NoneRetentionPolicy() { }
240-
}
241236
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
242237
public readonly partial struct RetentionPolicyKind : System.IEquatable<Azure.Communication.Chat.RetentionPolicyKind>
243238
{
@@ -269,10 +264,10 @@ public partial class SendChatMessageResult
269264
internal SendChatMessageResult() { }
270265
public string Id { get { throw null; } }
271266
}
272-
public partial class ThreadCreationDateRetentionPolicy : Azure.Communication.Chat.ChatRetentionPolicy
267+
public sealed partial class ThreadCreationDateRetentionPolicy : Azure.Communication.Chat.ChatRetentionPolicy
273268
{
274-
public ThreadCreationDateRetentionPolicy(int deleteThreadAfterDays) { }
275-
public int DeleteThreadAfterDays { get { throw null; } set { } }
269+
public ThreadCreationDateRetentionPolicy(int deleteThreadAfterDays) : base (default(Azure.Communication.Chat.RetentionPolicyKind)) { }
270+
public int DeleteThreadAfterDays { get { throw null; } }
276271
}
277272
public partial class TypingNotificationOptions
278273
{
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# The attribute is in shared source which is included and compiled into the binary, so there is no compatibility concern on it.
2+
CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'Azure.Communication.Chat.ChatModelFactory.ChatMessage(System.String, Azure.Communication.Chat.ChatMessageType, System.String, System.String, Azure.Communication.Chat.ChatMessageContent, System.String, System.DateTimeOffset, System.String, System.Nullable<System.DateTimeOffset>, System.Nullable<System.DateTimeOffset>)' in the contract but not the implementation.
3+
CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'Azure.Communication.Chat.ChatModelFactory.ChatMessage(System.String, Azure.Communication.Chat.ChatMessageType, System.String, System.String, Azure.Communication.Chat.ChatMessageContent, System.String, System.DateTimeOffset, System.String, System.Nullable<System.DateTimeOffset>, System.Nullable<System.DateTimeOffset>, System.Collections.Generic.IReadOnlyDictionary<System.String, System.String>)' in the contract but not the implementation.
4+
CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'Azure.Communication.Chat.ChatModelFactory.ChatMessageReadReceipt(Azure.Communication.CommunicationIdentifier, System.String, System.DateTimeOffset)' in the contract but not the implementation.
5+
CannotRemoveAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' exists on 'Azure.Communication.Chat.ChatModelFactory.ChatThreadItem(System.String, System.String, System.Nullable<System.DateTimeOffset>, System.Nullable<System.DateTimeOffset>)' in the contract but not the implementation.

sdk/communication/Azure.Communication.Chat/src/ChatRestClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ internal HttpMessage CreateCreateChatThreadRequest(CreateChatThreadOptions optio
5252

5353
if (options.RetentionPolicy != null)
5454
{
55-
createChatThreadRequest.RetentionPolicy = options.RetentionPolicy;
55+
createChatThreadRequest.RetentionPolicy = ChatRetentionPolicyConverter.ConvertBack(options.RetentionPolicy);
5656
}
5757

5858
var model = createChatThreadRequest;

sdk/communication/Azure.Communication.Chat/src/ChatThreadClient.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ public virtual Response UpdateProperties(UpdateChatThreadPropertiesOptions optio
8282
scope.Start();
8383
try
8484
{
85-
return _chatThreadRestClient.UpdateChatThreadProperties(Id, options.Topic, options.Metadata.ToDictionary(pair => pair.Key, pair => pair.Value), options.RetentionPolicy, cancellationToken);
85+
return _chatThreadRestClient.UpdateChatThreadProperties(
86+
Id,
87+
options.Topic,
88+
options.Metadata?.ToDictionary(pair => pair.Key, pair => pair.Value),
89+
ChatRetentionPolicyConverter.ConvertBack(options.RetentionPolicy),
90+
cancellationToken);
8691
}
8792
catch (Exception ex)
8893
{
@@ -101,7 +106,12 @@ public virtual async Task<Response> UpdatePropertiesAsync(UpdateChatThreadProper
101106
scope.Start();
102107
try
103108
{
104-
return await _chatThreadRestClient.UpdateChatThreadPropertiesAsync(Id, options.Topic, options.Metadata, options.RetentionPolicy, cancellationToken).ConfigureAwait(false);
109+
return await _chatThreadRestClient.UpdateChatThreadPropertiesAsync(
110+
Id,
111+
options.Topic,
112+
options.Metadata,
113+
ChatRetentionPolicyConverter.ConvertBack(options.RetentionPolicy),
114+
cancellationToken).ConfigureAwait(false);
105115
}
106116
catch (Exception ex)
107117
{

0 commit comments

Comments
 (0)