Skip to content

Commit

Permalink
Merge pull request #10859 from Youssef1313/ide0051
Browse files Browse the repository at this point in the history
build: Enable IDE0051 (remove unused private members)
  • Loading branch information
jeromelaban authored Feb 16, 2023
2 parents d25a99f + f8a9f96 commit 45c85c0
Show file tree
Hide file tree
Showing 142 changed files with 693 additions and 808 deletions.
6 changes: 0 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,4 @@ dotnet_diagnostic.CA2101.severity = none
dotnet_diagnostic.IDE0055.severity = error

# IDE0051: Remove unused private member
# Enable once all violations are fixed.
dotnet_diagnostic.IDE0051.severity = warning

[src/Uno.UI/**/*.cs]
# IDE0051: Remove unused private member
# Enable once all violations are fixed.
dotnet_diagnostic.IDE0051.severity = none
58 changes: 27 additions & 31 deletions src/Uno.UI/Behaviors/VisibleBoundsPadding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ namespace Uno.UI.Behaviors
/// <remarks>
/// This class is located in the same source file as the VisibleBoundsPadding class to avoid code duplication.
/// This is required to ensure that both Uno.UI styles and UWP (through Uno.UI.Toolkit) can use this behavior
/// and not have to synchronize two code files. The internal implementation is not supposed to be used outside
/// and not have to synchronize two code files. The internal implementation is not supposed to be used outside
/// of the Uno.UI assembly, Uno.UI.Toolkit.VisibleBoundsPadding should be used by dependents.
/// </remarks>
internal static class InternalVisibleBoundsPadding
#else
namespace Uno.UI.Toolkit
{
/// <summary>
/// A behavior which automatically adds padding to a control that ensures its content will always be inside
/// A behavior which automatically adds padding to a control that ensures its content will always be inside
/// the <see cref="ApplicationView.VisibleBounds"/> of the application. Set PaddingMask to 'All' to enable this behavior,
/// or set PaddingMask to another value to enable it only on a particular side or sides.
/// </summary>
Expand Down Expand Up @@ -108,37 +108,13 @@ public static Thickness WindowPadding
}
}

/// <summary>
/// VisibleBounds offset to the reference frame of the window Bounds.
/// </summary>
private static Rect OffsetVisibleBounds
{
get
{
#if WINUI
return new();
#else
var visibleBounds = ApplicationView.GetForCurrentView().VisibleBounds;

if (Window.Current is Window window)
{
var bounds = window.Bounds;
visibleBounds.X -= bounds.X;
visibleBounds.Y -= bounds.Y;
}

return visibleBounds;
#endif
}
}

public static PaddingMask GetPaddingMask(DependencyObject obj)
=> (PaddingMask)obj.GetValue(PaddingMaskProperty);

/// <summary>
/// Set the <see cref="PaddingMask"/> to use on this property. A mask of <see cref="PaddingMask.All"/> will apply visible bounds
/// padding on all sides, a mask of <see cref="PaddingMask.Bottom"/> will adjust only the bottom padding, etc. The different options
/// can be combined as bit flags.
/// Set the <see cref="PaddingMask"/> to use on this property. A mask of <see cref="PaddingMask.All"/> will apply visible bounds
/// padding on all sides, a mask of <see cref="PaddingMask.Bottom"/> will adjust only the bottom padding, etc. The different options
/// can be combined as bit flags.
/// </summary>
public static void SetPaddingMask(DependencyObject obj, PaddingMask value)
=> obj.SetValue(PaddingMaskProperty, value);
Expand Down Expand Up @@ -171,7 +147,27 @@ private static void OnIsPaddingMaskChanged(DependencyObject dependencyObject, De

#if !WINUI
/// <summary>
/// If false, ApplicationView.VisibleBounds and Window.Current.Bounds have different aspect ratios (eg portrait vs landscape) which
/// VisibleBounds offset to the reference frame of the window Bounds.
/// </summary>
private static Rect OffsetVisibleBounds
{
get
{
var visibleBounds = ApplicationView.GetForCurrentView().VisibleBounds;

if (Window.Current is Window window)
{
var bounds = window.Bounds;
visibleBounds.X -= bounds.X;
visibleBounds.Y -= bounds.Y;
}

return visibleBounds;
}
}

/// <summary>
/// If false, ApplicationView.VisibleBounds and Window.Current.Bounds have different aspect ratios (eg portrait vs landscape) which
/// might arise transiently when the screen orientation changes.
/// </summary>
private static bool AreBoundsAspectRatiosConsistent
Expand Down Expand Up @@ -294,7 +290,7 @@ private Thickness AdjustScrollablePadding(Thickness visibilityPadding, ScrollVie
#if XAMARIN
if (scrollableRoot is ItemsPresenter)
{
// This implies we're probably inside a ListView, in which case the reasoning breaks down in Uno (because ItemsPresenter
// This implies we're probably inside a ListView, in which case the reasoning breaks down in Uno (because ItemsPresenter
// is *outside* the scrollable region); we skip the adjustment and hope for the best.
scrollableRoot = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Uno.UI/Controls/BindableHorizontalListView.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ protected void ExecuteCommandOnItem(ICommand command, int position)
command.Execute(item);
}

private int GetItemWidth()
{
return GetChildAt(0).Width;
}

private void ScrollToItem()
{
if (_scrollToIndexChanged
Expand Down
28 changes: 6 additions & 22 deletions src/Uno.UI/Controls/BindableImageView.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
using Windows.UI.Core;
using Uno.Helpers;

#pragma warning disable CS0649 // TODO: Fix.

namespace Uno.UI.Controls
{
[Windows.UI.Xaml.Data.Bindable]
Expand Down Expand Up @@ -81,8 +83,8 @@ public class BindableImageView : ImageView, View.IOnTouchListener
private int _previousMeasuredHeight, _previousMeasuredWidth;
private float _saveScale = 1f;

private ScaleGestureDetector _scaleDetector;
private GestureDetector _doubleTapDetector;
//private ScaleGestureDetector _scaleDetector;
//private GestureDetector _doubleTapDetector;

private static int DeltaClick = 3;
private Bitmap _currentBitmap;
Expand Down Expand Up @@ -463,24 +465,6 @@ protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)

#region Interaction methods

private void BuildImageInteractivity(Android.Content.Context context)
{
MinZoom = 1f;
MaxZoom = 3f;

_saveScale = 1f;

_scaleDetector = new ScaleGestureDetector(context, new ScaleListener(this));
_doubleTapDetector = new GestureDetector(context, new DoubleTapListener(this));

_matrix = new Matrix();
_m = new float[9];
ImageMatrix = _matrix;
SetScaleType(ImageView.ScaleType.Matrix);

SetOnTouchListener(this);
}

private void OnDrawableChanged()
{
if (_matrix != null && _saveScale == 1 && Width != 0 && Height != 0)
Expand Down Expand Up @@ -525,8 +509,8 @@ public bool OnTouch(View v, MotionEvent e)
{
this.Parent.RequestDisallowInterceptTouchEvent(_saveScale != 1);

_scaleDetector.OnTouchEvent(e);
_doubleTapDetector.OnTouchEvent(e);
//_scaleDetector.OnTouchEvent(e);
//_doubleTapDetector.OnTouchEvent(e);

var currentPoint = new System.Drawing.PointF(e.GetX(), e.GetY());

Expand Down
23 changes: 4 additions & 19 deletions src/Uno.UI/Controls/Window.macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ private static bool IsTabletPointingEvent(NSEvent nativeEvent)
/// Method invoked when a drag operation enters the <see cref="NSWindow"/>.
/// </summary>
/// <remarks>
///
///
/// While it is never documented directly, DraggingEntered can be added to NSWindow just like NSView.
/// Key docs telling this story include:
///
///
/// (1) NSWindow documentation does not include most NSView drag/drop methods
/// https://developer.apple.com/documentation/appkit/nswindow
/// (2) Since NSWindow documentation doesn't reference them, they also aren't included in Xamarin
Expand All @@ -354,11 +354,11 @@ private static bool IsTabletPointingEvent(NSEvent nativeEvent)
/// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DragandDrop/Concepts/dragdestination.html#//apple_ref/doc/uid/20000977-BAJBJFBG
/// (5) Other macOS drag/drop articles and blogs refer to dragging/dropping directly from Window - although
/// give no examples.
///
///
/// The Export "method_name" attribute is fundamentally important to make this work, removing it will
/// break functionality and the method will never be called by macOS. Again, this seemingly is because
/// Xamarin.macOS is not aware of it.
///
///
/// </remarks>
/// <param name="info">Information about the dragging session from the sender.</param>
/// <returns>The accepted drag operation(s).</returns>
Expand Down Expand Up @@ -531,21 +531,6 @@ public static void SetNeedsKeyboard(NSView view, bool needsKeyboard)
_attachedProperties.SetValue(view, NeedsKeyboardAttachedPropertyKey, (bool?)needsKeyboard);
}
}

private static bool GetNeedsKeyboard(NSView view)
{
var superViews = view.FindSuperviews().ToList();
superViews.Insert(0, view);

return superViews.Any(superView => _attachedProperties.GetValue(superView, NeedsKeyboardAttachedPropertyKey, () => default(bool?)).GetValueOrDefault());
}

private static bool NeedsKeyboard(NSView view)
{
return view is NSTextView
|| view is NSTextField
|| GetNeedsKeyboard(view);
}
#endregion

public BringIntoViewMode? FocusedViewBringIntoViewOnKeyboardOpensMode { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion src/Uno.UI/DirectUI/BudgetManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.


#if false

namespace DirectUI
{
Expand Down Expand Up @@ -62,3 +62,5 @@ private void GetElapsedMilliSecondsSinceLastUITickImpl(out int returnValue)
}
}
}

#endif
2 changes: 1 addition & 1 deletion src/Uno.UI/DirectUI/BudgetManager.h.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace DirectUI
internal partial class BudgetManager
{
// The default elapsed time before deferring
private const int BUDGET_MANAGER_DEFAULT_LIMIT = 40;
//private const int BUDGET_MANAGER_DEFAULT_LIMIT = 40;

//long m_freq;
//long m_startFrameTime;
Expand Down
6 changes: 0 additions & 6 deletions src/Uno.UI/Helpers/WinUI/SharedHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,6 @@ public static bool DoRectsIntersect(
return doIntersect;
}

object FindResourceOrNull(string resource, ResourceDictionary resources)
{
object boxedResource = resource;
return resources.HasKey(boxedResource) ? resources.Lookup(boxedResource) : null;
}

// When checkVisibility is True, IsAncestor additionally checks if any UIElement from the 'child'
// to the 'parent' chain is Collapsed. It returns False when that is the case.
public static bool IsAncestor(
Expand Down
10 changes: 0 additions & 10 deletions src/Uno.UI/Helpers/WinUI/SplitDataSourceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,6 @@ void OnRemoveAt(int index)
m_attachedData.RemoveAt(index);
}

void OnReplace(int index)
{
var splitVector = GetVectorForItem(index);
if (splitVector != null)
{
var value = GetAt(index);
splitVector.Replace(index, value);
}
}

void OnInsertAt(int index)
{
var vectorID = DefaultVectorIDOnInsert();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.UI.Xaml.Controls
{
public partial class InfoBadge : Control
{
private const string IconPresenterName = "IconPresenter";
//private const string IconPresenterName = "IconPresenter";

public InfoBadge()
{
Expand Down
4 changes: 3 additions & 1 deletion src/Uno.UI/Microsoft/UI/Xaml/Controls/InfoBar/InfoBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial class InfoBar : Control
{
private const string c_closeButtonName = "CloseButton";
private const string c_iconTextBlockName = "StandardIcon";
private const string c_contentRootName = "ContentRoot";
//private const string c_contentRootName = "ContentRoot";

private readonly long _foregroundChangedCallbackRegistration;

Expand Down Expand Up @@ -271,6 +271,7 @@ private void UpdateForeground()
VisualStateManager.GoToState(this, ReadLocalValue(Control.ForegroundProperty) == DependencyProperty.UnsetValue ? "ForegroundNotSet" : "ForegroundSet", false);
}

#if false
private string GetSeverityLevelResourceName(InfoBarSeverity severity)
{
switch (severity)
Expand All @@ -281,6 +282,7 @@ private string GetSeverityLevelResourceName(InfoBarSeverity severity)
};
return "InfoBarSeverityInformationalName";
}
#endif

private string GetIconSeverityLevelResourceName(InfoBarSeverity severity)
{
Expand Down
Loading

0 comments on commit 45c85c0

Please sign in to comment.