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

Fixing CSIsNull001 and CSIsNull002 .editorconfig issues #10118

Closed
wants to merge 3 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 0 additions & 6 deletions src/Microsoft.DotNet.Wpf/src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ dotnet_diagnostic.CA5351.severity = suggestion
# CA5362: Potential reference cycle in deserialized object graph
dotnet_diagnostic.CA5362.severity = suggestion

# CSIsNull001: Use 'is' pattern check
dotnet_diagnostic.CSIsNull001.severity = suggestion

# CSIsNull002: Use 'is not' pattern check
dotnet_diagnostic.CSIsNull002.severity = suggestion

# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.IDE0005.severity = suggestion

Expand Down
54 changes: 27 additions & 27 deletions src/Microsoft.DotNet.Wpf/src/Common/Graphics/exports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public Channel(Channel referenceChannel, bool isOutOfBandChannel, IntPtr pConnec
_isOutOfBandChannel = isOutOfBandChannel;
_isSynchronous = isSynchronous;

if (referenceChannel != null)
if (referenceChannel is not null)
{
referenceChannelHandle = referenceChannel._hChannel;
}
Expand Down Expand Up @@ -783,7 +783,7 @@ internal void SendCommandBitmapSource(
BitmapSourceSafeMILHandle pBitmapSource
)
{
Invariant.Assert(pBitmapSource != null && !pBitmapSource.IsInvalid);
Invariant.Assert(pBitmapSource is not null && !pBitmapSource.IsInvalid);
Invariant.Assert(_hChannel != IntPtr.Zero);

HRESULT.Check(UnsafeNativeMethods.MilResource_SendCommandBitmapSource(
Expand All @@ -801,7 +801,7 @@ internal void SendCommandMedia(
bool notifyUceDirect
)
{
Invariant.Assert(pMedia != null && !pMedia.IsInvalid);
Invariant.Assert(pMedia is not null && !pMedia.IsInvalid);

Invariant.Assert(_hChannel != IntPtr.Zero);

Expand Down Expand Up @@ -926,7 +926,7 @@ public Resource(DUCE.ResourceHandle h)
/// </summary>
public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.ResourceType type)
{
Debug.Assert(channel != null);
Debug.Assert(channel is not null);
#if DEBUG
_debugOnly_Channel = channel;
#endif
Expand All @@ -946,7 +946,7 @@ public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.Resou
/// </return>
public bool ReleaseOnChannel(Channel channel)
{
Debug.Assert(channel != null);
Debug.Assert(channel is not null);
#if DEBUG
Debug.Assert(_debugOnly_Channel == channel);
#endif
Expand Down Expand Up @@ -1040,12 +1040,12 @@ public Entry(object k, ValueType v)

public bool IsEmpty()
{
if (_first._key != null)
if (_first._key is not null)
{
return false;
}

if (_others != null)
if (_others is not null)
{
return false;
}
Expand All @@ -1062,15 +1062,15 @@ private int Find(object key)
{
int index = NOT_FOUND; // Not found.

if (_first._key != null)
if (_first._key is not null)
{
if (_first._key == key)
{
index = FOUND_IN_INLINE_STORAGE; // It's stored in our inlined storage.
}
else
{
if (_others != null)
if (_others is not null)
{
for (int i = 0; i < _others.Count; i++)
{
Expand All @@ -1086,7 +1086,7 @@ private int Find(object key)
#if DEBUG
else
{
Debug.Assert(_others == null, "There shouldn't be anything stored in the others array.");
Debug.Assert(_others is null, "There shouldn't be anything stored in the others array.");
}
#endif

Expand All @@ -1108,13 +1108,13 @@ public void Set(object key, ValueType value)
{
if (index == NOT_FOUND)
{
if (_first._key == null)
if (_first._key is null)
{
_first = new Entry(key, value);
}
else
{
if (_others == null)
if (_others is null)
{
_others = new List<Entry>(2); // by default we have two entries in the extra storage.
}
Expand All @@ -1139,7 +1139,7 @@ public bool Remove(object key)

if (index == FOUND_IN_INLINE_STORAGE)
{
if (_others != null)
if (_others is not null)
{
Debug.Assert(_others.Count > 0);
int j = _others.Count-1;
Expand Down Expand Up @@ -1214,11 +1214,11 @@ public bool Get(object key, out ValueType value)
/// </summary>
public int Count()
{
if (_first._key == null)
if (_first._key is null)
{
return 0;
}
else if (_others == null)
else if (_others is null)
{
return 1;
}
Expand Down Expand Up @@ -1283,7 +1283,7 @@ public Entry(object k, DUCE.ResourceHandle v)

public bool IsEmpty()
{
return _head._key == null;
return _head._key is null;
}

/// <summary>
Expand All @@ -1295,7 +1295,7 @@ private int Find(object key)
{
int index = NOT_FOUND; // Not found.

if (_head._key != null)
if (_head._key is not null)
{
if (_head._key == key)
{
Expand Down Expand Up @@ -1339,7 +1339,7 @@ public void Set(object key, DUCE.ResourceHandle value)
{
// The key was not found.
// Is the Map empty?
if (_head._key == null)
if (_head._key is null)
{
_head = new Entry(key, value);
}
Expand Down Expand Up @@ -1452,7 +1452,7 @@ public bool Get(object key, out DUCE.ResourceHandle value)
/// </summary>
public int Count()
{
if (_head._key == null)
if (_head._key is null)
{
return 0;
}
Expand Down Expand Up @@ -1516,7 +1516,7 @@ internal struct MultiChannelResource
/// </remark>
public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.ResourceType type)
{
Debug.Assert(channel != null);
Debug.Assert(channel is not null);
DUCE.ResourceHandle handle;
bool inmap = _map.Get(channel, out handle);

Expand All @@ -1541,7 +1541,7 @@ public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.Resou
/// <param name="targetChannel">The channel to duplicate the handle to.</param>
public DUCE.ResourceHandle DuplicateHandle(Channel sourceChannel, Channel targetChannel)
{
Debug.Assert(sourceChannel != null);
Debug.Assert(sourceChannel is not null);
DUCE.ResourceHandle duplicate = DUCE.ResourceHandle.Null;

DUCE.ResourceHandle handle = DUCE.ResourceHandle.Null;
Expand Down Expand Up @@ -1579,7 +1579,7 @@ public DUCE.ResourceHandle DuplicateHandle(Channel sourceChannel, Channel target
/// </return>
public bool ReleaseOnChannel(Channel channel)
{
Debug.Assert(channel != null);
Debug.Assert(channel is not null);

DUCE.ResourceHandle handle;

Expand All @@ -1604,7 +1604,7 @@ public DUCE.ResourceHandle GetHandle(Channel channel)
{
DUCE.ResourceHandle h;

if (channel != null)
if (channel is not null)
{
_map.Get(channel, out h);
}
Expand Down Expand Up @@ -1647,7 +1647,7 @@ public DUCE.Channel GetChannel(int index)

public uint GetRefCountOnChannel(Channel channel)
{
Debug.Assert(channel != null);
Debug.Assert(channel is not null);

DUCE.ResourceHandle handle;

Expand Down Expand Up @@ -1948,8 +1948,8 @@ Channel channel
DUCE.MILCMD_VISUAL_SETGUIDELINECOLLECTION command;
Debug.Assert(!hCompositionNode.IsNull);

int countX = guidelinesX == null ? 0 : guidelinesX.Count;
int countY = guidelinesY == null ? 0 : guidelinesY.Count;
int countX = guidelinesX is null ? 0 : guidelinesX.Count;
int countY = guidelinesY is null ? 0 : guidelinesY.Count;
int countXY = countX + countY;

command.Type = MILCMD.MilCmdVisualSetGuidelineCollection;
Expand Down Expand Up @@ -2241,7 +2241,7 @@ Channel channel
bool? enableMultiMonitorDisplayClipping =
System.Windows.CoreCompatibilityPreferences.EnableMultiMonitorDisplayClipping;

if (enableMultiMonitorDisplayClipping != null)
if (enableMultiMonitorDisplayClipping is not null)
{
// The flag is explicitly set by the user in application manifest
command.flags |= (UInt32)MILRTInitializationFlags.MIL_RT_IS_DISABLE_MULTIMON_DISPLAY_CLIPPING_VALID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static void ParseTargetFrameworkName(out string identifier, out string p
// This is our default
// When TFM cannot be found, it probably means we are running
// on .NET Core 2.2 or lower, in which case we will default to .NET Core 3.0
if (targetFrameworkMoniker == null)
if (targetFrameworkMoniker is null)
{
targetFrameworkMoniker = ".NETCoreApp,Version=v3.0";
}
Expand Down Expand Up @@ -83,7 +83,7 @@ private static bool TryParseFrameworkName(String frameworkName, out String ident
identifier = profile = string.Empty;
version = 0;

if (frameworkName == null || frameworkName.Length == 0)
if (frameworkName is null || frameworkName.Length == 0)
{
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.DotNet.Wpf/src/Common/src/System/SR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal static string GetResourceString(string resourceKey, string defaultStrin
{
string resourceString = GetResourceString(resourceKey);

if (defaultString != null && resourceKey.Equals(resourceString, StringComparison.Ordinal))
if (defaultString is not null && resourceKey.Equals(resourceString, StringComparison.Ordinal))
{
return defaultString;
}
Expand All @@ -63,7 +63,7 @@ internal static string GetResourceString(string resourceKey, string defaultStrin

internal static string Format(string resourceFormat, params object[] args)
{
if (args != null)
if (args is not null)
{
if (UsingResourceKeys())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal DynamicPropertyAccessorImpl(Type ownerType, string propertyName)

public override object GetValue(object component)
{
if (_getter == null)
if (_getter is null)
{
var binder = new TrivialGetMemberBinder(PropertyName);
_getter = CallSite<Func<CallSite, object, object>>.Create(binder);
Expand All @@ -35,7 +35,7 @@ public override object GetValue(object component)

public override void SetValue(object component, object value)
{
if (_setter == null)
if (_setter is null)
{
var binder = new TrivialSetMemberBinder(PropertyName);
_setter = CallSite<Action<CallSite, object, object>>.Create(binder);
Expand Down Expand Up @@ -131,7 +131,7 @@ public override void SetValue(object component, object[] args, object value)
// ensure only one accessor for each rank
public static DynamicIndexerAccessor GetIndexerAccessor(int rank)
{
if (_accessors.Length < rank || _accessors[rank-1] == null)
if (_accessors.Length < rank || _accessors[rank-1] is null)
{
lock(_lock)
{
Expand All @@ -142,7 +142,7 @@ public static DynamicIndexerAccessor GetIndexerAccessor(int rank)
_accessors = newAccessors;
}

if (_accessors[rank-1] == null)
if (_accessors[rank-1] is null)
{
_accessors[rank-1] = new DynamicIndexerAccessorImpl(rank);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal override bool IsDataRowView(object item)
internal override bool IsSqlNull(object value)
{
INullable nullable = value as INullable;
return (nullable != null && nullable.IsNull);
return (nullable is not null && nullable.IsNull);
}

// return true if the type is nullable in the SqlTypes sense
Expand All @@ -45,7 +45,7 @@ internal override bool IsSqlNullableType(Type type)
// identity and change notifications. We handle these specially.
internal override bool IsDataSetCollectionProperty(PropertyDescriptor pd)
{
if (s_DataTablePropertyDescriptorType == null)
if (s_DataTablePropertyDescriptorType is null)
{
// lazy load the types for the offending PD's. They're internal, so
// we get them indirectly.
Expand Down Expand Up @@ -122,7 +122,7 @@ internal override object GetValue(object item, PropertyDescriptor pd, bool useFo
{
// the "suitable ADO object" is the corresponding DataTable
DataTable dataTable = (value as DataView)?.Table;
if (dataTable != null)
if (dataTable is not null)
{
new DataTableToDataViewLink(dataTable, value);
}
Expand All @@ -131,7 +131,7 @@ internal override object GetValue(object item, PropertyDescriptor pd, bool useFo
{
// the "suitable ADO object" is the parent DataRowView
DataRowView dataRowView = item as DataRowView;
if (dataRowView != null)
if (dataRowView is not null)
{
new DataRowViewToRelatedViewLink(dataRowView, value);
}
Expand Down Expand Up @@ -174,19 +174,19 @@ internal override bool DetermineWhetherDBNullIsValid(object item, string columnN
{
DataRowView drv;
DataRow dr = null;
if ((drv = item as DataRowView) == null &&
(dr = item as DataRow) == null)
if ((drv = item as DataRowView) is null &&
(dr = item as DataRow) is null)
{
return false;
}

// this code was provided by the ADO team
DataTable table = (drv != null) ? drv.DataView.Table : dr.Table;
DataTable table = (drv is not null) ? drv.DataView.Table : dr.Table;

DataColumn column = null;
if (arg != null)
if (arg is not null)
{
if ((columnName = arg as String) != null)
if ((columnName = arg as String) is not null)
{
column = table.Columns[columnName];
}
Expand All @@ -199,12 +199,12 @@ internal override bool DetermineWhetherDBNullIsValid(object item, string columnN
}
}
}
else if (columnName != null)
else if (columnName is not null)
{
column = table.Columns[columnName];
}

return (column != null) && column.AllowDBNull;
return (column is not null) && column.AllowDBNull;
}

private class DataTableToDataViewLink
Expand Down
Loading