Repository navigation
all appearances of "== null" are replaced with "is null" and all appe… - #3469
sashatankov wants to merge 2 commits into
Conversation
…arances of "!= null" are replaced with "is not null"
| } | ||
|
|
||
| Debug.Fail("No conversion from " + value == null ? "null" : value.GetType().FullName + " to byte[]"); | ||
| Debug.Fail("No conversion from " + value is null ? "null" : value.GetType().FullName + " to byte[]"); |
There was a problem hiding this comment.
Anyone know if this change (from == to is) is safe in terms of operator precedence? Or are there edge cases which needs adding braces?
(Not speaking of this particular instance, which is probably ok, but in general terms)
There was a problem hiding this comment.
My understanding it is the same operation, just safer.
@jaredpar can you confirm?
There was a problem hiding this comment.
TLDR: This is a safe change. The is and == operator have virtually the same precedence so the only realistic change here is moving from a custom == operator to a direct null or non-null check (which is the intent of this PR).
Messy Details
The is operator does have higher precedence than == which means in certain pathological cases this could alter the evaluation order. At the same time is and ==, as well as all the relational operators, are directly next to each other in the precedence table so you'd need a decently pathological to see this occur. Essentially something in the form of a == b == null where you change the second == to is and you have some operators defined over bool.
This is a working example of the type of code you'd need to see this in action. Changing the second == to is will change the code from producing a warning to binding to the custom equality operator.
Again though that is pretty out there. It's not something I'd really focus on for a change like this. I included it only for completeness.
| finally | ||
| { | ||
| if (pipeClient != null) | ||
| if (pipeClient is not null) |
There was a problem hiding this comment.
This is C#9 feature, which hasn't been released yet. I don't think this will work prior to VS 16.7.
So let's concentrate on == null -> is null only, until C#9 is shipped.
There was a problem hiding this comment.
Ok, so I change only the "is not null" appearances to "!=null". see my last commit
|
|
||
| /// <summary> | ||
| /// Adds a Node with given label and value to the parent, provided the parent is not null; | ||
| /// Adds a Node with given label and value to the parent, provided the parent != null; |
There was a problem hiding this comment.
We shouldn't change comments
|
|
||
| /// <summary> | ||
| /// Creates an instance of the specified type. The default implementation will create the object. If the object implements IComponent and only requires an empty or IContainer style constructor, this will search for IDesignerHost and create through the host. Otherwise it will use reflection. If addToContainer is true, this will add to the container using this class's Conainer property, using the name provided if it is not null. | ||
| /// Creates an instance of the specified type. The default implementation will create the object. If the object implements IComponent and only requires an empty or IContainer style constructor, this will search for IDesignerHost and create through the host. Otherwise it will use reflection. If addToContainer is true, this will add to the container using this class's Conainer property, using the name provided if it != null. |
|
Please complete filling the PR description. |
|
There are too may files changed, this will take too long to review. Please send separate PRs for each project. |
…arances of "!= null" are replaced with "is not null"
Fixes #
Proposed changes
Customer Impact
Regression?
Risk
Screenshots
Before
After
Test methodology
Accessibility testing
Test environment(s)
Microsoft Reviewers: Open in CodeFlow