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

Enable IDE0059 analyzer: Unnecessary assignment of a value #63340

Merged
merged 8 commits into from
Jan 12, 2022

Conversation

marek-safar
Copy link
Contributor

No description provided.

@ghost
Copy link

ghost commented Jan 4, 2022

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: marek-safar
Assignees: marek-safar
Labels:

area-Meta

Milestone: -

@@ -281,7 +281,7 @@ private static void CheckReceivedBy(string receivedBy)

// 'receivedBy' can either be a host or a token. Since a token is a valid host, we only verify if the value
// is a valid host.;
if (HttpRuleParser.GetHostLength(receivedBy, 0, true, out string? host) != receivedBy.Length)
if (HttpRuleParser.GetHostLength(receivedBy, 0, true, out _) != receivedBy.Length)
Copy link
Member

Choose a reason for hiding this comment

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

@geoffkizer, not sure how much it actually matters, but looking at the call sites to GetHostLength, it seems several of them end up ignoring the out string host even though the method will end up allocating one, regardless. Might be worth a look, and if there are other similar cases that could be improved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this is ugly. The usual pattern of the GetXLength methods here and elsewhere is that they return an int to indicate the length, but don't actually construct the substring, which the caller can do trivially. Not sure why this one is different. I'll take a look.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #63641
See also #63640

@@ -9,15 +9,6 @@ namespace System.Net.NetworkInformation
{
public partial class NetworkChange
{
static NetworkChange()
{
// fake usage of static readonly fields to avoid getting CA1823 warning when we are compiling this partial.
Copy link
Member

Choose a reason for hiding this comment

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

Is this not accurate?

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 was but I changed csproj file not to pull these private fields at all

@marek-safar
Copy link
Contributor Author

Failures are unrelated due to OSError: [Errno 28] No space left on device

@marek-safar marek-safar merged commit 6de7147 into dotnet:main Jan 12, 2022
@marek-safar marek-safar deleted the ide0059 branch January 12, 2022 17:10
@ghost ghost locked as resolved and limited conversation to collaborators Feb 11, 2022
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.

5 participants