Skip to content

Commit a3bb643

Browse files
committed
Use IReadOnlyList instead of arrays for MarketChart properties
1 parent 66470c0 commit a3bb643

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

App/Services/Extensions/ListExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Services.Extensions;
22

33
public static class ListExtensions
44
{
5-
public static bool IsNullOrEmpty<T>(this IList<T>? list)
5+
public static bool IsNullOrEmpty<T>(this IReadOnlyList<T>? list)
66
{
77
return list is null || list.Count == 0;
88
}

App/Services/Models/MarketChart.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ namespace Services.Models;
55
public record MarketChart
66
{
77
[JsonPropertyName("prices")]
8-
public decimal[][]? Prices { get; init; }
9-
[JsonPropertyName("market_caps")]
10-
public decimal[][]? MarketCaps { get; init; }
8+
public IReadOnlyList<IReadOnlyList<decimal>>? Prices { get; init; }
9+
[JsonPropertyName("market_caps")] public IReadOnlyList<IReadOnlyList<decimal>>? MarketCaps { get; init; }
1110
[JsonPropertyName("total_volumes")]
12-
public decimal[][]? TotalVolumes { get; init; }
11+
public IReadOnlyList<IReadOnlyList<decimal>>? TotalVolumes { get; init; }
1312
}

App/Services/Utility/MarketChartHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public static List<MarketChartPoint> MapMarketChartToMarketChartPoints(MarketCha
2222
throw new MarketChartException($"{nameof(marketChart.TotalVolumes)} is null");
2323
}
2424

25-
if (marketChart.Prices.Length != marketChart.MarketCaps.Length ||
26-
marketChart.Prices.Length != marketChart.TotalVolumes.Length)
25+
if (marketChart.Prices.Count != marketChart.MarketCaps.Count ||
26+
marketChart.Prices.Count != marketChart.TotalVolumes.Count)
2727
{
2828
throw new MarketChartException("Unequal number of data points in market chart");
2929
}
3030

3131
var marketChartPoints = new List<MarketChartPoint>();
32-
for (var i = 0; i < marketChart.Prices.Length; i++)
32+
for (var i = 0; i < marketChart.Prices.Count; i++)
3333
{
3434
var marketData = new MarketChartPoint
3535
{

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<EnforeCodeStyleInBuild>true</EnforeCodeStyleInBuild>
1515
<EnableNETAnalyzers>true</EnableNETAnalyzers>
1616
<EnableCodeAnalysis>true</EnableCodeAnalysis>
17-
<NoWarn>S6678;CA2007;CA1848;CA1002;CA1819;CA1305;CA1062;CA2000;CA5394;CA1724;CA1031;S3267;CA1515;S1118;CA1707;CA2234;CA1051;CA1063;S3881</NoWarn>
17+
<NoWarn>S6678;CA2007;CA1848;CA1002;CA1305;CA1062;CA2000;CA5394;CA1724;CA1031;S3267;CA1515;S1118;CA1707;CA2234;CA1051;CA1063;S3881</NoWarn>
1818
</PropertyGroup>
1919
<ItemGroup Condition="'$(MSBuildProjectExtension)' != '.dcproj'">
2020
<PackageReference Include="SonarAnalyzer.CSharp">

0 commit comments

Comments
 (0)