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

Set CA1001 to "Error" and resolved issues #1826

Merged
merged 9 commits into from
Oct 1, 2021
Merged

Set CA1001 to "Error" and resolved issues #1826

merged 9 commits into from
Oct 1, 2021

Conversation

kgar
Copy link
Contributor

@kgar kgar commented Sep 29, 2021

closes #1423

For classes with disposable members, made those classes implement IDisposable, using the recommended Dispose() methods.

This created a ripple effect where the newly disposable classes needed to be disposed of wherever used.

Updated documentation, examples, sample code, and demos where BrowserFetcher is used and could be disposed.

@kblok sorry, this one has got a lot of changes. Documentation aside, the rest was necessary to satisfy the analyzer.

@@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net471</TargetFrameworks>
<LangVersion>7.3</LangVersion>
<LangVersion>8.0</LangVersion>
Copy link
Member

Choose a reason for hiding this comment

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

<3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those using statements are the spice of life

@@ -30,7 +30,7 @@ namespace PuppeteerSharp
/// var browser = await await Puppeteer.LaunchAsync(new LaunchOptions { ExecutablePath = revisionInfo.ExecutablePath});
/// </code>
/// </example>
public class BrowserFetcher
public class BrowserFetcher : IDisposable
Copy link
Member

Choose a reason for hiding this comment

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

This will mean a breaking change and a major version 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.

I was getting nervous, the more files that changed 😱

Copy link
Member

@kblok kblok left a comment

Choose a reason for hiding this comment

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

Great job!
Quite painful, but needed.

@kblok
Copy link
Member

kblok commented Sep 30, 2021

It seems the build broke badly https://ci.appveyor.com/project/kblok/puppeteer-sharp/builds/40962024

@kgar
Copy link
Contributor Author

kgar commented Sep 30, 2021

I see the problem. I'm checking a few things over on MSDN, but I should have the tests passing again.

@kgar
Copy link
Contributor Author

kgar commented Sep 30, 2021

The issue was I disposed of the timeout task before cancellation had put the task into a finalized state. I think we're ok not to dispose of the timeout task, as the cancellation token source will ensure that the task gets sorted out.

…ction.cs to resolve issues of transport events firing against the _callbackQueue's disposed semaphore.

Added ScreenshotTaskQueue disposal to Browser.cs after the async disposals occur.
@kblok
Copy link
Member

kblok commented Sep 30, 2021

It seems netcore builds are getting stuck on ShouldSupportCustomTransport

@kgar
Copy link
Contributor Author

kgar commented Sep 30, 2021

I'm looking forward to figuring this one out 👀

…g queued calls to finish before it disposes of the semaphore.

Updated TaskQueue to implement IAsyncDisposable and delegated the Dispose method to use DisposeAsync, in a discard task.

Set Browser to call TaskQueue.DisposeAsync() rather than .Dispose().

Set Page to call TaskQueue.DisposeAsync() instead of .Dispose(). Also delegated Dispose's discard task to DisposeAsync(), as they were logically equivalent.
@kblok kblok merged commit 47798cc into hardkoded:master Oct 1, 2021
@kgar kgar deleted the Implement-CA1001 branch October 1, 2021 19:10
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.

Enable CA1001 rule
2 participants