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

[StyleCleanUp] Address IDE warnings Part 3 #10188

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Compat issues with assembly System.Windows.Controls.Ribbon:
Total Issues: 0
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeA
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IRawElementProviderFragment' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IRawElementProviderFragmentRoot' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IRawElementProviderHwndOverride' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IRawElementProviderSimple' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IScrollItemProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IScrollProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ISelectionItemProvider' in the contract but not the implementation.
Expand All @@ -20,10 +19,9 @@ CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeA
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITableItemProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITableProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITextProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITextRangeProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IToggleProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.ITransformProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IValueProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IVirtualizedItemProvider' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.InteropServices.InterfaceTypeAttribute' exists on 'System.Windows.Automation.Provider.IWindowProvider' in the contract but not the implementation.
Total Issues: 27
Total Issues: 25
6 changes: 0 additions & 6 deletions src/Microsoft.DotNet.Wpf/src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,6 @@ dotnet_diagnostic.IDE0020.severity = suggestion
# IDE0029: Use coalesce expression
dotnet_diagnostic.IDE0029.severity = suggestion

# IDE0030: Null check can be simplified
dotnet_diagnostic.IDE0030.severity = suggestion

# IDE0031: Use null propagation
dotnet_diagnostic.IDE0031.severity = suggestion

# IDE0034: Simplify 'default' expression
dotnet_diagnostic.IDE0034.severity = suggestion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -171,7 +171,7 @@ private static XmlNamespaceManager GetXmlNamespaceManager(DependencyObject targe
if (nsmgr == null)
{
XmlDataProvider xdp = Helper.XmlDataProviderForElement(target);
nsmgr = (xdp != null) ? xdp.XmlNamespaceManager : null;
nsmgr = xdp?.XmlNamespaceManager;
}

return nsmgr;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -37,7 +37,7 @@ internal override bool IsXElement(object item)
internal override string GetXElementTagName(object item)
{
XName name = ((XElement)item).Name;
return (name != null) ? name.ToString() : null;
return name?.ToString();
}

// XLinq exposes two synthetic properties - Elements and Descendants -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,7 @@ private void _Compile(string relativeSourceFile, bool pass2)
}


if (SourceFileInfo != null)
{
SourceFileInfo.CloseStream();
}
SourceFileInfo?.CloseStream();

if (bamlStream != null)
{
Expand Down Expand Up @@ -1930,7 +1927,7 @@ private CodeExpression GetEventDelegate(CodeContext cc, MemberInfo miEvent, stri
// Fetch the EventHandlerType from either the EventInfo or the MethodInfo
// for the Add{Propertyname}Handler method's MethodInfo
Type eventHandlerType = GetEventHandlerType(miEvent);
string [] typeArgsList = cc != null ? cc.GenericTypeArgs : null;
string [] typeArgsList = cc?.GenericTypeArgs;

cdce.DelegateType = GenerateConstructedTypeReference(eventHandlerType, typeArgsList, eventTarget, eventTargetName, eventName);
cdce.MethodName = eventHandler.Trim() + (subClassed ? HELPER : string.Empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public override bool Execute()
/// </summary>
public string Culture
{
get { return _culture != null ? _culture.ToLower(CultureInfo.InvariantCulture) : null; }
get { return _culture?.ToLower(CultureInfo.InvariantCulture); }
set { _culture = value; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ public override bool Execute()
}
finally
{
if (manifestReader != null)
{
// Close the manifest reader
manifestReader.Close();
}
// Close the manifest reader
manifestReader?.Close();
}

// NOTE:
Expand Down Expand Up @@ -124,11 +121,8 @@ public override bool Execute()
}
finally
{
if (manifestWriter != null)
{
// Close the manifest writer
manifestWriter.Close();
}
// Close the manifest writer
manifestWriter?.Close();
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

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


return visual;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -798,10 +798,8 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
if (_viewHandle != null)
_viewHandle.Dispose();
if (_mappingHandle != null)
_mappingHandle.Dispose();
_viewHandle?.Dispose();
_mappingHandle?.Dispose();
}

// We only handle flat disk files read only, should never be writeable.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -567,10 +567,7 @@ private void ResponseCallback(IAsyncResult ar)
}
finally
{
if (webResponse != null)
{
webResponse.Close();
}
webResponse?.Close();

// bytes requested are downloaded or errored out
// inform the caller that these ranges are available
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -396,10 +396,8 @@ protected override void Dispose(bool disposing)
_disposed = true;

// release any blocked threads - Set() does not throw any exceptions
if (_readEventHandles[(int)ReadEvent.FullDownloadReadEvent] != null)
_readEventHandles[(int)ReadEvent.FullDownloadReadEvent].Set();
if (_readEventHandles[(int)ReadEvent.ByteRangeReadEvent] != null)
_readEventHandles[(int)ReadEvent.ByteRangeReadEvent].Set();
_readEventHandles[(int)ReadEvent.FullDownloadReadEvent]?.Set();
_readEventHandles[(int)ReadEvent.ByteRangeReadEvent]?.Set();

// Free ByteRangeDownloader
FreeByteRangeDownloader();
Expand All @@ -417,10 +415,7 @@ protected override void Dispose(bool disposing)
}

// Free Full Download
if (_responseStream != null)
{
_responseStream.Close();
}
_responseStream?.Close();

FreeTempFile();
#if DEBUG
Expand Down Expand Up @@ -1181,10 +1176,7 @@ private void ReleaseFullDownloadResources()
finally
{
// FreeFullDownload
if (_responseStream != null)
{
_responseStream.Close();
}
_responseStream?.Close();
}
}
finally
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -133,10 +133,7 @@ internal static void RemovePackage(Uri uri)

lock (_globalLock)
{
if (_packagePairs != null)
{
_packagePairs.Remove(uri);
}
_packagePairs?.Remove(uri);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -239,11 +239,8 @@ protected override void Dispose(bool disposing)
// close the Part or NetStream
_innerStream.Close();

if (_owningStream != null)
{
// in this case, the innerStream was the part so this is the NetStream
_owningStream.Close();
}
// in this case, the innerStream was the part so this is the NetStream
_owningStream?.Close();
}
}
finally
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -84,7 +84,7 @@ internal StrokeNodeIterator(StylusShape nodeShape)
/// <param name="drawingAttributes">drawing attributes</param>
internal StrokeNodeIterator(DrawingAttributes drawingAttributes)
: this( null, //stylusPoints
StrokeNodeOperations.CreateInstance((drawingAttributes == null ? null : drawingAttributes.StylusShape)),
StrokeNodeOperations.CreateInstance((drawingAttributes?.StylusShape)),
(drawingAttributes == null ? false : !drawingAttributes.IgnorePressure)) //usePressure
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -85,9 +85,9 @@ internal static void SetFlagsToRoot(DependencyObject element, bool value, Visual
{
visual.SetFlagsToRoot(value, flags);
}
else if (visual3D != null)
else
{
visual3D.SetFlagsToRoot(value, flags);
visual3D?.SetFlagsToRoot(value, flags);
}
}

