Skip to content

Commit f15a1fd

Browse files
authored
[StyleCleanUp] Addressing IDE warnings (#10185)
* Addressing IDE0150 .editorconfig issues * Reverting encoding changes
1 parent 11cbc7a commit f15a1fd

File tree

11 files changed

+21
-24
lines changed

11 files changed

+21
-24
lines changed

src/Microsoft.DotNet.Wpf/src/.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,6 @@ dotnet_diagnostic.IDE0082.severity = suggestion
257257
# IDE0100: Remove redundant equality
258258
dotnet_diagnostic.IDE0100.severity = suggestion
259259

260-
# IDE0150: Prefer 'null' check over type check
261-
dotnet_diagnostic.IDE0150.severity = suggestion
262-
263260
# IDE0180: Use tuple to swap values
264261
dotnet_diagnostic.IDE0180.severity = suggestion
265262

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/Renderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ private void AttachVisual(StrokeVisual visual, bool buildingStrokeCollection)
529529
{
530530
// Find or create a container visual for highlighter strokes of the color
531531
ContainerVisual parent = GetContainerVisual(visual.Stroke.DrawingAttributes);
532-
Debug.Assert(visual is StrokeVisual);
532+
Debug.Assert(visual is not null);
533533

534534
//insert StrokeVisuals under any non-StrokeVisuals used for dynamic inking
535535
int i = 0;

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/FlowDocumentPage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ private TextPointer FindElementPosition(IInputElement e, bool isLimitedToTextVie
924924
Debug.Assert(e != null);
925925

926926
// Validate that this function is only called when a TextContainer exists as complex content
927-
Debug.Assert(_structuralCache.TextContainer is TextContainer);
927+
Debug.Assert(_structuralCache.TextContainer is not null);
928928

929929
TextPointer elementPosition = null;
930930

@@ -941,8 +941,8 @@ private TextPointer FindElementPosition(IInputElement e, bool isLimitedToTextVie
941941
else
942942
{
943943
// Else: search for e in the complex content
944-
if (!(_structuralCache.TextContainer.Start is TextPointer) ||
945-
!(_structuralCache.TextContainer.End is TextPointer))
944+
if (!(_structuralCache.TextContainer.Start is not null) ||
945+
!(_structuralCache.TextContainer.End is not null))
946946
{
947947
// Invalid TextContainer, don't search
948948
return null;

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public static bool TryUnwrapObject(object o, out IObjectReference objRef)
6161

6262
Type type = o.GetType();
6363
ObjectReferenceWrapperAttribute objRefWrapper = type.GetCustomAttribute<ObjectReferenceWrapperAttribute>();
64-
if (objRefWrapper is object)
64+
if (objRefWrapper is not null)
6565
{
6666
objRef = (IObjectReference)type.GetField(objRefWrapper.ObjectReferenceField, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly).GetValue(o);
6767
return true;
6868
}
6969

7070
ProjectedRuntimeClassAttribute projectedClass = type.GetCustomAttribute<ProjectedRuntimeClassAttribute>();
7171

72-
if (projectedClass is object)
72+
if (projectedClass is not null)
7373
{
7474
return TryUnwrapObject(
7575
type.GetProperty(projectedClass.DefaultInterfaceProperty, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly).GetValue(o),

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ExceptionHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static void ThrowExceptionForHR(int hr)
6666
{
6767
ExceptionDispatchInfo.Capture(ex).Throw();
6868
}
69-
else if (ex is object)
69+
else if (ex is not null)
7070
{
7171
throw ex;
7272
}
@@ -107,7 +107,7 @@ private static Exception GetExceptionForHR(int hr, bool useGlobalErrorState, out
107107
{
108108
ILanguageExceptionErrorInfo languageErrorInfo = new ABI.WinRT.Interop.ILanguageExceptionErrorInfo(languageErrorInfoRef);
109109
using IObjectReference languageException = languageErrorInfo.GetLanguageException();
110-
if (languageException is object)
110+
if (languageException is not null)
111111
{
112112
if (languageException.IsReferenceToManagedObject)
113113
{

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/Projections.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private static bool IsTypeWindowsRuntimeTypeNoArray(Type type)
130130
|| type == typeof(string)
131131
|| type == typeof(Guid)
132132
|| type == typeof(object)
133-
|| type.GetCustomAttribute<WindowsRuntimeTypeAttribute>() is object;
133+
|| type.GetCustomAttribute<WindowsRuntimeTypeAttribute>() is not null;
134134
}
135135

136136
public static bool TryGetCompatibleWindowsRuntimeTypeForVariantType(Type type, out Type compatibleType)
@@ -205,7 +205,7 @@ internal static bool TryGetMarshalerTypeForProjectedRuntimeClass(IObjectReferenc
205205
{
206206
IInspectable inspectable = inspectablePtr;
207207
string runtimeClassName = inspectable.GetRuntimeClassName(true);
208-
if (runtimeClassName is object)
208+
if (runtimeClassName is not null)
209209
{
210210
if (ProjectedRuntimeClassNames.Contains(runtimeClassName))
211211
{

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/TypeExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static Type FindHelperType(this Type type)
1515
type = typeof(Exception);
1616
}
1717
Type customMapping = Projections.FindCustomHelperTypeMapping(type);
18-
if (customMapping is object)
18+
if (customMapping is not null)
1919
{
2020
return customMapping;
2121
}
@@ -31,7 +31,7 @@ public static Type FindHelperType(this Type type)
3131
public static Type GetHelperType(this Type type)
3232
{
3333
var helperType = type.FindHelperType();
34-
if (helperType is object)
34+
if (helperType is not null)
3535
return helperType;
3636
throw new InvalidOperationException($"Target type is not a projected type: {type.FullName}.");
3737
}
@@ -48,7 +48,7 @@ public static Type FindVftblType(this Type helperType)
4848
{
4949
return null;
5050
}
51-
if (helperType.IsGenericType && vftblType is object)
51+
if (helperType.IsGenericType && vftblType is not null)
5252
{
5353
vftblType = vftblType.MakeGenericType(helperType.GetGenericArguments());
5454
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/UndoManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ internal static void AttachUndoManager(DependencyObject scope, UndoManager undoM
9696
ArgumentNullException.ThrowIfNull(scope);
9797
ArgumentNullException.ThrowIfNull(undoManager);
9898

99-
if (undoManager is UndoManager && ((UndoManager)undoManager)._scope != null)
99+
if (undoManager is not null && ((UndoManager)undoManager)._scope != null)
100100
{
101101
throw new InvalidOperationException(SR.UndoManagerAlreadyAttached);
102102
}
@@ -106,7 +106,7 @@ internal static void AttachUndoManager(DependencyObject scope, UndoManager undoM
106106

107107
// Attach the service to the scope via private dependency property
108108
scope.SetValue(UndoManager.UndoManagerInstanceProperty, undoManager);
109-
if (undoManager is UndoManager)
109+
if (undoManager is not null)
110110
{
111111
Debug.Assert(((UndoManager)undoManager)._scope == null);
112112
((UndoManager)undoManager)._scope = scope;
@@ -141,7 +141,7 @@ internal static void DetachUndoManager(DependencyObject scope)
141141
scope.ClearValue(UndoManager.UndoManagerInstanceProperty);
142142

143143
// Break the linkage to its scope
144-
if (undoManager is UndoManager)
144+
if (undoManager is not null)
145145
{
146146
Debug.Assert(((UndoManager)undoManager)._scope == scope);
147147
((UndoManager)undoManager)._scope = null;

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ItemsControlAutomationPeer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ internal RecyclableWrapper GetRecyclableWrapperPeer(object item)
424424
return _recyclableWrapperCache;
425425
}
426426

427-
// UpdateChildrenIntenal is called with ItemsInvalidateLimit to ensure we don’t fire unnecessary structure change events when items are just scrolled in/out of view in case of
427+
// UpdateChildrenIntenal is called with ItemsInvalidateLimit to ensure we don’t fire unnecessary structure change events when items are just scrolled in/out of view in case of
428428
// virtualized controls.
429429
override internal IDisposable UpdateChildren()
430430
{
@@ -625,7 +625,7 @@ public T this[object item]
625625
if (_hashtable == null)
626626
_hashtable = new WeakDictionary<object,T>();
627627

628-
if(!_hashtable.ContainsKey(item) && value is T)
628+
if(!_hashtable.ContainsKey(item) && value is not null)
629629
_hashtable[item] = value;
630630
else
631631
Debug.Assert(false,"it must not add already present Item");
@@ -634,7 +634,7 @@ public T this[object item]
634634
{
635635
if (_list == null)
636636
_list = new List<KeyValuePair<object, T>>();
637-
if(value is T)
637+
if(value is not null)
638638
_list.Add(new KeyValuePair<object, T>(item, value));
639639
}
640640

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/DocumentSequenceTextPointer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ internal static uint GetDebugId()
841841

842842
internal static string ToString(DocumentSequenceTextPointer thisTp)
843843
{
844-
return $"{(thisTp is DocumentSequenceTextPointer ? "DSTP" : "DSTN")} Id={thisTp.DebugId} B={thisTp.ChildBlock.DebugId} G={thisTp.ChildPointer.LogicalDirection}";
844+
return $"{(thisTp is not null ? "DSTP" : "DSTN")} Id={thisTp.DebugId} B={thisTp.ChildBlock.DebugId} G={thisTp.ChildPointer.LogicalDirection}";
845845
}
846846
#endif
847847
#endregion Internal Methods

0 commit comments

Comments
 (0)