From e8df4176d852281be7b76f97129fb4b41a027cc5 Mon Sep 17 00:00:00 2001 From: Mariana Rios Flores Date: Tue, 20 Jul 2021 10:50:30 -0700 Subject: [PATCH] ext enum -> enum --- ....AI.Translation.Document.netstandard2.0.cs | 19 ++----- .../DocumentTranslationInput.Serialization.cs | 2 +- .../Models/StorageInputType.Serialization.cs | 28 ++++++++++ .../src/Generated/Models/StorageInputType.cs | 51 ------------------- .../src/StorageInputType.cs | 13 ++++- 5 files changed, 44 insertions(+), 69 deletions(-) create mode 100644 sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/StorageInputType.Serialization.cs delete mode 100644 sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/StorageInputType.cs diff --git a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs index d37ebc4ae4255..deb5f58d1916d 100644 --- a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs +++ b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs @@ -155,23 +155,10 @@ internal FileFormat() { } public string Format { get { throw null; } } public System.Collections.Generic.IReadOnlyList FormatVersions { get { throw null; } } } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct StorageInputType : System.IEquatable + public enum StorageInputType { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public StorageInputType(string value) { throw null; } - public static Azure.AI.Translation.Document.StorageInputType File { get { throw null; } } - public static Azure.AI.Translation.Document.StorageInputType Folder { get { throw null; } } - public bool Equals(Azure.AI.Translation.Document.StorageInputType other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.AI.Translation.Document.StorageInputType left, Azure.AI.Translation.Document.StorageInputType right) { throw null; } - public static implicit operator Azure.AI.Translation.Document.StorageInputType (string value) { throw null; } - public static bool operator !=(Azure.AI.Translation.Document.StorageInputType left, Azure.AI.Translation.Document.StorageInputType right) { throw null; } - public override string ToString() { throw null; } + File = 0, + Folder = 1, } public partial class TranslationGlossary { diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationInput.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationInput.Serialization.cs index 356ca5ef0aae5..07c289e170e6e 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationInput.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationInput.Serialization.cs @@ -27,7 +27,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(StorageType)) { writer.WritePropertyName("storageType"); - writer.WriteStringValue(StorageType.Value.ToString()); + writer.WriteStringValue(StorageType.Value.ToSerialString()); } writer.WriteEndObject(); } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/StorageInputType.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/StorageInputType.Serialization.cs new file mode 100644 index 0000000000000..443ddfc72a413 --- /dev/null +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/StorageInputType.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.Translation.Document +{ + internal static partial class StorageInputTypeExtensions + { + public static string ToSerialString(this StorageInputType value) => value switch + { + StorageInputType.Folder => "Folder", + StorageInputType.File => "File", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown StorageInputType value.") + }; + + public static StorageInputType ToStorageInputType(this string value) + { + if (string.Equals(value, "Folder", StringComparison.InvariantCultureIgnoreCase)) return StorageInputType.Folder; + if (string.Equals(value, "File", StringComparison.InvariantCultureIgnoreCase)) return StorageInputType.File; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown StorageInputType value."); + } + } +} diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/StorageInputType.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/StorageInputType.cs deleted file mode 100644 index 22dd575b39929..0000000000000 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/StorageInputType.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.Translation.Document -{ - /// Storage type of the input documents source string. - public readonly partial struct StorageInputType : IEquatable - { - private readonly string _value; - - /// Determines if two values are the same. - /// is null. - public StorageInputType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string FolderValue = "Folder"; - private const string FileValue = "File"; - - /// Folder. - public static StorageInputType Folder { get; } = new StorageInputType(FolderValue); - /// File. - public static StorageInputType File { get; } = new StorageInputType(FileValue); - /// Determines if two values are the same. - public static bool operator ==(StorageInputType left, StorageInputType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(StorageInputType left, StorageInputType right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator StorageInputType(string value) => new StorageInputType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is StorageInputType other && Equals(other); - /// - public bool Equals(StorageInputType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/translation/Azure.AI.Translation.Document/src/StorageInputType.cs b/sdk/translation/Azure.AI.Translation.Document/src/StorageInputType.cs index 3ee1380214716..b1fd4f30838cc 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/StorageInputType.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/StorageInputType.cs @@ -5,8 +5,19 @@ namespace Azure.AI.Translation.Document { + /// + /// Storage type of the input documents source. + /// [CodeGenModel("StorageInputType")] - public readonly partial struct StorageInputType + public enum StorageInputType { + /// + /// File + /// + File, + /// + /// Folder + /// + Folder } }