Skip to content

Commit 36e6e74

Browse files
authored
[StyleCleanUp] Address IDE warnings Part 3 (#10188)
* Update: Resolve IDE0030 in src * Update: Resolve IDE0031 in src * Address PR Review comments * Fix test failures
1 parent 55f444b commit 36e6e74

File tree

525 files changed

+1886
-5022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

525 files changed

+1886
-5022
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Compat issues with assembly System.Windows.Controls.Ribbon:
21
Total Issues: 0

src/Microsoft.DotNet.Wpf/ApiCompat/Baselines/UIAutomationProvider-ref.baseline.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeA
1111
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IRawElementProviderFragment' in the contract but not the implementation.
1212
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IRawElementProviderFragmentRoot' in the contract but not the implementation.
1313
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IRawElementProviderHwndOverride' in the contract but not the implementation.
14-
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IRawElementProviderSimple' in the contract but not the implementation.
1514
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IScrollItemProvider' in the contract but not the implementation.
1615
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IScrollProvider' in the contract but not the implementation.
1716
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ISelectionItemProvider' in the contract but not the implementation.
@@ -20,10 +19,9 @@ CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeA
2019
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITableItemProvider' in the contract but not the implementation.
2120
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITableProvider' in the contract but not the implementation.
2221
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITextProvider' in the contract but not the implementation.
23-
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITextRangeProvider' in the contract but not the implementation.
2422
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IToggleProvider' in the contract but not the implementation.
2523
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITransformProvider' in the contract but not the implementation.
2624
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IValueProvider' in the contract but not the implementation.
2725
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IVirtualizedItemProvider' in the contract but not the implementation.
2826
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IWindowProvider' in the contract but not the implementation.
29-
Total Issues: 27
27+
Total Issues: 25

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ dotnet_diagnostic.CA5362.severity = suggestion
185185
# IDE0005: Using directive is unnecessary.
186186
dotnet_diagnostic.IDE0005.severity = suggestion
187187

188-
# IDE0030: Null check can be simplified
189-
dotnet_diagnostic.IDE0030.severity = suggestion
190-
191-
# IDE0031: Use null propagation
192-
dotnet_diagnostic.IDE0031.severity = suggestion
193-
194188
# IDE0034: Simplify 'default' expression
195189
dotnet_diagnostic.IDE0034.severity = suggestion
196190

src/Microsoft.DotNet.Wpf/src/Extensions/PresentationFramework-SystemXml/SystemXmlExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -171,7 +171,7 @@ private static XmlNamespaceManager GetXmlNamespaceManager(DependencyObject targe
171171
if (nsmgr == null)
172172
{
173173
XmlDataProvider xdp = Helper.XmlDataProviderForElement(target);
174-
nsmgr = (xdp != null) ? xdp.XmlNamespaceManager : null;
174+
nsmgr = xdp?.XmlNamespaceManager;
175175
}
176176

177177
return nsmgr;

src/Microsoft.DotNet.Wpf/src/Extensions/PresentationFramework-SystemXmlLinq/SystemXmlLinqExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -37,7 +37,7 @@ internal override bool IsXElement(object item)
3737
internal override string GetXElementTagName(object item)
3838
{
3939
XName name = ((XElement)item).Name;
40-
return (name != null) ? name.ToString() : null;
40+
return name?.ToString();
4141
}
4242

4343
// XLinq exposes two synthetic properties - Elements and Descendants -

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,7 @@ private void _Compile(string relativeSourceFile, bool pass2)
566566
}
567567

568568

569-
if (SourceFileInfo != null)
570-
{
571-
SourceFileInfo.CloseStream();
572-
}
569+
SourceFileInfo?.CloseStream();
573570

574571
if (bamlStream != null)
575572
{
@@ -1935,7 +1932,7 @@ private CodeExpression GetEventDelegate(CodeContext cc, MemberInfo miEvent, stri
19351932
// Fetch the EventHandlerType from either the EventInfo or the MethodInfo
19361933
// for the Add{Propertyname}Handler method's MethodInfo
19371934
Type eventHandlerType = GetEventHandlerType(miEvent);
1938-
string [] typeArgsList = cc != null ? cc.GenericTypeArgs : null;
1935+
string [] typeArgsList = cc?.GenericTypeArgs;
19391936

19401937
cdce.DelegateType = GenerateConstructedTypeReference(eventHandlerType, typeArgsList, eventTarget, eventTargetName, eventName);
19411938
cdce.MethodName = eventHandler.Trim() + (subClassed ? HELPER : string.Empty);

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/FileClassifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public override bool Execute()
156156
/// </summary>
157157
public string Culture
158158
{
159-
get { return _culture != null ? _culture.ToLower(CultureInfo.InvariantCulture) : null; }
159+
get { return _culture?.ToLower(CultureInfo.InvariantCulture); }
160160
set { _culture = value; }
161161
}
162162

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/UpdateManifestForBrowserApplication.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,8 @@ public override bool Execute()
8585
}
8686
finally
8787
{
88-
if (manifestReader != null)
89-
{
90-
// Close the manifest reader
91-
manifestReader.Close();
92-
}
88+
// Close the manifest reader
89+
manifestReader?.Close();
9390
}
9491

9592
// NOTE:
@@ -121,11 +118,8 @@ public override bool Execute()
121118
}
122119
finally
123120
{
124-
if (manifestWriter != null)
125-
{
126-
// Close the manifest writer
127-
manifestWriter.Close();
128-
}
121+
// Close the manifest writer
122+
manifestWriter?.Close();
129123
}
130124

131125
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/ElementUtil.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -156,7 +156,7 @@ internal static Visual GetElementFromPoint( IntPtr hwnd, Visual root, Point poin
156156
Point pointClient = PointUtil.ScreenToClient( pointScreen, hwndSource );
157157
Point pointRoot = PointUtil.ClientToRoot(pointClient, hwndSource);
158158
PointHitTestResult result = VisualTreeUtils.AsNearestPointHitTestResult(VisualTreeHelper.HitTest(root, pointRoot));
159-
Visual visual = (result != null) ? result.VisualHit : null;
159+
Visual visual = result?.VisualHit;
160160

161161

162162
return visual;

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,10 +795,8 @@ protected override void Dispose(bool disposing)
795795
{
796796
if (disposing)
797797
{
798-
if (_viewHandle != null)
799-
_viewHandle.Dispose();
800-
if (_mappingHandle != null)
801-
_mappingHandle.Dispose();
798+
_viewHandle?.Dispose();
799+
_mappingHandle?.Dispose();
802800
}
803801

804802
// We only handle flat disk files read only, should never be writeable.

0 commit comments

Comments
 (0)