Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Introduce Component as the base type for a few components#12324

Merged
AlexGhiondea merged 2 commits intodotnet:masterfrom
AlexGhiondea:ComponentAsBaseType_12154
Oct 4, 2016
Merged

Introduce Component as the base type for a few components#12324
AlexGhiondea merged 2 commits intodotnet:masterfrom
AlexGhiondea:ComponentAsBaseType_12154

Conversation

@AlexGhiondea
Copy link
Copy Markdown
Contributor

The following types were changed to derive from Component:

  • WebClient
  • FileSystemWatcher
  • Ping
  • BackgroundWorker
  • Process
  • ProcessModule
  • ProcessThread

Fixes #12154

@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

/cc @weshaggard @stephentoub

namespace System.ComponentModel
{
public class BackgroundWorker : IDisposable
public class BackgroundWorker : System.ComponentModel.Component
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IIRC, because Component wasn't a base class, we added finalizers to some of these derived types like BackgroundWorker, so that if types derived from BackgroundWorker and override Dispose(bool), they would still have their Dispose method called on finalization (since Component has one). Now that we're adding back Component, we should remove such finalizers we added just to core. In addition to being unnecessary, they could actually lead to problems, if they result in Dispose(false) being executed twice for an instance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed -- there were quite a few places where I had to remove the Dispose method we introduced before this.

/// information about the module.
/// </devdoc>
public class ProcessModule
public class ProcessModule : System.ComponentModel.Component
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For all of these, can we add using System.ComponentModel; rather than including the namespace here?

@stephentoub
Copy link
Copy Markdown
Member

A few comments, otherwise LGTM

The following types were changed to derive from Component:
- WebClient
- FileSystemWatcher
- Ping
- BackgroundWorker
- Process
- ProcessModule
- ProcessThread
@AlexGhiondea AlexGhiondea force-pushed the ComponentAsBaseType_12154 branch from 7f0ce62 to 94f1481 Compare October 4, 2016 17:27
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'==''">
<ProjectReference Include="..\..\pkg\System.Net.Ping.pkgproj">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This pkgproj ProjectReference should work for both 1.3 and 1.7 configurations. Why did you need to move to a package reference for some cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without this the netcoreapp1.0 tests were not able to resolve the asset for it.

<OSGroup>Windows_NT</OSGroup>
<TargetGroup>netstandard1.3</TargetGroup>
</Project>
<Project Include="FunctionalTests\System.Net.Ping.Functional.Tests.csproj">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please put the default TargetGroup in the group at the top of the file see #12312 for reference.

@AlexGhiondea AlexGhiondea merged commit f1b7585 into dotnet:master Oct 4, 2016
@stephentoub
Copy link
Copy Markdown
Member

@AlexGhiondea, you didn't remove the finalizers as I mentioned?

@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

@stephentoub I was 100% sure you meant the Dispose methods we added. Created #12360 to remove the actual finalizers.

@AlexGhiondea AlexGhiondea deleted the ComponentAsBaseType_12154 branch October 5, 2016 17:43
@karelz karelz modified the milestone: 1.2.0 Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…aseType_12154

Introduce Component as the base type for a few components

Commit migrated from dotnet/corefx@f1b7585
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants