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 IDE0100 Remove redundant equality #7919

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/CodeAnalysis.src.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ dotnet_diagnostic.IDE0084.severity = none
dotnet_diagnostic.IDE0090.severity = silent

# IDE0100: Remove redundant equality
dotnet_diagnostic.IDE0100.severity = none # TODO: warning
dotnet_diagnostic.IDE0100.severity = warning

# IDE0110: Remove unnecessary discard
dotnet_diagnostic.IDE0110.severity = none # TODO: warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
' But the user may be doing an AddHandler of their own in which case we need
' to make sure to honor the request. If we aren't past OnInitialize() yet
' we shouldn't do it but the flag above catches that case.
If _networkObject Is Nothing And _finishedOnInitialize = True Then
If _networkObject Is Nothing AndAlso _finishedOnInitialize Then
_networkObject = New Devices.Network
Dim windowsFormsApplicationBase As WindowsFormsApplicationBase = Me
AddHandler _networkObject.NetworkAvailabilityChanged,
Expand Down Expand Up @@ -567,7 +567,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
' during the NetworkAvailabilityChanged event. This problem would just extend itself to any future
' callback that involved the asyncOperationsManager so this is where we need to create objects that
' have a asyncOperationsContext in them.
If _turnOnNetworkListener = True And _networkObject Is Nothing Then
If _turnOnNetworkListener And _networkObject Is Nothing Then

' The is-nothing-check is to avoid hooking the object more than once.
_networkObject = New Devices.Network
Expand All @@ -590,7 +590,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
RaiseEvent StartupNextInstance(Me, eventArgs)

' Activate the original instance.
If eventArgs.BringToForeground = True AndAlso MainForm IsNot Nothing Then
If eventArgs.BringToForeground AndAlso MainForm IsNot Nothing Then
If MainForm.WindowState = FormWindowState.Minimized Then
MainForm.WindowState = FormWindowState.Normal
End If
Expand Down Expand Up @@ -681,7 +681,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
' We don't put a try/catch around the handler event so that exceptions in there will
' bubble out - else we will have a recursive exception handler.
RaiseEvent UnhandledException(Me, e)
If e.ExitApplication = True Then Application.Exit()
If e.ExitApplication Then Application.Exit()

' User handled the event.
Return True
Expand Down Expand Up @@ -960,7 +960,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
' need to be mirrored in the ELSE debugger attached clause below.
Try
If OnInitialize(CommandLineArgs) Then
If OnStartup(EventArgs) = True Then
If OnStartup(EventArgs) Then
OnRun()
OnShutdown()
End If
Expand All @@ -978,7 +978,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices

' We had an exception, but not during the OnUnhandledException handler so give the user
' a chance to look at what happened in the UnhandledException event handler
If Not OnUnhandledException(New UnhandledExceptionEventArgs(True, ex)) = True Then
If Not OnUnhandledException(New UnhandledExceptionEventArgs(True, ex)) Then

' The user didn't write a handler so throw the error out to the system
Throw
Expand All @@ -991,7 +991,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
' We also don't hook up the Application.ThreadException event because WinForms ignores it
' when we are running under the debugger.
If OnInitialize(CommandLineArgs) Then
If OnStartup(EventArgs) = True Then
If OnStartup(EventArgs) Then
OnRun()
OnShutdown()
End If
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ private bool ShouldClearCollection(IDesignerSerializationManager manager, IColle
{
bool shouldClear = false;
PropertyDescriptor clearProp = manager.Properties["ClearCollections"];
if (clearProp is not null && clearProp.PropertyType == typeof(bool) && ((bool)clearProp.GetValue(manager) == true))
if (clearProp is not null && clearProp.PropertyType == typeof(bool) && ((bool)clearProp.GetValue(manager)))
{
shouldClear = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public virtual object Deserialize(IDesignerSerializationManager manager, CodeTyp

// Interesting problem. The CodeDom parser may auto generate statements that are associated with other methods. VB does this, for example, to create statements automatically for Handles clauses. The problem with this technique is that we will end up with statements that are related to variables that live solely in user code and not in InitializeComponent. We will attempt to construct instances of these objects with limited success. To guard against this, we check to see if the manager even supports this feature, and if it does, we must look out for these statements while filling the statement collections.
PropertyDescriptor supportGenerate = manager.Properties["SupportsStatementGeneration"];
if (supportGenerate is not null && supportGenerate.PropertyType == typeof(bool) && ((bool)supportGenerate.GetValue(manager)) == true)
if (supportGenerate is not null && supportGenerate.PropertyType == typeof(bool) && ((bool)supportGenerate.GetValue(manager)))
{
// Ok, we must do the more expensive work of validating the statements we get.
foreach (string name in _nameTable.Keys)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected Behavior()
/// </param>
protected Behavior(bool callParentBehavior, BehaviorService? behaviorService)
{
if ((callParentBehavior == true) && (behaviorService == null))
if ((callParentBehavior) && (behaviorService == null))
{
throw new ArgumentException(null, nameof(behaviorService));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private bool AddControlSnaplinesWhenResizing(ControlDesigner designer, Control c
// do not add snaplines if we are resizing the control is a container control with AutoSize set to true and the control is the parent of the targetControl
if (_resizing &&
(designer is ParentControlDesigner) &&
(control.AutoSize == true) &&
(control.AutoSize) &&
(targetControl != null) &&
(targetControl.Parent != null) &&
(targetControl.Parent.Equals(control)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ internal static int AdjustPixelsForIntegralHeight(Control control, int pixelsMov
if (propIntegralHeight != null)
{
object value = propIntegralHeight.GetValue(control);
if (value is bool && (bool)value == true)
if (value is bool && (bool)value)
{
PropertyDescriptor propItemHeight = TypeDescriptor.GetProperties(control)["ItemHeight"];
if (propItemHeight != null)
Expand Down Expand Up @@ -566,7 +566,7 @@ public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc)
if (propIntegralHeight != null)
{
object value = propIntegralHeight.GetValue(targetControl);
if (value is bool && (bool)value == true)
if (value is bool && (bool)value)
{
shouldSnapHorizontally = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ protected void OnMenuAlignToGrid(object sender, EventArgs e)
{
// first check to see if the component is locked, if so - don't move it...
PropertyDescriptor lockedProp = GetProperty(comp, "Locked");
if (lockedProp != null && ((bool)lockedProp.GetValue(comp)) == true)
if (lockedProp != null && ((bool)lockedProp.GetValue(comp)))
{
continue;
}
Expand Down Expand Up @@ -1463,7 +1463,7 @@ protected void OnMenuCenterSelection(object sender, EventArgs e)
// Also, skip all locked components...
//
PropertyDescriptor lockProp = props["Locked"];
if (lockProp != null && (bool)lockProp.GetValue(comp) == true)
if (lockProp != null && (bool)lockProp.GetValue(comp))
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2470,7 +2470,7 @@ private void OnSetCursor()
return;
}

if (prop != null && ((bool)prop.GetValue(_component)) == true)
if (prop != null && ((bool)prop.GetValue(_component)))
{
Cursor.Current = Cursors.Default;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ protected void OnKeySize(object sender, EventArgs e)
if (propIntegralHeight != null)
{
object value = propIntegralHeight.GetValue(component);
if (value is bool && (bool)value == true)
if (value is bool && (bool)value)
{
PropertyDescriptor propItemHeight = TypeDescriptor.GetProperties(component)["ItemHeight"];
if (propItemHeight != null)
Expand Down Expand Up @@ -1215,7 +1215,7 @@ protected void OnStatusLockControls(object sender, EventArgs e)
//Get the locked property of the base control first...
//
PropertyDescriptor lockedProp = TypeDescriptor.GetProperties(baseControl)["Locked"];
if (lockedProp != null && ((bool)lockedProp.GetValue(baseControl)) == true)
if (lockedProp != null && ((bool)lockedProp.GetValue(baseControl)))
{
cmd.Checked = true;
return;
Expand All @@ -1233,7 +1233,7 @@ protected void OnStatusLockControls(object sender, EventArgs e)
foreach (object component in baseDesigner.AssociatedComponents)
{
lockedProp = TypeDescriptor.GetProperties(component)["Locked"];
if (lockedProp != null && ((bool)lockedProp.GetValue(component)) == true)
if (lockedProp != null && ((bool)lockedProp.GetValue(component)))
{
cmd.Checked = true;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public virtual SelectionRules SelectionRules
object value = pd.GetValue(component);

// Make sure that value is a boolean, in case someone else added this property
if (value is bool boolean && boolean == true)
if (value is bool boolean && boolean)
{
rules = SelectionRules.Locked | SelectionRules.Visible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public override SelectionRules SelectionRules
if (propAuto != null)
{
object auto = propAuto.GetValue(component);
if (auto is bool && (bool)auto == true)
if (auto is bool && (bool)auto)
{
rules &= ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ public virtual bool AllowNew
// Don't let user set value to true if inner list can never support adding of items
// do NOT check for a default constructor because someone will set AllowNew=True
// when they have overridden OnAddingNew (which we cannot detect).
if (value == true && !_isBindingList && !IsListWriteable(checkConstructor: false))
if (value && !_isBindingList && !IsListWriteable(checkConstructor: false))
{
throw new InvalidOperationException(SR.NoAllowNewOnReadOnlyList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ private void LbnSelChange()
AccessibilityNotifyClients(AccessibleEvents.Selection, index);

//# VS7 86
if (!_killnextselect && (index == _lastSelected || CheckOnClick == true))
if (!_killnextselect && (index == _lastSelected || CheckOnClick))
{
CheckState currentValue = CheckedItems.GetCheckedState(index);
CheckState newValue = (currentValue != CheckState.Unchecked)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ private unsafe void WmDateTimeChange(ref Message m)
/// </summary>
private void WmDropDown()
{
if (RightToLeftLayout == true && RightToLeft == RightToLeft.Yes)
if (RightToLeftLayout && RightToLeft == RightToLeft.Yes)
{
HWND handle = (HWND)PInvoke.SendMessage(this, (User32.WM)DTM.GETMONTHCAL);
if (handle != IntPtr.Zero)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ private void OnNewObjects()
/// </summary>
protected virtual void OnSelChangeSelector(object? source, TreeViewEventArgs e)
{
if (_firstActivate == true)
if (_firstActivate)
{
// treeview seems to fire a change event when it is first setup before
// the form is activated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ private void SelectIndex(int index)
UserEdit = true;
}

Debug.Assert(_domainIndex >= 0 || UserEdit == true, "UserEdit should be true when domainIndex < 0 " + UserEdit);
Debug.Assert(_domainIndex >= 0 || UserEdit, "UserEdit should be true when domainIndex < 0 " + UserEdit);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6518,7 +6518,7 @@ private void WmSysCommand(ref Message m)
case User32.SC.CONTEXTHELP:
CancelEventArgs e = new CancelEventArgs(false);
OnHelpButtonClicked(e);
if (e.Cancel == true)
if (e.Cancel)
{
callDefault = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private static Size TryCalculatePreferredSize(IArrangedElement container, Rectan

// if we are not wrapping contents, then the breakIndex (as set in MeasureRow)
// should be equal to the count of child items in the container.
Debug.Assert(wrapContents == true || breakIndex == container.Children.Count,
Debug.Assert(wrapContents || breakIndex == container.Children.Count,
"We should not be trying to break the row if we are not wrapping contents.");

if (!measureOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ internal override void OnStopTimer()
/// </summary>
protected void ParseEditText()
{
Debug.Assert(UserEdit == true, "ParseEditText() - UserEdit == false");
Debug.Assert(UserEdit, "ParseEditText() - UserEdit == false");

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public override void Select(AccessibleSelection flags)

internal override void Collapse()
{
if (_owningGridEntry.Expandable && _owningGridEntry.Expanded == true)
if (_owningGridEntry.Expandable && _owningGridEntry.Expanded)
{
_owningGridEntry.Expanded = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public bool HasFocus
_hasFocus = value;

// Notify accessibility applications that keyboard focus has changed.
if (OwnerGridView.IsAccessibilityObjectCreated && value == true)
if (OwnerGridView.IsAccessibilityObjectCreated && value)
{
int id = OwnerGridView.AccessibilityGetGridEntryChildID(this);
if (id >= 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,12 @@ private Rectangle GetDisplayRectInternal()
_displayRect = ClientRectangle;
}

if (!AutoScroll && HorizontalScroll._visible == true)
if (!AutoScroll && HorizontalScroll._visible)
{
_displayRect = new Rectangle(_displayRect.X, _displayRect.Y, HorizontalScroll.Maximum, _displayRect.Height);
}

if (!AutoScroll && VerticalScroll._visible == true)
if (!AutoScroll && VerticalScroll._visible)
{
_displayRect = new Rectangle(_displayRect.X, _displayRect.Y, _displayRect.Width, VerticalScroll.Maximum);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ protected override CreateParams CreateParams

// set up window styles
//
if (Multiline == true)
if (Multiline)
{
cp.Style |= (int)ComCtl32.TCS.MULTILINE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public static IEnumerable<object[]> ListViewGroupAccessibleObject_GetChild_Invok
foreach (View view in Enum.GetValues(typeof(View)))
{
// View.Tile is not supported by ListView in virtual mode
if (virtualMode == true && View.Tile == view)
if (virtualMode && View.Tile == view)
{
continue;
}
Expand Down Expand Up @@ -636,7 +636,7 @@ public static IEnumerable<object[]> ListViewGroup_GroupAddedWithItem_AccessibleO
foreach (View view in Enum.GetValues(typeof(View)))
{
// View.Tile is not supported by ListView in virtual mode
if (virtualMode == true && View.Tile == view)
if (virtualMode && View.Tile == view)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ public static IEnumerable<object[]> ListViewItemAccessibleObject_Bounds_TestData
foreach (View view in Enum.GetValues(typeof(View)))
{
// View.Tile is not supported by ListView in virtual mode
if (virtualMode == true && View.Tile == view)
if (virtualMode && View.Tile == view)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4634,7 +4634,7 @@ public static IEnumerable<object[]> ListView_SelectedIndexies_Contains_Invoke_Te
foreach (View view in Enum.GetValues(typeof(View)))
{
// View.Tile is not supported by ListView in virtual mode
if (virtualMode == true && View.Tile == view)
if (virtualMode && View.Tile == view)
{
continue;
}
Expand Down Expand Up @@ -4700,7 +4700,7 @@ public static IEnumerable<object[]> ListView_OnGotFocus_Invoke_TestData()
foreach (View view in Enum.GetValues(typeof(View)))
{
// View.Tile is not supported by ListView in virtual mode
if (virtualMode == true && View.Tile == view)
if (virtualMode && View.Tile == view)
{
continue;
}
Expand Down