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 2 #10170

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 0 additions & 3 deletions src/Microsoft.DotNet.Wpf/src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ dotnet_diagnostic.IDE0005.severity = suggestion
# IDE0017: Simplify object initialization
dotnet_diagnostic.IDE0017.severity = suggestion

# IDE0029: Use coalesce expression
dotnet_diagnostic.IDE0029.severity = suggestion

# IDE0030: Null check can be simplified
dotnet_diagnostic.IDE0030.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 @@ -28,7 +28,7 @@ internal XmlNodeComparer(SortDescriptionCollection sortParameters, XmlNamespaceM
{
_sortParameters = sortParameters;
_namespaceManager = namespaceManager;
_culture = (culture == null) ? CultureInfo.InvariantCulture : culture;
_culture = culture ?? CultureInfo.InvariantCulture;
}

int IComparer.Compare(object o1, object o2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ public LineBuffer(string line)

public void SetLine(string line)
{
Content = (line == null) ? string.Empty : line;
Content = line ?? string.Empty;
Index = 0;
}

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 @@ -253,7 +253,7 @@ GlyphRun glyphRun
glyphRun.EmitBackground(drawingContext, _properties.BackgroundBrush);

drawingContext.DrawGlyphRun(
foregroundBrush != null ? foregroundBrush : _properties.ForegroundBrush,
foregroundBrush ?? _properties.ForegroundBrush,
glyphRun
);
}
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 @@ -650,9 +650,9 @@ private bool ProcessStagingArea()
// PreProcessedInputEventArgs and cast it to NotifyInputEventArgs
// or ProcessInputEventArgs because a malicious user could upcast
// the object and call inappropriate methods.
NotifyInputEventArgs notifyInputEventArgs = (_notifyInputEventArgs != null) ? _notifyInputEventArgs : new NotifyInputEventArgs();
ProcessInputEventArgs processInputEventArgs = (_processInputEventArgs != null) ? _processInputEventArgs : new ProcessInputEventArgs();
PreProcessInputEventArgs preProcessInputEventArgs = (_preProcessInputEventArgs != null) ? _preProcessInputEventArgs : new PreProcessInputEventArgs();
NotifyInputEventArgs notifyInputEventArgs = _notifyInputEventArgs ?? new NotifyInputEventArgs();
ProcessInputEventArgs processInputEventArgs = _processInputEventArgs ?? new ProcessInputEventArgs();
PreProcessInputEventArgs preProcessInputEventArgs = _preProcessInputEventArgs ?? new PreProcessInputEventArgs();
_notifyInputEventArgs = null;
_processInputEventArgs = null;
_preProcessInputEventArgs = null;
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 @@ -44,7 +44,7 @@ public QueryCursorEventArgs(MouseDevice mouse, int timestamp, StylusDevice stylu
public Cursor Cursor
{
get {return _cursor;}
set {_cursor = ((value == null) ? Cursors.None : value);}
set {_cursor = (value ?? Cursors.None);}
}

/// <summary>
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 @@ -1026,8 +1026,7 @@ public override void PushEffect(
// NOTE:Disabling this API for now

_currentDrawingGroup.BitmapEffect = effect;
_currentDrawingGroup.BitmapEffectInput = (effectInput != null) ?
effectInput : new BitmapEffectInput();
_currentDrawingGroup.BitmapEffectInput = effectInput ?? new BitmapEffectInput();
}

/// <summary>
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 @@ -191,7 +191,7 @@ public Uri BaseUri
public override string ToString()
{
string source = _familyIdentifier.Source;
return source != null ? source : string.Empty;
return source ?? string.Empty;
}


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,9 +396,7 @@ internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCh
data.hTransform = hTransform;
data.FillRule = FillRule;

byte[] pathDataToMarshal = _data == null ?
Geometry.GetEmptyPathGeometryData().SerializedData :
_data;
byte[] pathDataToMarshal = _data ?? GetEmptyPathGeometryData().SerializedData;

unsafe
{
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 @@ -54,7 +54,7 @@ public MarkedHighlightComponent(XmlQualifiedName type, DependencyObject host)
{
ArgumentNullException.ThrowIfNull(type);

_DPHost = host == null ? this : host;
_DPHost = host ?? this;
ClipToBounds = false;

//create anchor highlight. The second parameter controls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ internal ViewRecord GetViewRecord(object collection, CollectionViewSource cvs, T
else
{
// collection is not a factory - create an appropriate view
IList il = (ilsList != null) ? ilsList : collection as IList;
IList il = ilsList ?? collection as IList;
if (il != null)
{
// create a view on an IList or IBindingList
Expand Down Expand Up @@ -582,7 +582,7 @@ internal ViewRecord GetViewRecord(object collection, CollectionViewSource cvs, T
throw new ArgumentException(SR.Format(SR.CollectionView_WrongType, collectionViewType.Name));

// if collection is IListSource, get its list first (bug 1023903)
object arg = (ilsList != null) ? ilsList : collection;
object arg = ilsList ?? collection;

try
{
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 @@ -565,7 +565,7 @@ LocalizabilityAttribute second
{
if (first == null || second == null)
{
return (first == null) ? second : first;
return first ?? second;
}

// min of two readability enum. The less the more restrictive.
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 @@ -165,7 +165,7 @@ private void OnAdornerMouseButtonDownEvent(object sender, MouseButtonEventArgs a
// If the current captured device is Stylus, we should activate the LassoSelectionBehavior with
// the Stylus. Otherwise, use mouse.
EditingCoordinator.ActivateDynamicBehavior(EditingCoordinator.LassoSelectionBehavior,
args.StylusDevice != null ? args.StylusDevice : args.Device);
args.StylusDevice ?? args.Device);
}
}

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 @@ -292,7 +292,7 @@ internal IInputElement InputHitTestCore(Point point)
ie = _ptsPage.InputHitTest(point);
}
}
return (ie != null) ? ie : _structuralCache.FormattingOwner as IInputElement;
return ie ?? _structuralCache.FormattingOwner as IInputElement;
}

/// <summary>
Expand Down Expand Up @@ -392,7 +392,7 @@ internal ReadOnlyCollection<ParagraphResult> FloatingElementResults
}

/// <summary>
/// Called when a UIElement-derived class which is hosted by a IContentHost changes its DesiredSize
/// Called when a UIElement-derived class which is hosted by a IContentHost changes its DesiredSize
/// </summary>
/// <param name="child">
/// Child element whose DesiredSize has changed
Expand Down Expand Up @@ -1212,7 +1212,7 @@ IEnumerator<IInputElement> IContentHost.HostedElements
}

/// <summary>
/// Called when a UIElement-derived class which is hosted by a IContentHost changes its DesiredSize
/// Called when a UIElement-derived class which is hosted by a IContentHost changes its DesiredSize
/// </summary>
/// <param name="child">
/// Child element whose DesiredSize has changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ internal override TextSpan<CultureSpecificCharacterBufferRange> GetPrecedingText
precedingText = new CharacterBufferRange(precedingTextString, 0, precedingTextString.Length);

StaticTextPointer pointer = position.CreateStaticPointer();
DependencyObject element = (pointer.Parent != null) ? pointer.Parent : _paraClient.Paragraph.Element;
DependencyObject element = pointer.Parent ?? _paraClient.Paragraph.Element;
culture = DynamicPropertyReader.GetCultureInfo(element);
}

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 @@ -161,7 +161,7 @@ internal override TextSpan<CultureSpecificCharacterBufferRange> GetPrecedingText


StaticTextPointer pointer = position.CreateStaticPointer();
DependencyObject element = (pointer.Parent != null) ? pointer.Parent : _paraClient.Paragraph.Element;
DependencyObject element = pointer.Parent ?? _paraClient.Paragraph.Element;
culture = DynamicPropertyReader.GetCultureInfo(element);
}

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,7 +101,7 @@ public override TextSpan<CultureSpecificCharacterBufferRange> GetPrecedingText(i
precedingText = new CharacterBufferRange(precedingTextString, 0, precedingTextString.Length);

StaticTextPointer pointer = position.CreateStaticPointer();
DependencyObject element = (pointer.Parent != null) ? pointer.Parent : _owner;
DependencyObject element = pointer.Parent ?? _owner;
culture = DynamicPropertyReader.GetCultureInfo(element);
}

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 @@ -121,7 +121,7 @@ public string DefaultDirectory
get
{
// Avoid returning a null string - return String.Empty instead.
return _defaultDirectory == null ? String.Empty : _defaultDirectory;
return _defaultDirectory ?? string.Empty;
}
set
{
Expand Down Expand Up @@ -160,7 +160,7 @@ public string InitialDirectory
get
{
// Avoid returning a null string - return String.Empty instead.
return _initialDirectory == null ? String.Empty : _initialDirectory;
return _initialDirectory ?? string.Empty;
}
set
{
Expand All @@ -179,7 +179,7 @@ public string RootDirectory
get
{
// Avoid returning a null string - return String.Empty instead.
return _rootDirectory == null ? String.Empty : _rootDirectory;
return _rootDirectory ?? string.Empty;
}
set
{
Expand Down Expand Up @@ -218,7 +218,7 @@ public string Title
get
{
// Avoid returning a null string - return String.Empty instead.
return _title == null ? String.Empty : _title;
return _title ?? string.Empty;
}
set
{
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 @@ -262,7 +262,7 @@ public string DefaultExt
{
// For string properties, it's important to not return null, as an empty
// string tends to make more sense to beginning developers.
return _defaultExtension == null ? String.Empty : _defaultExtension;
return _defaultExtension ?? string.Empty;
}

set
Expand Down Expand Up @@ -307,7 +307,7 @@ public string Filter
{
// For string properties, it's important to not return null, as an empty
// string tends to make more sense to beginning developers.
return _filter == null ? String.Empty : _filter;
return _filter ?? string.Empty;
}

set
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 @@ -44,7 +44,7 @@ protected override string GetAutomationIdCore()
}
}

return result == null ? string.Empty : result;
return result ?? string.Empty;
}

///
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 @@ -677,7 +677,7 @@ private object RawItem
if (iwr != null)
{
object item = iwr.Target;
return (item == null) ? DependencyProperty.UnsetValue : item;
return item ?? DependencyProperty.UnsetValue;
}
else
{
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 @@ -122,7 +122,7 @@ internal static DataGridCellInfo CreatePossiblyPartialCellInfo(object item, Data
}
else
{
return new DataGridCellInfo(owner, column, (item == null) ? DependencyProperty.UnsetValue : item);
return new DataGridCellInfo(owner, column, item ?? DependencyProperty.UnsetValue);
}
}

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 @@ -103,7 +103,7 @@ public DocumentPaginator DocumentPaginator
/// </summary>
public DocumentPage DocumentPage
{
get { return (_documentPage == null) ? DocumentPage.Missing : _documentPage; }
get { return _documentPage ?? DocumentPage.Missing; }
}

/// <summary>
Expand Down
Loading