Skip to content

Commit

Permalink
feat: Align properties (netstandard2.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Sep 21, 2021
1 parent 5397faa commit fdcf4c5
Show file tree
Hide file tree
Showing 15 changed files with 356 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4623,7 +4623,7 @@ private string BuildFontWeight(string memberValue)
{
var fontWeights = (INamedTypeSymbol)_metadataHelper.GetTypeByFullName(XamlConstants.Types.FontWeights);

if (fontWeights.GetFields().Any(m => m.Name.Equals(memberValue, StringComparison.OrdinalIgnoreCase)))
if (fontWeights.GetProperties().Any(p => p.Name.Equals(memberValue, StringComparison.OrdinalIgnoreCase)))
{
return "FontWeights." + memberValue;
}
Expand Down Expand Up @@ -4696,9 +4696,12 @@ private static string AppendFloatSuffix(string memberValue)
private string BuildColor(string memberValue)
{
var colorsSymbol = (INamedTypeSymbol)_metadataHelper.GetTypeByFullName(XamlConstants.Types.Colors);
if (colorsSymbol.FindField(_colorSymbol, memberValue, StringComparison.OrdinalIgnoreCase) is IFieldSymbol field)

if (colorsSymbol.GetProperties().FirstOrDefault(p =>
SymbolEqualityComparer.Default.Equals(p.Type, _colorSymbol) &&
p.Name.Equals(memberValue, StringComparison.OrdinalIgnoreCase)) is IPropertySymbol property)
{
return $"{GlobalPrefix}{XamlConstants.Types.Colors}.{field.Name}";
return $"{GlobalPrefix}{XamlConstants.Types.Colors}.{property.Name}";
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Automation/AutomationProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static string GetName(DependencyObject element)
return (string)element.GetValue(NameProperty);
}

public static DependencyProperty NameProperty =
public static DependencyProperty NameProperty { get; } =
DependencyProperty.RegisterAttached(
"Name",
typeof(string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public Thickness Padding
set { SetValue(PaddingProperty, value); }
}

public static DependencyProperty PaddingProperty =
public static DependencyProperty PaddingProperty { get; } =
DependencyProperty.Register(
"Padding",
typeof(Thickness),
Expand Down Expand Up @@ -498,7 +498,7 @@ public Thickness BorderThickness
set { SetValue(BorderThicknessProperty, value); }
}

public static DependencyProperty BorderThicknessProperty =
public static DependencyProperty BorderThicknessProperty { get; } =
DependencyProperty.Register(
"BorderThickness",
typeof(Thickness),
Expand All @@ -524,7 +524,7 @@ public Brush BorderBrush
set { SetValue(BorderBrushProperty, value); }
}

public static DependencyProperty BorderBrushProperty =
public static DependencyProperty BorderBrushProperty { get; } =
DependencyProperty.Register(
"BorderBrush",
typeof(Brush),
Expand All @@ -547,7 +547,7 @@ private void OnBorderBrushChanged(Brush oldValue, Brush newValue)
private static CornerRadius GetCornerRadiusDefaultValue() => CornerRadius.None;

[GeneratedDependencyProperty(ChangedCallback = true)]
public static DependencyProperty CornerRadiusProperty = CreateCornerRadiusProperty();
public static DependencyProperty CornerRadiusProperty { get; } = CreateCornerRadiusProperty();

public CornerRadius CornerRadius
{
Expand Down
6 changes: 3 additions & 3 deletions src/Uno.UI/UI/Xaml/Controls/ItemsControl/ItemsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public ItemsPanelTemplate ItemsPanel
set { SetValue(ItemsPanelProperty, value); }
}

public static DependencyProperty ItemsPanelProperty =
public static DependencyProperty ItemsPanelProperty { get; } =
DependencyProperty.Register(
"ItemsPanel",
typeof(ItemsPanelTemplate),
Expand Down Expand Up @@ -194,7 +194,7 @@ public DataTemplate ItemTemplate
set { SetValue(ItemTemplateProperty, value); }
}

public static DependencyProperty ItemTemplateProperty =
public static DependencyProperty ItemTemplateProperty { get; } =
DependencyProperty.Register(
"ItemTemplate",
typeof(DataTemplate),
Expand Down Expand Up @@ -222,7 +222,7 @@ public DataTemplateSelector ItemTemplateSelector
set { SetValue(ItemTemplateSelectorProperty, value); }
}

public static DependencyProperty ItemTemplateSelectorProperty =
public static DependencyProperty ItemTemplateSelectorProperty { get; } =
DependencyProperty.Register(
"ItemTemplateSelector",
typeof(DataTemplateSelector),
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Controls/ItemsControl/ItemsPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Thickness Padding
set => SetValue(PaddingProperty, value);
}

public static DependencyProperty PaddingProperty =
public static DependencyProperty PaddingProperty { get; } =
DependencyProperty.Register(
"Padding",
typeof(Thickness),
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public double VerticalOffset
private set => SetValue(VerticalOffsetProperty, value);
}

public static DependencyProperty VerticalOffsetProperty =
public static DependencyProperty VerticalOffsetProperty { get; } =
DependencyProperty.Register(
"VerticalOffset",
typeof(double),
Expand All @@ -574,7 +574,7 @@ public double HorizontalOffset
private set => SetValue(HorizontalOffsetProperty, value);
}

public static DependencyProperty HorizontalOffsetProperty =
public static DependencyProperty HorizontalOffsetProperty { get; } =
DependencyProperty.Register(
"HorizontalOffset",
typeof(double),
Expand Down
6 changes: 3 additions & 3 deletions src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public Thickness Padding
set => SetValue(PaddingProperty, value);
}

public static DependencyProperty PaddingProperty =
public static DependencyProperty PaddingProperty { get; } =
DependencyProperty.Register(
"Padding",
typeof(Thickness),
Expand All @@ -599,7 +599,7 @@ public int CharacterSpacing
set => SetValue(CharacterSpacingProperty, value);
}

public static DependencyProperty CharacterSpacingProperty =
public static DependencyProperty CharacterSpacingProperty { get; } =
DependencyProperty.Register(
"CharacterSpacing",
typeof(int),
Expand Down Expand Up @@ -629,7 +629,7 @@ public TextDecorations TextDecorations
set => SetValue(TextDecorationsProperty, value);
}

public static DependencyProperty TextDecorationsProperty =
public static DependencyProperty TextDecorationsProperty { get; } =
DependencyProperty.Register(
"TextDecorations",
typeof(uint),
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/DependencyProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ internal int CachedHashCode
/// Specifies a static value that is used by the dependency property system rather than null to indicate that
/// the property exists, but does not have its value set by the dependency property system.
/// </summary>
public static readonly object UnsetValue = Windows.UI.Xaml.UnsetValue.Instance;
public static object UnsetValue { get; } = Windows.UI.Xaml.UnsetValue.Instance;

/// <summary>
/// Retrieves the property metadata value for the dependency property as registered to a type. You specify the type you want info from as a type reference.
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/Documents/TextElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public int CharacterSpacing
set => SetValue(CharacterSpacingProperty, value);
}

public static DependencyProperty CharacterSpacingProperty =
public static DependencyProperty CharacterSpacingProperty { get; } =
DependencyProperty.Register(
"CharacterSpacing",
typeof(int),
Expand Down Expand Up @@ -242,7 +242,7 @@ public TextDecorations TextDecorations
set { SetValue(TextDecorationsProperty, value); }
}

public static DependencyProperty TextDecorationsProperty =
public static DependencyProperty TextDecorationsProperty { get; } =
DependencyProperty.Register(
"TextDecorations",
typeof(uint),
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWP/Storage/Streams/IRandomAccessStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial interface IRandomAccessStream : IDisposable, IInputStream, IOutpu

ulong Position { get; }

ulong Size { get; }
ulong Size { get; set; }

IInputStream GetInputStreamAt( ulong position);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ public IAsyncOperation<bool> FlushAsync()
public ulong Position => _stream.Position;

/// <inheritdoc />
public ulong Size => _stream.Size;
public ulong Size
{
get => _stream.Size;
set => _stream.Size = value;
}

/// <inheritdoc />
public IInputStream GetInputStreamAt(ulong position)
Expand Down
6 changes: 5 additions & 1 deletion src/Uno.UWP/Storage/Streams/StreamedRandomAccessStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ public StreamedRandomAccessStream(
public ulong Position => (ulong)_temp.Position;

/// <inheritdoc />
public ulong Size => (ulong)_temp.Length;
public ulong Size
{
get => (ulong)_temp.Length;
set => _temp.SetLength((long)value);
}

/// <inheritdoc />
public IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
Expand Down
Loading

0 comments on commit fdcf4c5

Please sign in to comment.