-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
champion-requiredNeeds internal champion to shepherd issueNeeds internal champion to shepherd issuecode cleanupcleanup code for unused apis/properties/comments - no functional changes.cleanup code for unused apis/properties/comments - no functional changes.
Milestone
Description
- .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use
dotnet --info) - Have you experienced this same bug with .NET Framework?: Yes/No
Problem description:
Discovered as part of a review of #1955.
Having enabled SA1408 the analyser flagged the following issue:
// NB: the snippet is re-formatted to increase readability
internal override bool CanAccessProperties
{
get
{
int ocState = GetOcState();
return axState[fOwnWindow] && (ocState > OC_RUNNING || (IsUserMode() && ocState >= OC_RUNNING)) || ocState >= OC_INPLACE;
}
}winforms/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs
Lines 526 to 535 in 7019e14
| internal override bool CanAccessProperties | |
| { | |
| get | |
| { | |
| int ocState = GetOcState(); | |
| return (axState[fOwnWindow] && | |
| (ocState > OC_RUNNING || (IsUserMode() && ocState >= OC_RUNNING)) || | |
| ocState >= OC_INPLACE); | |
| } | |
| } |
Actual behavior:
The intent is unclear.
- Is the following a correct expectation:
ocState >= OC_INPLACE- OR -axState[fOwnWindow] && (ocState > OC_RUNNING || (IsUserMode() && ocState >= OC_RUNNING))? - In
ocState > OC_RUNNING || (IsUserMode() && ocState >= OC_RUNNING)condition the second>is redundant, as ifocState > OC_RUNNINGthe condition will betrueon the first operand
Expected behavior:
The code is written in a manner that clearly communicates the intent and a desired outcome.
Metadata
Metadata
Assignees
Labels
champion-requiredNeeds internal champion to shepherd issueNeeds internal champion to shepherd issuecode cleanupcleanup code for unused apis/properties/comments - no functional changes.cleanup code for unused apis/properties/comments - no functional changes.