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

Remove unused locals in System.ServiceProcess.ServiceController #31704

Merged
merged 3 commits into from
Feb 4, 2020

Conversation

nxtn
Copy link
Contributor

@nxtn nxtn commented Feb 4, 2020

Contributes to #30457

When implemented in a derived class, the needs of your application determine what value to return. For example, if a QuerySuspend broadcast status is passed, you could cause your application to reject the query by returning false.

@@ -474,7 +474,7 @@ private void DeferredPowerEvent(int eventType, IntPtr eventData)
try
{
PowerBroadcastStatus status = (PowerBroadcastStatus)eventType;
bool statusResult = OnPowerEvent(status);
_ = OnPowerEvent(status);
Copy link
Member

Choose a reason for hiding this comment

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

This can just be:

OnPowerEvent((PowerBroadcastStatus)eventType);

@@ -473,8 +473,7 @@ private void DeferredPowerEvent(int eventType, IntPtr eventData)
// already been freed.
try
{
PowerBroadcastStatus status = (PowerBroadcastStatus)eventType;
_ = OnPowerEvent(status);
_ = OnPowerEvent((PowerBroadcastStatus)eventType);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_ = OnPowerEvent((PowerBroadcastStatus)eventType);
OnPowerEvent((PowerBroadcastStatus)eventType);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When would you prefer discards?

Copy link
Member

Choose a reason for hiding this comment

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

When would you prefer discards?

For ignored return values, only if it's critical that someone reading the code understands data is being thrown away, or if the compiler complains. The former might show up in one of our security libraries, for example. The latter might show up with a method returning a Task in an async method and where we explicitly want to ignore it.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks

@stephentoub stephentoub merged commit f836a08 into dotnet:master Feb 4, 2020
@nxtn nxtn deleted the servicecontroller branch February 4, 2020 07:30
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants