Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding TryParse() methods to every AsX method in FieldValue and DocumentField #15945

Closed
maririos opened this issue Oct 14, 2020 · 3 comments
Assignees
Labels
blocking-release Blocks release Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer
Milestone

Comments

@maririos
Copy link
Member

maririos commented Oct 14, 2020

Feedback from our customers where when trying our AsX where X is a type methods in FieldValue and DocumentField we throw exception when the Type doesn't match.
It will be more convenient to have a TryParse method that the user can call that will return a bool value.
See https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/exceptions-and-performance#try-parse-pattern

@maririos maririos added Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer labels Oct 14, 2020
@maririos maririos added this to the [2020] November milestone Oct 14, 2020
@maririos maririos self-assigned this Jan 25, 2021
@maririos maririos modified the milestones: [2021] February, [2021] March Feb 4, 2021
@maririos
Copy link
Member Author

We need to understand which scenarios are causing the throwing and if the if ( xx is type chu) is enough or not

@maririos maririos added the blocking-release Blocks release label Feb 16, 2021
@maririos maririos assigned maririos and unassigned maririos Feb 16, 2021
@maririos maririos removed their assignment Feb 23, 2021
@maririos maririos modified the milestones: [2021] March, [2021] April Mar 5, 2021
@maririos maririos modified the milestones: [2021] April, [2021] May Apr 1, 2021
@maririos maririos self-assigned this Apr 14, 2021
@maririos maririos removed the blocking-release Blocks release label May 5, 2021
@maririos maririos modified the milestones: [2021] May, Backlog May 5, 2021
@maririos
Copy link
Member Author

maririos commented May 5, 2021

Moving to backlog while working on the design. According to when it is ready and approved will add to an active milestone

@kinelski kinelski modified the milestone: [2022] March Jan 11, 2022
@kinelski kinelski modified the milestones: [2022] March, [2022] April Feb 10, 2022
@kinelski kinelski changed the title Consider adding TryParse() methods to every AsX method in FieldValue Consider adding TryParse() methods to every AsX method in FieldValue and DocumentField Mar 17, 2022
@jsquire jsquire modified the milestones: [2022] April, Backlog Apr 15, 2022
@kinelski kinelski modified the milestones: Backlog, [2022] May Apr 19, 2022
@kinelski kinelski modified the milestones: [2022] May, [2022] June May 12, 2022
@jsquire jsquire modified the milestones: [2022] June, [2022] July Jun 14, 2022
@kinelski kinelski added the blocking-release Blocks release label Jun 21, 2022
@kinelski kinelski self-assigned this Jun 24, 2022
@jsquire jsquire modified the milestones: 2022-07, 2022-08 Jul 15, 2022
@kinelski kinelski modified the milestones: 2022-08, 2022-09 Aug 11, 2022
@kinelski
Copy link
Member

kinelski commented Sep 7, 2022

After discussing this matter with architects, we won't implement AsX methods as it could just make the class more confusing to customers.

We decided to add an DocumentFieldType.Unknown enum value that can be used in these scenarios. More information here: #30909

Updated the way DocumentField is handled. When the field value is not returned by the service (which happens when they can't parse the extracted value into the expected type), we set DocumentField.FieldType to DocumentFieldType.Unknown in the SDK. Customers could then use the DocumentField.ExpectedFieldType in addition to the raw string DocumentField.Content to manually parse the field value in this case. This change permits handling this scenario without try/catch blocks (current approach).

@kinelski kinelski closed this as completed Sep 7, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocking-release Blocks release Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer
Projects
None yet
Development

No branches or pull requests

3 participants