From 84109ccf6055889d00fa65c37bf357eb9aa188e5 Mon Sep 17 00:00:00 2001 From: Lehonti Ramos Date: Tue, 8 Aug 2023 00:04:30 +0200 Subject: [PATCH] Modernized getter syntax --- src/AvaloniaMath/Controls/FormulaBlock.cs | 24 ++++++++-------- src/WpfMath/Controls/FormulaControl.xaml.cs | 28 +++++++++---------- .../Controls/VisualContainerElement.cs | 7 ++--- src/XamlMath.Shared/Atoms/DummyAtom.cs | 5 +--- src/XamlMath.Shared/Boxes/Box.cs | 5 +--- src/XamlMath.Shared/TexEnvironment.cs | 4 +-- src/XamlMath.Shared/TexFormulaParser.cs | 5 +--- 7 files changed, 33 insertions(+), 45 deletions(-) diff --git a/src/AvaloniaMath/Controls/FormulaBlock.cs b/src/AvaloniaMath/Controls/FormulaBlock.cs index ef8ea321..f5a44f72 100644 --- a/src/AvaloniaMath/Controls/FormulaBlock.cs +++ b/src/AvaloniaMath/Controls/FormulaBlock.cs @@ -70,39 +70,39 @@ public FormulaBlock() public string Formula { - get { return GetValue(FormulaProperty); } - set { SetValue(FormulaProperty, value); } + get => GetValue(FormulaProperty); + set => SetValue(FormulaProperty, value); } public double Scale { - get { return GetValue(ScaleProperty); } - set { SetValue(ScaleProperty, value); } + get => GetValue(ScaleProperty); + set => SetValue(ScaleProperty, value); } public string SystemTextFontName { - get { return GetValue(SystemTextFontNameProperty); } - set { SetValue(SystemTextFontNameProperty, value); } + get => GetValue(SystemTextFontNameProperty); + set => SetValue(SystemTextFontNameProperty, value); } public bool HasError { - get { return GetValue(HasErrorProperty); } - private set { SetValue(HasErrorProperty, value); } + get => GetValue(HasErrorProperty); + private set => SetValue(HasErrorProperty, value); } public ObservableCollection Errors { - get { return GetValue(ErrorsProperty); } - private set { SetValue(ErrorsProperty, value); } + get => GetValue(ErrorsProperty); + private set => SetValue(ErrorsProperty, value); } // TODO[#353]: Make it used public ControlTemplate ErrorTemplate { - get { return GetValue(ErrorTemplateProperty); } - set { SetValue(ErrorTemplateProperty, value); } + get => GetValue(ErrorTemplateProperty); + set => SetValue(ErrorTemplateProperty, value); } public override void Render(DrawingContext context) diff --git a/src/WpfMath/Controls/FormulaControl.xaml.cs b/src/WpfMath/Controls/FormulaControl.xaml.cs index d2f660e6..aebeceff 100644 --- a/src/WpfMath/Controls/FormulaControl.xaml.cs +++ b/src/WpfMath/Controls/FormulaControl.xaml.cs @@ -22,14 +22,14 @@ public partial class FormulaControl : UserControl public string Formula { - get { return (string)GetValue(FormulaProperty); } - set { SetValue(FormulaProperty, value); } + get => (string)GetValue(FormulaProperty); + set => SetValue(FormulaProperty, value); } public double Scale { - get { return (double)GetValue(ScaleProperty); } - set { SetValue(ScaleProperty, value); } + get => (double)GetValue(ScaleProperty); + set => SetValue(ScaleProperty, value); } public string SystemTextFontName @@ -40,32 +40,32 @@ public string SystemTextFontName public bool HasError { - get { return (bool)GetValue(HasErrorProperty); } - private set { SetValue(HasErrorProperty, value); } + get => (bool)GetValue(HasErrorProperty); + private set => SetValue(HasErrorProperty, value); } public ObservableCollection Errors { - get { return (ObservableCollection)GetValue(ErrorsProperty); } - private set { SetValue(ErrorsProperty, value); } + get => (ObservableCollection)GetValue(ErrorsProperty); + private set => SetValue(ErrorsProperty, value); } public ControlTemplate ErrorTemplate { - get { return (ControlTemplate)GetValue(ErrorTemplateProperty); } - set { SetValue(ErrorTemplateProperty, value); } + get => (ControlTemplate)GetValue(ErrorTemplateProperty); + set => SetValue(ErrorTemplateProperty, value); } public int SelectionStart { - get { return (int)GetValue(SelectionStartProperty); } - set { SetValue(SelectionStartProperty, value); } + get => (int)GetValue(SelectionStartProperty); + set => SetValue(SelectionStartProperty, value); } public int SelectionLength { - get { return (int)GetValue(SelectionLengthProperty); } - set { SetValue(SelectionLengthProperty, value); } + get => (int)GetValue(SelectionLengthProperty); + set => SetValue(SelectionLengthProperty, value); } public Brush? SelectionBrush diff --git a/src/WpfMath/Controls/VisualContainerElement.cs b/src/WpfMath/Controls/VisualContainerElement.cs index 39bf3236..07074cc4 100644 --- a/src/WpfMath/Controls/VisualContainerElement.cs +++ b/src/WpfMath/Controls/VisualContainerElement.cs @@ -19,7 +19,7 @@ public VisualContainerElement() public DrawingVisual? Visual { - get { return this.visual; } + get => this.visual; set { RemoveVisualChild(this.visual); @@ -31,10 +31,7 @@ public DrawingVisual? Visual } } - protected override int VisualChildrenCount - { - get { return 1; } - } + protected override int VisualChildrenCount => 1; protected override Visual? GetVisualChild(int index) { diff --git a/src/XamlMath.Shared/Atoms/DummyAtom.cs b/src/XamlMath.Shared/Atoms/DummyAtom.cs index e63e7104..a1a48ba9 100644 --- a/src/XamlMath.Shared/Atoms/DummyAtom.cs +++ b/src/XamlMath.Shared/Atoms/DummyAtom.cs @@ -36,10 +36,7 @@ public static DummyAtom CreateLigature(FixedCharAtom ligatureAtom) => public bool IsTextSymbol { get; init; } - public bool IsKern - { - get { return this.Atom is SpaceAtom; } - } + public bool IsKern => this.Atom is SpaceAtom; public Result GetCharFont(ITeXFont texFont) => ((CharSymbol)this.Atom).GetCharFont(texFont); diff --git a/src/XamlMath.Shared/Boxes/Box.cs b/src/XamlMath.Shared/Boxes/Box.cs index 4291a71a..76b0deae 100644 --- a/src/XamlMath.Shared/Boxes/Box.cs +++ b/src/XamlMath.Shared/Boxes/Box.cs @@ -28,10 +28,7 @@ protected Box(IBrush? foreground, IBrush? background) this.Background = background; } - public ReadOnlyCollection Children - { - get { return this.childrenReadOnly; } - } + public ReadOnlyCollection Children => this.childrenReadOnly; public SourceSpan? Source { diff --git a/src/XamlMath.Shared/TexEnvironment.cs b/src/XamlMath.Shared/TexEnvironment.cs index 5e5e4783..9db61f0f 100644 --- a/src/XamlMath.Shared/TexEnvironment.cs +++ b/src/XamlMath.Shared/TexEnvironment.cs @@ -16,8 +16,8 @@ public sealed record TexEnvironment( internal int LastFontId { - get { return this.lastFontId == TexFontUtilities.NoFontId ? this.MathFont.GetMuFontId() : this.lastFontId; } - set { this.lastFontId = value; } + get => this.lastFontId == TexFontUtilities.NoFontId ? this.MathFont.GetMuFontId() : this.lastFontId; + set => this.lastFontId = value; } internal TexEnvironment GetCrampedStyle() => diff --git a/src/XamlMath.Shared/TexFormulaParser.cs b/src/XamlMath.Shared/TexFormulaParser.cs index 535a0d46..a7741ec9 100644 --- a/src/XamlMath.Shared/TexFormulaParser.cs +++ b/src/XamlMath.Shared/TexFormulaParser.cs @@ -72,10 +72,7 @@ static TexFormulaParser() textStyles = formulaSettingsParser.GetTextStyles(); } - internal static string[][] DelimiterNames - { - get { return delimiterNames; } - } + internal static string[][] DelimiterNames => delimiterNames; internal static string GetDelimeterMapping(char character) {