Expand Down Expand Up @@ -281,7 +281,7 @@ internal static bool AsVisualInternal(DependencyObject element, out Visual visua
{
Debug.Fail(String.Format(
"'{0}' is not a Visual or Visual3D. Caller is responsible for guaranteeing that element is a Visual type.",
element != null ? element.GetType() : null));
element?.GetType()));
}

return castSucceeded;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -101,10 +101,7 @@ internal GeneralTransform2DTo3DTo2D(Viewport2DVisual3D visual3D, Visual fromVisu

// store the inverse as well
_transform2DInverse = (GeneralTransform)_transform2D.Inverse;
if (_transform2DInverse != null)
{
_transform2DInverse.Freeze();
}
_transform2DInverse?.Freeze();

// make a copy of the camera and other values on the Viewport3D
Viewport3DVisual viewport3D = (Viewport3DVisual)VisualTreeHelper.GetContainingVisual2D(visual3D);
Expand All @@ -120,10 +117,7 @@ internal GeneralTransform2DTo3DTo2D(Viewport2DVisual3D visual3D, Visual fromVisu
_objectToViewport = visual3D.TransformToAncestor(viewport3D);

// if the transform was not possible, it could be null - check before freezing
if (_objectToViewport != null)
{
_objectToViewport.Freeze();
}
_objectToViewport?.Freeze();

// store the needed transformations for the various operations
_worldTransformation = M3DUtil.GetWorldTransformationMatrix(visual3D);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -532,10 +532,7 @@ internal static Matrix3D GetWorldTransformationMatrix(Visual3D visual3DStart, ou

Transform3D transform = (Transform3D)visual3D.GetValue(Visual3D.TransformProperty);

if (transform != null)
{
transform.Append(ref worldTransform);
}
transform?.Append(ref worldTransform);

dependencyObject = VisualTreeHelper.GetParent(dependencyObject);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -606,7 +606,7 @@ out cchNextValid
else if (!string.IsNullOrEmpty(targetFamilyName))
{
// The base Uri used for resolving target family names is the Uri of the composite font.
Uri baseUri = (canonicalFamilyReference != null) ? canonicalFamilyReference.LocationUri : null;
Uri baseUri = canonicalFamilyReference?.LocationUri;

// map to the target of the family map
cchAdvance = MapByFontFamilyName(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -146,10 +146,7 @@ internal static void AddParentPreOpportunityHandler(DependencyObject o, EventRou
else
{
UIElement3D e3D = logicalParent as UIElement3D;
if (e3D != null)
{
e3D.AddSynchronizedInputPreOpportunityHandler(route, args);
}
e3D?.AddSynchronizedInputPreOpportunityHandler(route, args);
}
}
}
Expand Down
Loading