Skip to content

Catch exception in TryConvertTo [updated] - #39649

Merged
2 commits merged into
mainfrom
pr/33594
Jan 21, 2022
Merged

2 commits merged into
mainfrom
pr/33594

Conversation

@SteveSandersonMS

Copy link
Copy Markdown
Member

This is a continuation of #33594. I had to create a new PR because the original one was no longer mergeable and further tweaks were needed.

Add test cases for trying to convert valid and invalid GUID values.

Catch exception in TryConvertTo

Catch when the converter throws an exception and return false and set the out value to default.

Change to Guid specific Converter

Remove try/catch added in TryConvertTo  and replace with Guid Converter

Add case for Nullable Guid

Add tests for NullableGuid

Fix NullableGuid parse reflect a null as parsed
@SteveSandersonMS SteveSandersonMS added the area-blazor Includes: Blazor, Razor Components label Jan 20, 2022
@SteveSandersonMS
SteveSandersonMS requested a review from a team January 20, 2022 11:12
{
parser = ConvertToGuid;
}
else if (typeof(T) == typeof(Guid?))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda unrelated - I imagine this block of code would look a lot nicer as a switch expression.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, probably. This code predates switch expressions. Keeping this out-of-scope for the PR though.

@ghost

ghost commented Jan 21, 2022

Copy link
Copy Markdown

Hello @SteveSandersonMS!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
ghost merged commit cb80a40 into main Jan 21, 2022
@ghost
ghost deleted the pr/33594 branch January 21, 2022 15:41
ShreyasJejurkar pushed a commit to ShreyasJejurkar/aspnetcore that referenced this pull request Jan 22, 2022
* Add test for TryConvertTo for GUID type

Add test cases for trying to convert valid and invalid GUID values.

Catch exception in TryConvertTo

Catch when the converter throws an exception and return false and set the out value to default.

Change to Guid specific Converter

Remove try/catch added in TryConvertTo  and replace with Guid Converter

Add case for Nullable Guid

Add tests for NullableGuid

Fix NullableGuid parse reflect a null as parsed

* Update src/Components/Components/test/BindConverterTest.cs

Co-authored-by: Jeff Layton <jeffl8n@users.noreply.github.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants