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

Replace FrozenSet with IReadOnlyList #1839

Merged
merged 5 commits into from
Apr 28, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Maui.Behaviors;
using CommunityToolkit.Maui.Behaviors;

namespace CommunityToolkit.Maui.Sample.ViewModels.Behaviors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;

namespace CommunityToolkit.Maui.Sample.ViewModels.Converters;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Application = Microsoft.Maui.Controls.Application;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;


namespace CommunityToolkit.Maui.Sample.ViewModels.Converters;

public class ListToStringConverterViewModel : BaseViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace CommunityToolkit.Maui.Sample.ViewModels.Converters;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Maui.ImageSources;
using CommunityToolkit.Maui.ImageSources;
using CommunityToolkit.Mvvm.ComponentModel;

namespace CommunityToolkit.Maui.Sample.ViewModels.ImageSources;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Frozen;
using System.Runtime.CompilerServices;
using CommunityToolkit.Maui.Sample.Views.Popups;
using CommunityToolkit.Maui.Views;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Frozen;
using System.Diagnostics.CodeAnalysis;
using CommunityToolkit.Maui.Core.Extensions;

Expand All @@ -19,7 +18,7 @@ public class AlertView : UIView
/// <summary>
/// PopupView Children
/// </summary>
public FrozenSet<UIView> Children => children.ToFrozenSet();
public IReadOnlyList<UIView> Children => children;
brminnick marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// <see cref="UIView"/> on which Alert will appear. When null, <see cref="AlertView"/> will appear at bottom of screen.
Expand Down Expand Up @@ -84,15 +83,15 @@ void ConstraintInParent()
[MemberNotNull(nameof(Container))]
void Initialize()
{
Container = new UIStackView()
Container = new UIStackView
{
Alignment = UIStackViewAlignment.Fill,
Distribution = UIStackViewDistribution.EqualSpacing,
Axis = UILayoutConstraintAxis.Horizontal,
TranslatesAutoresizingMaskIntoConstraints = false
};

foreach (var view in children)
foreach (var view in Children)
{
Container.AddArrangedSubview(view);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Maui.Core.Primitives;
using CommunityToolkit.Maui.Core.Primitives;
using CommunityToolkit.Maui.Views;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml.Controls;
Expand All @@ -14,12 +13,12 @@ namespace CommunityToolkit.Maui.Core.Views;
partial class MediaManager : IDisposable
{
// States that allow changing position
readonly FrozenSet<MediaElementState> allowUpdatePositionStates = new[]
{
readonly IReadOnlyList<MediaElementState> allowUpdatePositionStates =
[
MediaElementState.Playing,
MediaElementState.Paused,
MediaElementState.Stopped,
}.ToFrozenSet();
];

// The requests to keep display active are cumulative, this bool makes sure it only gets requested once
bool displayActiveRequested;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Maui.Behaviors;
using CommunityToolkit.Maui.Behaviors;
using CommunityToolkit.Maui.UnitTests.Mocks;
using FluentAssertions;
using Xunit;
Expand All @@ -8,11 +7,11 @@ namespace CommunityToolkit.Maui.UnitTests.Behaviors;

public class ProgressBarAnimationBehaviorTests() : BaseBehaviorTest<ProgressBarAnimationBehavior, ProgressBar>(new ProgressBarAnimationBehavior(), new ProgressBar())
{
public static readonly FrozenSet<object[]> ValidData = new[]
{
public static readonly IReadOnlyList<object[]> ValidData =
[
[1, 500, Easing.Default],
new object[] { 0, 750, Easing.CubicOut }
}.ToFrozenSet();
[0, 750, Easing.CubicOut]
];

[Theory(Timeout = 5000)]
[MemberData(nameof(ValidData))]
Expand Down Expand Up @@ -74,15 +73,15 @@ public void InvalidProgressValuesTest(double inputProgressValue, double expected
[Fact]
public void AttachedToInvalidElementTest()
{
FrozenSet<VisualElement> invalidVisualElements = new[]
{
IReadOnlyList<VisualElement> invalidVisualElements =
[
new Button(),
new Frame(),
new Label(),
new VisualElement(),
new View(),
new Entry(),
}.ToFrozenSet();
];

foreach (var invalidVisualElement in invalidVisualElements)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using System.Globalization;
using System.Globalization;
using CommunityToolkit.Maui.Converters;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using System.Globalization;
using System.Globalization;
using CommunityToolkit.Maui.Converters;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Maui.Converters;
using CommunityToolkit.Maui.Converters;
using Xunit;

namespace CommunityToolkit.Maui.UnitTests.Converters;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using System.ComponentModel;
using System.ComponentModel;
using System.Globalization;
using CommunityToolkit.Maui.Converters;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using CommunityToolkit.Maui.Converters;
using CommunityToolkit.Maui.Converters;
using Xunit;

namespace CommunityToolkit.Maui.UnitTests.Converters;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Frozen;
using System.Globalization;
using System.Globalization;
using System.Text.RegularExpressions;
using CommunityToolkit.Maui.Core;

Expand All @@ -11,8 +10,8 @@ sealed partial class MathExpression

static readonly IFormatProvider formatProvider = new CultureInfo("en-US");

readonly FrozenSet<MathOperator> operators;
readonly FrozenSet<double> arguments;
readonly IReadOnlyList<MathOperator> operators;
readonly IReadOnlyList<double> arguments;

internal MathExpression(string expression, IEnumerable<double>? arguments = null)
{
Expand Down Expand Up @@ -69,8 +68,8 @@ internal MathExpression(string expression, IEnumerable<double>? arguments = null
operators.Add(new MathOperator($"x{i}", 0, MathOperatorPrecedence.Constant, _ => argumentList[index]));
}

this.operators = operators.ToFrozenSet();
this.arguments = argumentList.ToFrozenSet();
this.operators = operators;
this.arguments = argumentList;
}

internal string Expression { get; }
Expand Down