Skip to content

Commit

Permalink
[FR] Modify Pages type (#18260)
Browse files Browse the repository at this point in the history
Changed the type for `IEnumerable` to `IList` as this is a property in an input-only object. 
Followed what other libraries like Search and KV do.
  • Loading branch information
maririos authored Jan 29, 2021
1 parent 5ee3df7 commit 5e37818
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Renamed the model `Appearance` to `TextAppearance`.
- 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`.

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public partial class RecognizeContentOptions
public RecognizeContentOptions() { }
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
public string Language { get { throw null; } set { } }
public System.Collections.Generic.IEnumerable<string> Pages { get { throw null; } set { } }
public System.Collections.Generic.IList<string> Pages { get { throw null; } }
}
public partial class RecognizeCustomFormsOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public virtual RecognizeContentOperation StartRecognizeContent(Stream form, Reco
formContentType.ConvertToContentType1(),
form,
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Pages,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -181,7 +181,7 @@ public virtual async Task<RecognizeContentOperation> StartRecognizeContentAsync(
formContentType.ConvertToContentType1(),
form,
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Pages,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -217,7 +217,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.Pages,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
sourcePath,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -254,7 +254,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.Pages,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
sourcePath,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ public RecognizeContentOptions()
public string Language { get; set; }

/// <summary>
/// Custom page numbers for multi-page documents(PDF/TIFF). Input the number of the
/// pages you want to get OCR result. For a range of pages, use a hyphen.
/// Separate each page or range with a comma.
/// <para>
/// Custom page numbers for multi-page documents(PDF/TIFF). Input the page numbers
/// and/or ranges of pages you want to get in the result. For a range of pages, use a hyphen, like
/// `Pages = { "1-3", "5-6" }`. Separate each page number or range with a comma.
/// </para>
/// <para>
/// Although this collection cannot be set, it can be modified.
/// See <a href="https://docs.microsoft.com/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers#collection-initializers">collection initializer</a>.
/// </para>
/// </summary>
public IEnumerable<string> Pages { get; set; }
public IList<string> Pages { get; } = new List<string>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public async Task StartRecognizeContentWithOnePageArgument(string pages, int exp
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeContentAsync(stream, new RecognizeContentOptions() { Pages = new List<string> { pages } });
operation = await client.StartRecognizeContentAsync(stream, new RecognizeContentOptions() { Pages = { pages } });
}

FormPageCollection formPages = await operation.WaitForCompletionAsync(PollingInterval);
Expand All @@ -480,7 +480,7 @@ public async Task StartRecognizeContentWithMultiplePageArgument(string page1, st
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeContentAsync(stream, new RecognizeContentOptions() { Pages = new List<string> { page1, page2 } });
operation = await client.StartRecognizeContentAsync(stream, new RecognizeContentOptions() { Pages = { page1, page2 } });
}

FormPageCollection formPages = await operation.WaitForCompletionAsync(PollingInterval);
Expand Down

0 comments on commit 5e37818

Please sign in to comment.