Skip to content

Commit

Permalink
[FR] Language and Locale as extensible enums (#18271)
Browse files Browse the repository at this point in the history
* language and locale as extensible enums
  • Loading branch information
maririos authored Jan 30, 2021
1 parent 20c4c3f commit f745cba
Show file tree
Hide file tree
Showing 41 changed files with 3,303 additions and 18,407 deletions.
2 changes: 2 additions & 0 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Renamed the model `Style` to `TextStyle`.
- Renamed the extensible enum `TextStyle` to `TextStyleName`.
- Changed object type for property `Pages` under `RecognizeContentOptions` from `IEnumerable` to `IList`.
- Changed model type of `Locale` from `string` to `FormRecognizerLocale` in `RecognizeBusinessCardsOptions`, `RecognizeInvoicesOptions`, and `RecognizeReceiptsOptions`.
- Changed model type of `Language` from `string` to `FormRecognizerLanguage` in `RecognizeContentOptions`.

## 3.1.0-beta.1 (2020-11-23)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,52 @@ public enum ServiceVersion
V2_1_Preview_2 = 2,
}
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct FormRecognizerLanguage : System.IEquatable<Azure.AI.FormRecognizer.FormRecognizerLanguage>
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public FormRecognizerLanguage(string value) { throw null; }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage De { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage En { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Es { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Fr { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage It { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Ja { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Nl { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Pt { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLanguage ZhHans { get { throw null; } }
public bool Equals(Azure.AI.FormRecognizer.FormRecognizerLanguage 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.FormRecognizer.FormRecognizerLanguage left, Azure.AI.FormRecognizer.FormRecognizerLanguage right) { throw null; }
public static implicit operator Azure.AI.FormRecognizer.FormRecognizerLanguage (string value) { throw null; }
public static bool operator !=(Azure.AI.FormRecognizer.FormRecognizerLanguage left, Azure.AI.FormRecognizer.FormRecognizerLanguage right) { throw null; }
public override string ToString() { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct FormRecognizerLocale : System.IEquatable<Azure.AI.FormRecognizer.FormRecognizerLocale>
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public FormRecognizerLocale(string value) { throw null; }
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnAU { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnCA { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnGB { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnIN { get { throw null; } }
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnUS { get { throw null; } }
public bool Equals(Azure.AI.FormRecognizer.FormRecognizerLocale 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.FormRecognizer.FormRecognizerLocale left, Azure.AI.FormRecognizer.FormRecognizerLocale right) { throw null; }
public static implicit operator Azure.AI.FormRecognizer.FormRecognizerLocale (string value) { throw null; }
public static bool operator !=(Azure.AI.FormRecognizer.FormRecognizerLocale left, Azure.AI.FormRecognizer.FormRecognizerLocale right) { throw null; }
public override string ToString() { throw null; }
}
public static partial class OperationExtensions
{
public static System.Threading.Tasks.Task<Azure.Response<Azure.AI.FormRecognizer.Models.RecognizedFormCollection>> WaitForCompletionAsync(this System.Threading.Tasks.Task<Azure.AI.FormRecognizer.Models.RecognizeBusinessCardsOperation> operation, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Expand All @@ -63,13 +109,13 @@ public partial class RecognizeBusinessCardsOptions
public RecognizeBusinessCardsOptions() { }
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
public bool IncludeFieldElements { get { throw null; } set { } }
public string Locale { get { throw null; } set { } }
public Azure.AI.FormRecognizer.FormRecognizerLocale? Locale { get { throw null; } set { } }
}
public partial class RecognizeContentOptions
{
public RecognizeContentOptions() { }
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
public string Language { get { throw null; } set { } }
public Azure.AI.FormRecognizer.FormRecognizerLanguage? Language { get { throw null; } set { } }
public System.Collections.Generic.IList<string> Pages { get { throw null; } }
}
public partial class RecognizeCustomFormsOptions
Expand All @@ -83,14 +129,14 @@ public partial class RecognizeInvoicesOptions
public RecognizeInvoicesOptions() { }
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
public bool IncludeFieldElements { get { throw null; } set { } }
public string Locale { get { throw null; } set { } }
public Azure.AI.FormRecognizer.FormRecognizerLocale? Locale { get { throw null; } set { } }
}
public partial class RecognizeReceiptsOptions
{
public RecognizeReceiptsOptions() { }
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
public bool IncludeFieldElements { get { throw null; } set { } }
public string Locale { get { throw null; } set { } }
public Azure.AI.FormRecognizer.FormRecognizerLocale? Locale { get { throw null; } set { } }
}
}
namespace Azure.AI.FormRecognizer.Models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public virtual RecognizeContentOperation StartRecognizeContent(Stream form, Reco
Response response = ServiceClient.AnalyzeLayoutAsync(
formContentType.ConvertToContentType1(),
form,
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Language,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -180,7 +180,7 @@ public virtual async Task<RecognizeContentOperation> StartRecognizeContentAsync(
Response response = await ServiceClient.AnalyzeLayoutAsyncAsync(
formContentType.ConvertToContentType1(),
form,
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Language,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -216,7 +216,7 @@ public virtual RecognizeContentOperation StartRecognizeContentFromUri(Uri formUr
{
SourcePath sourcePath = new SourcePath() { Source = formUri.AbsoluteUri };
Response response = ServiceClient.AnalyzeLayoutAsync(
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Language,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
sourcePath,
cancellationToken);
Expand Down Expand Up @@ -253,7 +253,7 @@ public virtual async Task<RecognizeContentOperation> StartRecognizeContentFromUr
{
SourcePath sourcePath = new SourcePath() { Source = formUri.AbsoluteUri };
Response response = await ServiceClient.AnalyzeLayoutAsyncAsync(
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Language,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
sourcePath,
cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -299,7 +299,7 @@ public virtual async Task<RecognizeReceiptsOperation> StartRecognizeReceiptsAsyn
formContentType.ConvertToContentType1(),
receipt,
recognizeReceiptsOptions.IncludeFieldElements,
recognizeReceiptsOptions.Locale == null ? (Locale?)null : recognizeReceiptsOptions.Locale,
recognizeReceiptsOptions.Locale,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -339,7 +339,7 @@ public virtual RecognizeReceiptsOperation StartRecognizeReceipts(Stream receipt,
formContentType.ConvertToContentType1(),
receipt,
recognizeReceiptsOptions.IncludeFieldElements,
recognizeReceiptsOptions.Locale == null ? (Locale?)null : recognizeReceiptsOptions.Locale,
recognizeReceiptsOptions.Locale,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -376,7 +376,7 @@ public virtual async Task<RecognizeReceiptsOperation> StartRecognizeReceiptsFrom
SourcePath sourcePath = new SourcePath() { Source = receiptUri.AbsoluteUri };
Response response = await ServiceClient.AnalyzeReceiptAsyncAsync(
recognizeReceiptsOptions.IncludeFieldElements,
recognizeReceiptsOptions.Locale == null ? (Locale?)null : recognizeReceiptsOptions.Locale,
recognizeReceiptsOptions.Locale,
sourcePath,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -414,7 +414,7 @@ public virtual RecognizeReceiptsOperation StartRecognizeReceiptsFromUri(Uri rece
SourcePath sourcePath = new SourcePath() { Source = receiptUri.AbsoluteUri };
Response response = ServiceClient.AnalyzeReceiptAsync(
recognizeReceiptsOptions.IncludeFieldElements,
recognizeReceiptsOptions.Locale == null ? (Locale?)null : recognizeReceiptsOptions.Locale,
recognizeReceiptsOptions.Locale,
sourcePath,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -459,7 +459,7 @@ public virtual async Task<RecognizeBusinessCardsOperation> StartRecognizeBusines
formContentType.ConvertToContentType1(),
businessCard,
recognizeBusinessCardsOptions.IncludeFieldElements,
recognizeBusinessCardsOptions.Locale == null ? (Locale?)null : recognizeBusinessCardsOptions.Locale,
recognizeBusinessCardsOptions.Locale,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -499,7 +499,7 @@ public virtual RecognizeBusinessCardsOperation StartRecognizeBusinessCards(Strea
formContentType.ConvertToContentType1(),
businessCard,
recognizeBusinessCardsOptions.IncludeFieldElements,
recognizeBusinessCardsOptions.Locale == null ? (Locale?)null : recognizeBusinessCardsOptions.Locale,
recognizeBusinessCardsOptions.Locale,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -536,7 +536,7 @@ public virtual async Task<RecognizeBusinessCardsOperation> StartRecognizeBusines
SourcePath sourcePath = new SourcePath() { Source = businessCardUri.AbsoluteUri };
Response response = await ServiceClient.AnalyzeBusinessCardAsyncAsync(
recognizeBusinessCardsOptions.IncludeFieldElements,
recognizeBusinessCardsOptions.Locale == null ? (Locale?)null : recognizeBusinessCardsOptions.Locale,
recognizeBusinessCardsOptions.Locale,
sourcePath,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -574,7 +574,7 @@ public virtual RecognizeBusinessCardsOperation StartRecognizeBusinessCardsFromUr
SourcePath sourcePath = new SourcePath() { Source = businessCardUri.AbsoluteUri };
Response response = ServiceClient.AnalyzeBusinessCardAsync(
recognizeBusinessCardsOptions.IncludeFieldElements,
recognizeBusinessCardsOptions.Locale == null ? (Locale?)null : recognizeBusinessCardsOptions.Locale,
recognizeBusinessCardsOptions.Locale,
sourcePath,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -619,7 +619,7 @@ public virtual async Task<RecognizeInvoicesOperation> StartRecognizeInvoicesAsyn
formContentType.ConvertToContentType1(),
invoice,
recognizeInvoicesOptions.IncludeFieldElements,
recognizeInvoicesOptions.Locale == null ? (Locale?)null : recognizeInvoicesOptions.Locale,
recognizeInvoicesOptions.Locale,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -659,7 +659,7 @@ public virtual RecognizeInvoicesOperation StartRecognizeInvoices(Stream invoice,
formContentType.ConvertToContentType1(),
invoice,
recognizeInvoicesOptions.IncludeFieldElements,
recognizeInvoicesOptions.Locale == null ? (Locale?)null : recognizeInvoicesOptions.Locale,
recognizeInvoicesOptions.Locale,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -696,7 +696,7 @@ public virtual async Task<RecognizeInvoicesOperation> StartRecognizeInvoicesFrom
SourcePath sourcePath = new SourcePath() { Source = invoiceUri.AbsoluteUri };
Response response = await ServiceClient.AnalyzeInvoiceAsyncAsync(
recognizeInvoicesOptions.IncludeFieldElements,
recognizeInvoicesOptions.Locale == null ? (Locale?)null : recognizeInvoicesOptions.Locale,
recognizeInvoicesOptions.Locale,
sourcePath,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -734,7 +734,7 @@ public virtual RecognizeInvoicesOperation StartRecognizeInvoicesFromUri(Uri invo
SourcePath sourcePath = new SourcePath() { Source = invoiceUri.AbsoluteUri };
Response response = ServiceClient.AnalyzeInvoiceAsync(
recognizeInvoicesOptions.IncludeFieldElements,
recognizeInvoicesOptions.Locale == null ? (Locale?)null : recognizeInvoicesOptions.Locale,
recognizeInvoicesOptions.Locale,
sourcePath,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

using Azure.Core;

namespace Azure.AI.FormRecognizer.Models
namespace Azure.AI.FormRecognizer
{
[CodeGenModel("Language")]
internal readonly partial struct Language
public readonly partial struct FormRecognizerLanguage
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

using Azure.Core;

namespace Azure.AI.FormRecognizer.Models
namespace Azure.AI.FormRecognizer
{
[CodeGenModel("Locale")]
internal readonly partial struct Locale
public readonly partial struct FormRecognizerLocale
{
}
}
Loading

0 comments on commit f745cba

Please sign in to comment.