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

Code Coverage for DownloadFile Review 1St #12486

Open
wants to merge 61 commits into
base: main
Choose a base branch
from

Conversation

paul1956
Copy link
Contributor

@paul1956 paul1956 commented Nov 14, 2024

Replace corrupt PR12221

Proposed changes

  • Code Coverage for DownloadFile

Customer Impact

  • This adds code coverage for DownloadFile which will be required to replace obsolete WebClient.

Regression?

  • No

Risk

-None

Test environment(s)

Microsoft Reviewers: Open in CodeFlow

@paul1956 paul1956 requested a review from a team as a code owner November 14, 2024 19:22
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 97.99416% with 55 lines in your changes missing coverage. Please review.

Project coverage is 76.34958%. Comparing base (ce6b6c2) to head (6509c30).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #12486         +/-   ##
===================================================
+ Coverage   76.14673%   76.34958%   +0.20284%     
===================================================
  Files           3191        3195          +4     
  Lines         640105      642830       +2725     
  Branches       47233       47372        +139     
===================================================
+ Hits          487419      490798       +3379     
+ Misses        149166      148510        -656     
- Partials        3520        3522          +2     
Flag Coverage Δ
Debug 76.34958% <97.99416%> (+0.20284%) ⬆️
integration 18.16949% <0.00000%> (-0.00074%) ⬇️
production 50.30540% <93.10345%> (+0.25320%) ⬆️
test 97.03390% <98.04644%> (+0.00628%) ⬆️
unit 47.52590% <93.10345%> (+0.26462%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

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

I would suggest factoring out the following files into a standalone PR:
SingleInstanceHelpers.vb
WindowsFormsApplicationBase.vb
Network.DownloadFile.vb
Interaction.vb
ClipboardProxy.vb
SingleInstanceHelpersTests.vb
TestUtilitiesTests.vb
PathSeparatorTestData.vb
VbFileCleanupTestBase.vb

They contain only cleanup changes and are ready to be merged while we discuss HTTPListener use within the team.

''' </summary>
''' <returns><see langword="True"/> if an audio stream is available, otherwise <see langword="False"/>.</returns>
''' <returns>
''' see langword="True"/> if an audio <see cref="Stream"/> is available,
Copy link
Member

Choose a reason for hiding this comment

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

This could be a single line, it's not long enough to be broken.


Friend Function ProcessRequests() As HttpListener
' Create a listener and add the prefixes.
Dim listener As New HttpListener()
Copy link
Member

Choose a reason for hiding this comment

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

For my education, what is the purpose of WebClientCopy class?

_webClient.DownloadFile(address, destinationFileName)
End If
Catch ex As WebException
If ex.Message.Contains("401") Then
Copy link
Member

Choose a reason for hiding this comment

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

It's usually good to keep the original exception for context. Why do we have to introduce our own messages? Can we set the original exception as the inner one?

Copy link
Member

Choose a reason for hiding this comment

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

THe same comment applies to the Upload method.

Copy link
Contributor Author

@paul1956 paul1956 Jan 8, 2025

Choose a reason for hiding this comment

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

My WebServerListner is implemented with HTTPClient, the existing code expects WebClient Errors. This code translates the errors, so they are compatible with existing code. When WebClient and WebClientCopy go away and upload and download use HTTPClient the same translation will happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WinForms only handle 2 specific Exceptions Timeout, Unauthorized plus a generic WebException.
When I run the existing code using WebClient I can get almost complete coverage of DownloadFile and UploadFile and the generic exception is never used. With HttpClient I handle the generic exception and use it for testing.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, we shouldn't add new exceptions for testing purposes only. New exceptions is a breaking change and we need an apparent benefit gained from making such a change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's usually good to keep the original exception for context. Why do we have to introduce our own messages? Can we set the original exception as the inner one?

@Tanya-Solyanik
We are reproducing WebClient Exceptions, HttpClient returns HttpErrors. From what I can tell WinForms only cares about 3 WebClient Exceptions (Timeout, Unauthorized and a generic catch all which is not used by WinForms today).

I have no visibility into all the errors that WebClient can possibly throw but WinForms works consistently with know and unknown errors.

The goal is no breaking exception changes.

@Tanya-Solyanik Tanya-Solyanik added the 📭 waiting-author-feedback The team requires more information from the author label Jan 8, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 📭 waiting-author-feedback The team requires more information from the author label Jan 8, 2025
@paul1956
Copy link
Contributor Author

paul1956 commented Jan 8, 2025

I would suggest factoring out the following files into a standalone PR: SingleInstanceHelpers.vb WindowsFormsApplicationBase.vb Network.DownloadFile.vb Interaction.vb ClipboardProxy.vb SingleInstanceHelpersTests.vb TestUtilitiesTests.vb PathSeparatorTestData.vb VbFileCleanupTestBase.vb

They contain only cleanup changes and are ready to be merged while we discuss HTTPListener use within the team.

@Tanya-Solyanik #12730 is all the cleanup

@Tanya-Solyanik Tanya-Solyanik added the 📭 waiting-author-feedback The team requires more information from the author label Jan 8, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 📭 waiting-author-feedback The team requires more information from the author label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants