Skip to content

Commit

Permalink
Adding customization code for classes using obsolete method and suppr…
Browse files Browse the repository at this point in the history
…ess the warning inline due to the defect here: Azure/autorest.csharp#5114
  • Loading branch information
glorialimicrosoft committed Oct 15, 2024
1 parent 19cafd9 commit f7c7f79
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 43 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
}
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);
}
}
}

0 comments on commit f7c7f79

Please sign in to comment.