Skip to content

Commit

Permalink
Merge pull request #1364 from beto-rodriguez/clean-build-warnings
Browse files Browse the repository at this point in the history
Clean build warnings and update with c#12 syntax
  • Loading branch information
beto-rodriguez committed Nov 18, 2023
2 parents 0aca63e + ce430c6 commit 5ca552f
Show file tree
Hide file tree
Showing 130 changed files with 812 additions and 1,103 deletions.
28 changes: 14 additions & 14 deletions build/build-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharp.Wpf/LiveChartsCore.SkiaSha
dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj -c $configuration
dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj -c $configuration
dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/LiveChartsCore.SkiaSharpView.Eto.csproj -c $configuration
dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj -c $configuration

$msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
# LiveCharts requires VisualStudio 17.8
# but it seems that the current image installed is 17.6
# for now we are skiping msbuilds

& $msbuild `
./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj `
/p:configuration=$configuration `
/restore
# dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj -c $configuration

dotnet workload install macos
dotnet workload install ios
dotnet workload install maccatalyst
dotnet workload install android
# $msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe

& $msbuild `
./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj `
/p:configuration=$configuration `
/restore
# & $msbuild `
# ./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj `
# /p:configuration=$configuration `
# /restore

# & $msbuild `
# ./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj `
# /p:configuration=$configuration `
# /restore
2 changes: 1 addition & 1 deletion samples/MauiSample/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public partial class AppShell : Shell
{
private bool _isLoaded = false;
private readonly Dictionary<string, string> _routesSamples = new();
private readonly Dictionary<string, string> _routesSamples = [];

public AppShell()
{
Expand Down
7 changes: 1 addition & 6 deletions samples/MauiSample/Platforms/Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
namespace MauiSample
{
[Application]
public class MainApplication : MauiApplication
public class MainApplication(IntPtr handle, JniHandleOwnership ownership) : MauiApplication(handle, ownership)
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
12 changes: 6 additions & 6 deletions samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public partial class ViewModel : ObservableObject
public ViewModel()
{
// Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark
_observableValues = new ObservableCollection<ObservablePoint>
{
_observableValues =
[
// Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark
// or use any INotifyPropertyChanged implementation // mark
new ObservablePoint(_index++, 2),
Expand All @@ -35,15 +35,15 @@ public ViewModel()
new(_index++, 3),
new(_index++, 8),
new(_index++, 3)
};
];

Series = new ObservableCollection<ISeries>
{
Series =
[
new ColumnSeries<ObservablePoint>
{
Values = _observableValues
}
};
];

// in the following sample notice that the type int does not implement INotifyPropertyChanged
// and our Series.Values property is of type List<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ViewModel()
columnSeries1.PointMeasured += OnPointMeasured;
columnSeries2.PointMeasured += OnPointMeasured;

Series = new List<ISeries> { columnSeries1, columnSeries2 };
Series = [columnSeries1, columnSeries2];
}

private void OnPointMeasured(ChartPoint<float, RoundedRectangleGeometry, LabelGeometry> point)
Expand Down
21 changes: 6 additions & 15 deletions samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,11 @@ public ViewModel()
public ISeries[] Series { get; set; }
}

public class FinancialData
public class FinancialData(DateTime date, double high, double open, double close, double low)
{
public FinancialData(DateTime date, double high, double open, double close, double low)
{
Date = date;
High = high;
Open = open;
Close = close;
Low = low;
}

public DateTime Date { get; set; }
public double High { get; set; }
public double Open { get; set; }
public double Close { get; set; }
public double Low { get; set; }
public DateTime Date { get; set; } = date;
public double High { get; set; } = high;
public double Open { get; set; } = open;
public double Close { get; set; } = close;
public double Low { get; set; } = low;
}
9 changes: 2 additions & 7 deletions samples/ViewModelsSamples/General/ConditionalDraw/City.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@

namespace ViewModelsSamples.General.ConditionalDraw;

public partial class City : ObservableObject
public partial class City(double population) : ObservableObject
{
public City(double population)
{
_population = population;
}

[ObservableProperty]
private double _population;
private double _population = population;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ namespace ViewModelsSamples.General.ConditionalDraw;

public partial class ViewModel : ObservableObject
{
private readonly ObservableCollection<ObservableValue> _values = new();
private readonly ObservableCollection<ObservableValue> _values = [];

public ViewModel()
{
var dangerPaint = new SolidColorPaint(SKColors.Red);

_values = new ObservableCollection<ObservableValue>
{
_values =
[
new(2), new(5), new(4), new(6), new(8), new(3), new(2), new(4), new(6)
};
];

var series = new ColumnSeries<ObservableValue>
{
Expand Down
12 changes: 3 additions & 9 deletions samples/ViewModelsSamples/General/Legends/AvailablePosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

namespace ViewModelsSamples.General.Legends;

public class AvailablePosition
public class AvailablePosition(string name, LegendPosition position)
{
public AvailablePosition(string name, LegendPosition position)
{
Name = name;
Position = position;
}

public string Name { get; set; }
public LegendPosition Position { get; set; }
public string Name { get; set; } = name;
public LegendPosition Position { get; set; } = position;
}
8 changes: 4 additions & 4 deletions samples/ViewModelsSamples/General/RealTime/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ namespace ViewModelsSamples.General.RealTime;
public partial class ViewModel : ObservableObject
{
private readonly Random _random = new();
private readonly List<DateTimePoint> _values = new();
private readonly List<DateTimePoint> _values = [];
private readonly DateTimeAxis _customAxis;

public ViewModel()
{
Series = new ObservableCollection<ISeries>
{
Series =
[
new LineSeries<DateTimePoint>
{
Values = _values,
Fill = null,
GeometryFill = null,
GeometryStroke = null
}
};
];

_customAxis = new DateTimeAxis(TimeSpan.FromSeconds(1), Formatter)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/ViewModelsSamples/General/Scrollable/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace ViewModelsSamples.General.Scrollable;
public partial class ViewModel
{
private bool _isDown = false;
private readonly ObservableCollection<ObservablePoint> _values = new();
private readonly ObservableCollection<ObservablePoint> _values = [];

public ViewModel()
{
Expand Down
12 changes: 3 additions & 9 deletions samples/ViewModelsSamples/General/Tooltips/AvailablePositions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

namespace ViewModelsSamples.General.Tooltips;

public class AvailablePositions
public class AvailablePositions(string name, TooltipPosition position)
{
public AvailablePositions(string name, TooltipPosition position)
{
Name = name;
Position = position;
}

public string Name { get; set; }
public TooltipPosition Position { get; set; }
public string Name { get; set; } = name;
public TooltipPosition Position { get; set; } = position;
}
12 changes: 6 additions & 6 deletions samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public partial class ViewModel : ObservableObject
public ViewModel()
{
// Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark
_observableValues = new ObservableCollection<ObservableValue>
{
_observableValues =
[
// Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark
// or use any INotifyPropertyChanged implementation // mark
new ObservableValue(2),
Expand All @@ -35,16 +35,16 @@ public ViewModel()
new(3),
new(4),
new(3)
};
];

Series = new ObservableCollection<ISeries>
{
Series =
[
new LineSeries<ObservableValue>
{
Values = _observableValues,
Fill = null
}
};
];

// in the following sample notice that the type int does not implement INotifyPropertyChanged
// and our Series.Values property is of type List<T>
Expand Down
6 changes: 3 additions & 3 deletions samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public partial class ViewModel : ObservableObject
public ViewModel()
{
// Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark
Series = new ObservableCollection<ISeries>
{
Series =
[
// Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark
// or use any INotifyPropertyChanged implementation // mark
new PieSeries<ObservableValue> { Values = new[] { new ObservableValue(2) } },
Expand All @@ -25,7 +25,7 @@ public ViewModel()
new PieSeries<ObservableValue> { Values = new[] { new ObservableValue(7) } },
new PieSeries<ObservableValue> { Values = new[] { new ObservableValue(4) } },
new PieSeries<ObservableValue> { Values = new[] { new ObservableValue(3) } }
};
];
}

public ObservableCollection<ISeries> Series { get; set; }
Expand Down
12 changes: 6 additions & 6 deletions samples/ViewModelsSamples/Scatter/AutoUpdate/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public partial class ViewModel : ObservableObject
public ViewModel()
{
// Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark
_observableValues = new ObservableCollection<WeightedPoint>
{
_observableValues =
[
// Use the WeightedPoint, ObservableValue or ObservablePoint types to let the chart listen for property changes // mark
// or use any INotifyPropertyChanged implementation // mark
new WeightedPoint(_index++, 2, 6),
Expand All @@ -35,12 +35,12 @@ public ViewModel()
new(_index++, 3, 8),
new(_index++, 8, 9),
new(_index++, 3, 4)
};
];

Series = new ObservableCollection<ISeries>
{
Series =
[
new ScatterSeries<WeightedPoint> { Values = _observableValues, GeometrySize = 50 }
};
];

// in the following series notice that the type int does not implement INotifyPropertyChanged
// and our Series.Values collection is of type List<T>
Expand Down
12 changes: 6 additions & 6 deletions samples/ViewModelsSamples/StepLines/AutoUpdate/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public partial class ViewModel : ObservableObject
public ViewModel()
{
// Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark
_observableValues = new ObservableCollection<ObservablePoint>
{
_observableValues =
[
// Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark
// or use any INotifyPropertyChanged implementation // mark
new ObservablePoint(_index++, 2),
Expand All @@ -35,16 +35,16 @@ public ViewModel()
new(_index++, 3),
new(_index++, 4),
new(_index++, 3)
};
];

Series = new ObservableCollection<ISeries>
{
Series =
[
new StepLineSeries<ObservablePoint>
{
Values = _observableValues,
// Fill = null
}
};
];

// in the following series notice that the type int does not implement INotifyPropertyChanged
// and our Series.Values collection is of type List<T>
Expand Down
8 changes: 1 addition & 7 deletions samples/WPFSample/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@

namespace WPFSample;

public class Command : ICommand
public class Command(Action<object> command) : ICommand
{
private readonly Action<object> command;
public event EventHandler CanExecuteChanged;

public Command(Action<object> command)
{
this.command = command;
}

public bool CanExecute(object parameter)
{
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace XamarinSample;
public partial class AppShell : Shell
{
private bool _isLoaded = false;
private readonly Dictionary<string, string> _routesSamples = new();
private readonly Dictionary<string, string> _routesSamples = [];

public AppShell()
{
Expand Down
Loading

0 comments on commit 5ca552f

Please sign in to comment.