Skip to content

Commit

Permalink
Auto-format source code
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions Autoformatter committed Mar 10, 2023
1 parent 638f3e4 commit 61ce5a5
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/Controls/src/Core/BindableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ internal void SetBinding(BindableProperty targetProperty, BindingBase binding, b
context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;

context.Binding?.Unapply();

BindingBase oldBinding = context.Binding;
context.Binding = binding ?? throw new ArgumentNullException(nameof(binding));

Expand Down Expand Up @@ -446,13 +446,13 @@ void SetValueFIXME(BindableProperty property, object value, SetterSpecificity sp
//FIXME
var fromStyle = specificity.Style > 0;
if (fromStyle)
SetBackupStyleValue(property, value);
SetBackupStyleValue(property, value);
if (fromStyle && !CanBeSetFromStyle(property))
return;

#pragma warning disable CS0618 // Type or member is obsolete
SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
(fromStyle ? SetValuePrivateFlags.FromStyle : SetValuePrivateFlags.ManuallySet), specificity );
(fromStyle ? SetValuePrivateFlags.FromStyle : SetValuePrivateFlags.ManuallySet), specificity);
#pragma warning restore CS0618 // Type or member is obsolete
}

Expand Down Expand Up @@ -485,7 +485,7 @@ internal void SetValueCore(BindableProperty property, object value, SetValueFlag
//bool manuallySet = (privateAttributes & SetValuePrivateFlags.ManuallySet) != 0;
bool silent = (privateAttributes & SetValuePrivateFlags.Silent) != 0;
bool fromStyle = (privateAttributes & SetValuePrivateFlags.FromStyle) != 0;
bool converted = (privateAttributes & SetValuePrivateFlags.Converted) != 0;
bool converted = (privateAttributes & SetValuePrivateFlags.Converted) != 0;

if (!converted && !property.TryConvert(ref value))
{
Expand Down Expand Up @@ -729,7 +729,7 @@ internal class BindablePropertyContext
internal enum SetValuePrivateFlags
{
None = 0,
[Obsolete("no longer in use")]CheckAccess = 1 << 0,
[Obsolete("no longer in use")] CheckAccess = 1 << 0,
Silent = 1 << 1,
[Obsolete("no longer in use")] ManuallySet = 1 << 2,
FromStyle = 1 << 3,
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/BindingBaseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static class BindingBaseExtensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static BindingMode GetRealizedMode(this BindingBase self, BindableProperty property)
{
var mode = self.Mode != BindingMode.Default ? self.Mode : property.DefaultBindingMode;
var mode = self.Mode != BindingMode.Default ? self.Mode : property.DefaultBindingMode;

if (mode == BindingMode.TwoWay && property.IsReadOnly)
return BindingMode.OneWayToSource;
Expand Down
8 changes: 4 additions & 4 deletions src/Controls/src/Core/MergedStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ public void Apply(BindableObject bindable, SetterSpecificity specificity)
Apply(bindable);
}

void Apply(BindableObject bindable)
void Apply(BindableObject bindable)
{
//FIXME compute specificity
ImplicitStyle?.Apply(bindable, new SetterSpecificity(100,0,0,0));
ImplicitStyle?.Apply(bindable, new SetterSpecificity(100, 0, 0, 0));
if (ClassStyles != null)
foreach (var classStyle in ClassStyles)
//FIXME compute specificity
((IStyle)classStyle)?.Apply(bindable, new SetterSpecificity(200,0,1,0));
((IStyle)classStyle)?.Apply(bindable, new SetterSpecificity(200, 0, 1, 0));
//FIXME compute specificity
Style?.Apply(bindable, new SetterSpecificity(200,0,0,0));
Style?.Apply(bindable, new SetterSpecificity(200, 0, 0, 0));
}

public Type TargetType { get; }
Expand Down
26 changes: 16 additions & 10 deletions src/Controls/src/Core/Setter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ MemberInfo minforetriever()
return this;
}



internal void Apply(BindableObject target, SetterSpecificity specificity)
{
Expand Down Expand Up @@ -121,7 +121,7 @@ internal void UnApply(BindableObject target, bool fromStyle = false)
if (_originalValues.TryGetValue(targetObject, out object defaultValue))
{
//FIXME: unapply no longer need specificity
var specificity = fromStyle ? new SetterSpecificity(100,0,0,0) : SetterSpecificity.VisualStateSetter;
var specificity = fromStyle ? new SetterSpecificity(100, 0, 0, 0) : SetterSpecificity.VisualStateSetter;
//reset default value, unapply bindings and dynamicResource
targetObject.SetValue(Property, defaultValue, specificity);
_originalValues.Remove(targetObject);
Expand Down Expand Up @@ -154,12 +154,12 @@ internal void UnApply(BindableObject target, bool fromStyle = false)
//200: local style, inline css,
//300-n: VSM, n = max(99, distance between the RD and the target)
//300: !important (not implemented)
public int Style { get; }
public int Style { get; }

//CSS Specificity, see https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
public int Id { get; }
public int Class { get; }
public int Type { get; }
public int Type { get; }

SetterSpecificity(int vsm, int manual, int dynamicresource, int style, int id, int @class, int type)
{
Expand All @@ -178,12 +178,18 @@ public SetterSpecificity(int style, int id, int @class, int type) : this(0, 0, 0

public int CompareTo(SetterSpecificity other)
{
if (Vsm != other.Vsm) return Vsm.CompareTo(other.Vsm);
if (Manual != other.Manual) return Manual.CompareTo(other.Manual);
if (DynamicResource != other.DynamicResource) return DynamicResource.CompareTo(other.DynamicResource);
if (Style != other.Style) return Style.CompareTo(other.Style);
if (Id != other.Id) return Id.CompareTo(other.Id);
if (Class != other.Class) return Class.CompareTo(other.Class);
if (Vsm != other.Vsm)
return Vsm.CompareTo(other.Vsm);
if (Manual != other.Manual)
return Manual.CompareTo(other.Manual);
if (DynamicResource != other.DynamicResource)
return DynamicResource.CompareTo(other.DynamicResource);
if (Style != other.Style)
return Style.CompareTo(other.Style);
if (Id != other.Id)
return Id.CompareTo(other.Id);
if (Class != other.Class)
return Class.CompareTo(other.Class);
return Type.CompareTo(other.Type);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/Style.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void ApplyCore(BindableObject bindable, Style basedOn)
//FIXME: compute specificity
var specificity = new SetterSpecificity(200, 0, 0, 0);
if (basedOn != null)
((IStyle)basedOn).Apply(bindable, new SetterSpecificity(specificity.Style-1,0,0,0));
((IStyle)basedOn).Apply(bindable, new SetterSpecificity(specificity.Style - 1, 0, 0, 0));

foreach (Setter setter in Setters)
setter.Apply(bindable, specificity);
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/StyleSheets/Style.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void Apply(VisualElement styleable, bool inheriting = false)
if (!convertedValues.TryGetValue(decl, out value))
convertedValues[decl] = (value = Convert(styleable, decl.Value, property));
//FIXME: compute distance
styleable.SetValue(property, value, new SetterSpecificity(100,0,0,0));
styleable.SetValue(property, value, new SetterSpecificity(100, 0, 0, 0));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ public void IsSetIsTrueWhenPropSetByDefaultValueCreator()
public void StyleValueIsOverridenByValue()
{
var label = new Label();
label.SetValue(Label.TextProperty, "Foo", new SetterSpecificity(100,0,0,0));
label.SetValue(Label.TextProperty, "Foo", new SetterSpecificity(100, 0, 0, 0));
Assert.Equal("Foo", label.Text);

label.SetValue(Label.TextProperty, "Bar");
Expand Down
3 changes: 2 additions & 1 deletion src/Controls/tests/Core.UnitTests/StyleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,8 @@ public void UnapplyingValueAfterStyleRemoval()
[Fact]
public void UnapplyingStyleDefaultToImplicit1()
{
var stackLayout = new StackLayout {
var stackLayout = new StackLayout
{
Resources = new ResourceDictionary {
new Style(typeof(Label)) { Setters = { new Setter { Property = Label.TextProperty, Value = "implicit" } } },
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/Core.UnitTests/TimePickerUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void TestTimeOutOfRange()

[Fact("Issue #745")]
public void ZeroTimeIsValid()
{
{
_ = new TimePicker
{
Time = new TimeSpan(0, 0, 0)
Expand Down

0 comments on commit 61ce5a5

Please sign in to comment.