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

Couple of code fixes #7731

Merged
merged 1 commit into from
Jan 6, 2016
Merged

Couple of code fixes #7731

merged 1 commit into from
Jan 6, 2016

Conversation

jaredpar
Copy link
Member

Corrects a couple of items noted in #7677

@jaredpar
Copy link
Member Author

CC @dotnet/roslyn-compiler, @dotnet/roslyn-ide

A code analysis utility was run against the Roslyn repo and filed as #7677. I did a quick sweep through the issues noted and fixed up a number of them in this PR. The type of changes fixed were:

  • Double writes to a local with no read in the middle. Typically in unit tests where we forgot to make an assertion on the result of an operation.
  • Incorrect usages of a format string in a string.Format call.
  • An if statement or ?: operation where true and false were the same.
  • Bad null checks on the result of as expressions

@@ -274,13 +274,6 @@ internal static bool ReportConflictWithParameter(Symbol parameter, Symbol newSym
return false;
}

if (newSymbolKind == SymbolKind.Parameter || newSymbolKind == SymbolKind.Local)
Copy link
Member Author

Choose a reason for hiding this comment

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

Expand the review up a few lines and you'll see an identical check being made which unconditionally returns in the if body. Hence this code path should never get hit.

Copy link
Member

Choose a reason for hiding this comment

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

Any sense how this snuck in? Merge issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was done as a part of a single commit. It's possible there was a local merge issue that caused this though.

@jaredpar
Copy link
Member Author

Updated to respond to PR feedback.

@gafter
Copy link
Member

gafter commented Dec 30, 2015

LGTM

2 similar comments
@VSadov
Copy link
Member

VSadov commented Dec 30, 2015

LGTM

@AlekseyTs
Copy link
Contributor

LGTM

thread2.Start();
thread1.Start();
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Member

Choose a reason for hiding this comment

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

Read the context. The purpose of the enclosing if statement is to permute the order in which the threads are started.

Copy link
Member

Choose a reason for hiding this comment

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

The OS makes no guarantee that the threads run in the order started, so why pretend?

Copy link
Member

Choose a reason for hiding this comment

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

Because it helps test for nondeterministic behavior.

@jaredpar
Copy link
Member Author

jaredpar commented Jan 2, 2016

Anyone from @dotnet/roslyn-ide able to sign off on the IDE portion of the change?

@@ -161,7 +169,7 @@ private void ObjectEquals3()
var allValues = _equalityUnits.SelectMany(x => x.AllValues);
foreach (var value in allValues)
{
Assert.NotEqual((object)42, value);
Assert.False(value.Equals((object)42));
Copy link
Member

Choose a reason for hiding this comment

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

Why the change? Just to make sure you don't get surprised by xunit behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jasonmalinowski the intent of this check was to verify the behavior of object.Equals(object). It seemed wrong to rely on this being tested as an implementation detail of Assert.NotEqual (and in fact it doesn't guarantee this). Much more direct to just call it directly.

@jasonmalinowski
Copy link
Member

👍. Also, please either edit the "PR Feedback" commit with a proper description of the change, or just squash it.

Corrects a couple of items noted in dotnet#7677
@jaredpar
Copy link
Member Author

jaredpar commented Jan 5, 2016

@jasonmalinowski will do on the squash.

During the active review of a PR I generally avoid rebasing if possible. This helps keep the comments relevant and seems to generally let things flow better. Once it gets signed off I squash, push, wait for Jenknis and merge.

jaredpar added a commit that referenced this pull request Jan 6, 2016
@jaredpar jaredpar merged commit 94e165a into dotnet:master Jan 6, 2016
@jaredpar jaredpar deleted the bug-7677 branch August 21, 2018 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants