Skip to content

Commit f745cba

Browse files
authored
[FR] Language and Locale as extensible enums (Azure#18271)
* language and locale as extensible enums
1 parent 20c4c3f commit f745cba

File tree

41 files changed

+3303
-18407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3303
-18407
lines changed

sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- Renamed the model `Style` to `TextStyle`.
77
- Renamed the extensible enum `TextStyle` to `TextStyleName`.
88
- Changed object type for property `Pages` under `RecognizeContentOptions` from `IEnumerable` to `IList`.
9+
- Changed model type of `Locale` from `string` to `FormRecognizerLocale` in `RecognizeBusinessCardsOptions`, `RecognizeInvoicesOptions`, and `RecognizeReceiptsOptions`.
10+
- Changed model type of `Language` from `string` to `FormRecognizerLanguage` in `RecognizeContentOptions`.
911

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

sdk/formrecognizer/Azure.AI.FormRecognizer/api/Azure.AI.FormRecognizer.netstandard2.0.cs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,52 @@ public enum ServiceVersion
4747
V2_1_Preview_2 = 2,
4848
}
4949
}
50+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
51+
public readonly partial struct FormRecognizerLanguage : System.IEquatable<Azure.AI.FormRecognizer.FormRecognizerLanguage>
52+
{
53+
private readonly object _dummy;
54+
private readonly int _dummyPrimitive;
55+
public FormRecognizerLanguage(string value) { throw null; }
56+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage De { get { throw null; } }
57+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage En { get { throw null; } }
58+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Es { get { throw null; } }
59+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Fr { get { throw null; } }
60+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage It { get { throw null; } }
61+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Ja { get { throw null; } }
62+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Nl { get { throw null; } }
63+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage Pt { get { throw null; } }
64+
public static Azure.AI.FormRecognizer.FormRecognizerLanguage ZhHans { get { throw null; } }
65+
public bool Equals(Azure.AI.FormRecognizer.FormRecognizerLanguage other) { throw null; }
66+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
67+
public override bool Equals(object obj) { throw null; }
68+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
69+
public override int GetHashCode() { throw null; }
70+
public static bool operator ==(Azure.AI.FormRecognizer.FormRecognizerLanguage left, Azure.AI.FormRecognizer.FormRecognizerLanguage right) { throw null; }
71+
public static implicit operator Azure.AI.FormRecognizer.FormRecognizerLanguage (string value) { throw null; }
72+
public static bool operator !=(Azure.AI.FormRecognizer.FormRecognizerLanguage left, Azure.AI.FormRecognizer.FormRecognizerLanguage right) { throw null; }
73+
public override string ToString() { throw null; }
74+
}
75+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
76+
public readonly partial struct FormRecognizerLocale : System.IEquatable<Azure.AI.FormRecognizer.FormRecognizerLocale>
77+
{
78+
private readonly object _dummy;
79+
private readonly int _dummyPrimitive;
80+
public FormRecognizerLocale(string value) { throw null; }
81+
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnAU { get { throw null; } }
82+
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnCA { get { throw null; } }
83+
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnGB { get { throw null; } }
84+
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnIN { get { throw null; } }
85+
public static Azure.AI.FormRecognizer.FormRecognizerLocale EnUS { get { throw null; } }
86+
public bool Equals(Azure.AI.FormRecognizer.FormRecognizerLocale other) { throw null; }
87+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
88+
public override bool Equals(object obj) { throw null; }
89+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
90+
public override int GetHashCode() { throw null; }
91+
public static bool operator ==(Azure.AI.FormRecognizer.FormRecognizerLocale left, Azure.AI.FormRecognizer.FormRecognizerLocale right) { throw null; }
92+
public static implicit operator Azure.AI.FormRecognizer.FormRecognizerLocale (string value) { throw null; }
93+
public static bool operator !=(Azure.AI.FormRecognizer.FormRecognizerLocale left, Azure.AI.FormRecognizer.FormRecognizerLocale right) { throw null; }
94+
public override string ToString() { throw null; }
95+
}
5096
public static partial class OperationExtensions
5197
{
5298
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; }
@@ -63,13 +109,13 @@ public partial class RecognizeBusinessCardsOptions
63109
public RecognizeBusinessCardsOptions() { }
64110
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
65111
public bool IncludeFieldElements { get { throw null; } set { } }
66-
public string Locale { get { throw null; } set { } }
112+
public Azure.AI.FormRecognizer.FormRecognizerLocale? Locale { get { throw null; } set { } }
67113
}
68114
public partial class RecognizeContentOptions
69115
{
70116
public RecognizeContentOptions() { }
71117
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
72-
public string Language { get { throw null; } set { } }
118+
public Azure.AI.FormRecognizer.FormRecognizerLanguage? Language { get { throw null; } set { } }
73119
public System.Collections.Generic.IList<string> Pages { get { throw null; } }
74120
}
75121
public partial class RecognizeCustomFormsOptions
@@ -83,14 +129,14 @@ public partial class RecognizeInvoicesOptions
83129
public RecognizeInvoicesOptions() { }
84130
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
85131
public bool IncludeFieldElements { get { throw null; } set { } }
86-
public string Locale { get { throw null; } set { } }
132+
public Azure.AI.FormRecognizer.FormRecognizerLocale? Locale { get { throw null; } set { } }
87133
}
88134
public partial class RecognizeReceiptsOptions
89135
{
90136
public RecognizeReceiptsOptions() { }
91137
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
92138
public bool IncludeFieldElements { get { throw null; } set { } }
93-
public string Locale { get { throw null; } set { } }
139+
public Azure.AI.FormRecognizer.FormRecognizerLocale? Locale { get { throw null; } set { } }
94140
}
95141
}
96142
namespace Azure.AI.FormRecognizer.Models

sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public virtual RecognizeContentOperation StartRecognizeContent(Stream form, Reco
141141
Response response = ServiceClient.AnalyzeLayoutAsync(
142142
formContentType.ConvertToContentType1(),
143143
form,
144-
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
144+
recognizeContentOptions.Language,
145145
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
146146
cancellationToken);
147147
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
@@ -180,7 +180,7 @@ public virtual async Task<RecognizeContentOperation> StartRecognizeContentAsync(
180180
Response response = await ServiceClient.AnalyzeLayoutAsyncAsync(
181181
formContentType.ConvertToContentType1(),
182182
form,
183-
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
183+
recognizeContentOptions.Language,
184184
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
185185
cancellationToken).ConfigureAwait(false);
186186
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
@@ -216,7 +216,7 @@ public virtual RecognizeContentOperation StartRecognizeContentFromUri(Uri formUr
216216
{
217217
SourcePath sourcePath = new SourcePath() { Source = formUri.AbsoluteUri };
218218
Response response = ServiceClient.AnalyzeLayoutAsync(
219-
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
219+
recognizeContentOptions.Language,
220220
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
221221
sourcePath,
222222
cancellationToken);
@@ -253,7 +253,7 @@ public virtual async Task<RecognizeContentOperation> StartRecognizeContentFromUr
253253
{
254254
SourcePath sourcePath = new SourcePath() { Source = formUri.AbsoluteUri };
255255
Response response = await ServiceClient.AnalyzeLayoutAsyncAsync(
256-
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
256+
recognizeContentOptions.Language,
257257
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
258258
sourcePath,
259259
cancellationToken).ConfigureAwait(false);
@@ -299,7 +299,7 @@ public virtual async Task<RecognizeReceiptsOperation> StartRecognizeReceiptsAsyn
299299
formContentType.ConvertToContentType1(),
300300
receipt,
301301
recognizeReceiptsOptions.IncludeFieldElements,
302-
recognizeReceiptsOptions.Locale == null ? (Locale?)null : recognizeReceiptsOptions.Locale,
302+
recognizeReceiptsOptions.Locale,
303303
cancellationToken).ConfigureAwait(false);
304304
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
305305

@@ -339,7 +339,7 @@ public virtual RecognizeReceiptsOperation StartRecognizeReceipts(Stream receipt,
339339
formContentType.ConvertToContentType1(),
340340
receipt,
341341
recognizeReceiptsOptions.IncludeFieldElements,
342-
recognizeReceiptsOptions.Locale == null ? (Locale?)null : recognizeReceiptsOptions.Locale,
342+
recognizeReceiptsOptions.Locale,
343343
cancellationToken);
344344
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
345345

@@ -376,7 +376,7 @@ public virtual async Task<RecognizeReceiptsOperation> StartRecognizeReceiptsFrom
376376
SourcePath sourcePath = new SourcePath() { Source = receiptUri.AbsoluteUri };
377377
Response response = await ServiceClient.AnalyzeReceiptAsyncAsync(
378378
recognizeReceiptsOptions.IncludeFieldElements,
379-
recognizeReceiptsOptions.Locale == null ? (Locale?)null : recognizeReceiptsOptions.Locale,
379+
recognizeReceiptsOptions.Locale,
380380
sourcePath,
381381
cancellationToken).ConfigureAwait(false);
382382
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
@@ -414,7 +414,7 @@ public virtual RecognizeReceiptsOperation StartRecognizeReceiptsFromUri(Uri rece
414414
SourcePath sourcePath = new SourcePath() { Source = receiptUri.AbsoluteUri };
415415
Response response = ServiceClient.AnalyzeReceiptAsync(
416416
recognizeReceiptsOptions.IncludeFieldElements,
417-
recognizeReceiptsOptions.Locale == null ? (Locale?)null : recognizeReceiptsOptions.Locale,
417+
recognizeReceiptsOptions.Locale,
418418
sourcePath,
419419
cancellationToken);
420420
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
@@ -459,7 +459,7 @@ public virtual async Task<RecognizeBusinessCardsOperation> StartRecognizeBusines
459459
formContentType.ConvertToContentType1(),
460460
businessCard,
461461
recognizeBusinessCardsOptions.IncludeFieldElements,
462-
recognizeBusinessCardsOptions.Locale == null ? (Locale?)null : recognizeBusinessCardsOptions.Locale,
462+
recognizeBusinessCardsOptions.Locale,
463463
cancellationToken).ConfigureAwait(false);
464464
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
465465

@@ -499,7 +499,7 @@ public virtual RecognizeBusinessCardsOperation StartRecognizeBusinessCards(Strea
499499
formContentType.ConvertToContentType1(),
500500
businessCard,
501501
recognizeBusinessCardsOptions.IncludeFieldElements,
502-
recognizeBusinessCardsOptions.Locale == null ? (Locale?)null : recognizeBusinessCardsOptions.Locale,
502+
recognizeBusinessCardsOptions.Locale,
503503
cancellationToken);
504504
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
505505

@@ -536,7 +536,7 @@ public virtual async Task<RecognizeBusinessCardsOperation> StartRecognizeBusines
536536
SourcePath sourcePath = new SourcePath() { Source = businessCardUri.AbsoluteUri };
537537
Response response = await ServiceClient.AnalyzeBusinessCardAsyncAsync(
538538
recognizeBusinessCardsOptions.IncludeFieldElements,
539-
recognizeBusinessCardsOptions.Locale == null ? (Locale?)null : recognizeBusinessCardsOptions.Locale,
539+
recognizeBusinessCardsOptions.Locale,
540540
sourcePath,
541541
cancellationToken).ConfigureAwait(false);
542542
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
@@ -574,7 +574,7 @@ public virtual RecognizeBusinessCardsOperation StartRecognizeBusinessCardsFromUr
574574
SourcePath sourcePath = new SourcePath() { Source = businessCardUri.AbsoluteUri };
575575
Response response = ServiceClient.AnalyzeBusinessCardAsync(
576576
recognizeBusinessCardsOptions.IncludeFieldElements,
577-
recognizeBusinessCardsOptions.Locale == null ? (Locale?)null : recognizeBusinessCardsOptions.Locale,
577+
recognizeBusinessCardsOptions.Locale,
578578
sourcePath,
579579
cancellationToken);
580580
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
@@ -619,7 +619,7 @@ public virtual async Task<RecognizeInvoicesOperation> StartRecognizeInvoicesAsyn
619619
formContentType.ConvertToContentType1(),
620620
invoice,
621621
recognizeInvoicesOptions.IncludeFieldElements,
622-
recognizeInvoicesOptions.Locale == null ? (Locale?)null : recognizeInvoicesOptions.Locale,
622+
recognizeInvoicesOptions.Locale,
623623
cancellationToken).ConfigureAwait(false);
624624
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
625625

@@ -659,7 +659,7 @@ public virtual RecognizeInvoicesOperation StartRecognizeInvoices(Stream invoice,
659659
formContentType.ConvertToContentType1(),
660660
invoice,
661661
recognizeInvoicesOptions.IncludeFieldElements,
662-
recognizeInvoicesOptions.Locale == null ? (Locale?)null : recognizeInvoicesOptions.Locale,
662+
recognizeInvoicesOptions.Locale,
663663
cancellationToken);
664664
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
665665

@@ -696,7 +696,7 @@ public virtual async Task<RecognizeInvoicesOperation> StartRecognizeInvoicesFrom
696696
SourcePath sourcePath = new SourcePath() { Source = invoiceUri.AbsoluteUri };
697697
Response response = await ServiceClient.AnalyzeInvoiceAsyncAsync(
698698
recognizeInvoicesOptions.IncludeFieldElements,
699-
recognizeInvoicesOptions.Locale == null ? (Locale?)null : recognizeInvoicesOptions.Locale,
699+
recognizeInvoicesOptions.Locale,
700700
sourcePath,
701701
cancellationToken).ConfigureAwait(false);
702702
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
@@ -734,7 +734,7 @@ public virtual RecognizeInvoicesOperation StartRecognizeInvoicesFromUri(Uri invo
734734
SourcePath sourcePath = new SourcePath() { Source = invoiceUri.AbsoluteUri };
735735
Response response = ServiceClient.AnalyzeInvoiceAsync(
736736
recognizeInvoicesOptions.IncludeFieldElements,
737-
recognizeInvoicesOptions.Locale == null ? (Locale?)null : recognizeInvoicesOptions.Locale,
737+
recognizeInvoicesOptions.Locale,
738738
sourcePath,
739739
cancellationToken);
740740
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

sdk/formrecognizer/Azure.AI.FormRecognizer/src/Language.cs renamed to sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerLanguage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
using Azure.Core;
55

6-
namespace Azure.AI.FormRecognizer.Models
6+
namespace Azure.AI.FormRecognizer
77
{
88
[CodeGenModel("Language")]
9-
internal readonly partial struct Language
9+
public readonly partial struct FormRecognizerLanguage
1010
{
1111
}
1212
}

sdk/formrecognizer/Azure.AI.FormRecognizer/src/Locale.cs renamed to sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerLocale.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
using Azure.Core;
55

6-
namespace Azure.AI.FormRecognizer.Models
6+
namespace Azure.AI.FormRecognizer
77
{
88
[CodeGenModel("Locale")]
9-
internal readonly partial struct Locale
9+
public readonly partial struct FormRecognizerLocale
1010
{
1111
}
1212
}

0 commit comments

Comments
 (0)