-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding customization code for classes using obsolete method and suppr…
…ess the warning inline due to the defect here: Azure/autorest.csharp#5114
- Loading branch information
1 parent
19cafd9
commit f7c7f79
Showing
4 changed files
with
80 additions
and
43 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
...unication/Azure.Communication.Messages/src/Generated/CommunicationMessagesModelFactory.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...unication/Azure.Communication.Messages/src/Generated/NotificationContent.Serialization.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
...ommunication/Azure.Communication.Messages/src/Models/CommunicationMessagesModelFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Azure.Communication.Messages.Models.Channels; | ||
|
||
namespace Azure.Communication.Messages | ||
{ | ||
/// <summary> Model factory for models. </summary> | ||
public static partial class CommunicationMessagesModelFactory | ||
{ | ||
#pragma warning disable CS0618 // Type or member is obsolete - Need to manually add this custom code due to the defect here: https://github.com/Azure/autorest.csharp/issues/5114 | ||
/// <summary> Initializes a new instance of <see cref="Messages.MediaNotificationContent"/>. </summary> | ||
/// <param name="channelRegistrationId"> The Channel Registration ID for the Business Identifier. </param> | ||
/// <param name="to"> The native external platform user identifiers of the recipient. </param> | ||
/// <param name="content"> Optional text content. </param> | ||
/// <param name="mediaUri"> A media url for the file. Required if the type is one of the supported media types, e.g. image. </param> | ||
/// <returns> A new <see cref="Messages.MediaNotificationContent"/> instance for mocking. </returns> | ||
public static MediaNotificationContent MediaNotificationContent(Guid channelRegistrationId = default, IEnumerable<string> to = null, string content = null, Uri mediaUri = null) | ||
{ | ||
to ??= new List<string>(); | ||
|
||
return new MediaNotificationContent( | ||
channelRegistrationId, | ||
to?.ToList(), | ||
CommunicationMessageKind.ImageV0, | ||
serializedAdditionalRawData: null, | ||
content, | ||
mediaUri); | ||
} | ||
} | ||
#pragma warning restore CS0618 // Type or member is obsolete - Need to manually add this custom code due to the defect here: https://github.com/Azure/autorest.csharp/issues/5114 | ||
} |
43 changes: 43 additions & 0 deletions
43
...ommunication/Azure.Communication.Messages/src/Models/NotificationContent.Serialization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.ClientModel.Primitives; | ||
using System.Text.Json; | ||
using Azure.Core; | ||
|
||
namespace Azure.Communication.Messages | ||
{ | ||
public partial class NotificationContent : IUtf8JsonSerializable, IJsonModel<NotificationContent> | ||
{ | ||
internal static NotificationContent DeserializeNotificationContent(JsonElement element, ModelReaderWriterOptions options = null) | ||
{ | ||
options ??= ModelSerializationExtensions.WireOptions; | ||
|
||
if (element.ValueKind == JsonValueKind.Null) | ||
{ | ||
return null; | ||
} | ||
if (element.TryGetProperty("kind", out JsonElement discriminator)) | ||
{ | ||
switch (discriminator.GetString()) | ||
{ | ||
case "audio": return AudioNotificationContent.DeserializeAudioNotificationContent(element, options); | ||
case "document": return DocumentNotificationContent.DeserializeDocumentNotificationContent(element, options); | ||
case "image": return ImageNotificationContent.DeserializeImageNotificationContent(element, options); | ||
#pragma warning disable CS0618 // Type or member is obsolete - Need to manually add this custom code due to the defect here: https://github.com/Azure/autorest.csharp/issues/5114 | ||
case "image_v0": return MediaNotificationContent.DeserializeMediaNotificationContent(element, options); | ||
#pragma warning restore CS0618 // Type or member is obsolete - Need to manually add this custom code due to the defect here: https://github.com/Azure/autorest.csharp/issues/5114 | ||
case "template": return TemplateNotificationContent.DeserializeTemplateNotificationContent(element, options); | ||
case "text": return TextNotificationContent.DeserializeTextNotificationContent(element, options); | ||
case "video": return VideoNotificationContent.DeserializeVideoNotificationContent(element, options); | ||
} | ||
} | ||
return UnknownNotificationContent.DeserializeUnknownNotificationContent(element, options); | ||
} | ||
} | ||
} |