Skip to content

Commit f7387e5

Browse files
LINQ .NET 8 and F! data updates
1 parent d684f25 commit f7387e5

File tree

8 files changed

+63
-60
lines changed

8 files changed

+63
-60
lines changed

1_CS/LINQ/DataLib/DataLib.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>

1_CS/LINQ/DataLib/Formula1.cs

+56-53
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,47 @@ public static class Formula1
55
private static List<Racer>? s_racers;
66
public static IList<Racer> GetChampions() => s_racers ??= InitializeRacers();
77

8-
private static List<Racer> InitializeRacers() => new()
9-
{
10-
new("Nino", "Farina", "Italy", 33, 5, new[] { 1950 }, new[] { "Alfa Romeo" }),
11-
new("Alberto", "Ascari", "Italy", 32, 13, new[] { 1952, 1953 }, new[] { "Ferrari" }),
12-
new("Juan Manuel", "Fangio", "Argentina", 51, 24, new int[] { 1951, 1954, 1955, 1956, 1957 }, new string[] { "Alfa Romeo", "Maserati", "Mercedes", "Ferrari" }),
13-
new("Mike", "Hawthorn", "UK", 45, 3, new int[] { 1958 }, new string[] { "Ferrari" }),
14-
new("Phil", "Hill", "USA", 48, 3, new int[] { 1961 }, new string[] { "Ferrari" }),
15-
new("John", "Surtees", "UK", 111, 6, new int[] { 1964 }, new string[] { "Ferrari" }),
16-
new("Jim", "Clark", "UK", 72, 25, new int[] { 1963, 1965 }, new string[] { "Lotus" }),
17-
new("Jack", "Brabham", "Australia", 125, 14, new int[] { 1959, 1960, 1966 }, new string[] { "Cooper", "Brabham" }),
18-
new("Denny", "Hulme", "New Zealand", 112, 8, new int[] { 1967 }, new string[] { "Brabham" }),
19-
new("Graham", "Hill", "UK", 176, 14, new int[] { 1962, 1968 }, new string[] { "BRM", "Lotus" }),
20-
new("Jochen", "Rindt", "Austria", 60, 6, new int[] { 1970 }, new string[] { "Lotus" }),
21-
new("Jackie", "Stewart", "UK", 99, 27, new int[] { 1969, 1971, 1973 }, new string[] { "Matra", "Tyrrell" }),
22-
new("Emerson", "Fittipaldi", "Brazil", 144, 14, new int[] { 1972, 1974 }, new string[] { "Lotus", "McLaren" }),
23-
new("James", "Hunt", "UK", 92, 10, new int[] { 1976 }, new string[] { "McLaren" }),
24-
new("Mario", "Andretti", "USA", 128, 12, new int[] { 1978 }, new string[] { "Lotus" }),
25-
new("Jody", "Scheckter", "South Africa", 112, 10, new int[] { 1979 }, new string[] { "Ferrari" }),
26-
new("Alan", "Jones", "Australia", 116, 12, new int[] { 1980 }, new string[] { "Williams" }),
27-
new("Keke", "Rosberg", "Finland", 114, 5, new int[] { 1982 }, new string[] { "Williams" }),
28-
new("Niki", "Lauda", "Austria", 171, 25, new int[] { 1975, 1977, 1984 }, new string[] { "Ferrari", "McLaren" }),
29-
new("Nelson", "Piquet", "Brazil", 204, 23, new int[] { 1981, 1983, 1987 }, new string[] { "Brabham", "Williams" }),
30-
new("Ayrton", "Senna", "Brazil", 161, 41, new int[] { 1988, 1990, 1991 }, new string[] { "McLaren" }),
31-
new("Nigel", "Mansell", "UK", 187, 31, new int[] { 1992 }, new string[] { "Williams" }),
32-
new("Alain", "Prost", "France", 199, 51, new int[] { 1985, 1986, 1989, 1993 }, new string[] { "McLaren", "Williams" }),
33-
new("Damon", "Hill", "UK", 115, 22, new int[] { 1996 }, new string[] { "Williams" }),
34-
new("Jacques", "Villeneuve", "Canada", 163, 11, new int[] { 1997 }, new string[] { "Williams" }),
35-
new("Mika", "Hakkinen", "Finland", 161, 20, new int[] { 1998, 1999 }, new string[] { "McLaren" }),
36-
new("Michael", "Schumacher", "Germany", 306, 91, new int[] { 1994, 1995, 2000, 2001, 2002, 2003, 2004 }, new string[] { "Benetton", "Ferrari" }),
37-
new("Fernando", "Alonso", "Spain", 370, 32, new int[] { 2005, 2006 }, new string[] { "Renault" }),
38-
new("Kimi", "Räikkönen", "Finland", 349, 21, new int[] { 2007 }, new string[] { "Ferrari" }),
39-
new("Jenson", "Button", "UK", 306, 16, new int[] { 2009 }, new string[] { "Brawn GP" }),
40-
new("Sebastian", "Vettel", "Germany", 299, 53, new int[] { 2010, 2011, 2012, 2013 }, new string[] { "Red Bull Racing" }),
41-
new("Nico", "Rosberg", "Germany", 206, 24, new int[] { 2016 }, new string[] { "Mercedes" }),
42-
new("Lewis", "Hamilton", "UK", 322, 103, new int[] { 2008, 2014, 2015, 2017, 2018, 2019, 2020 }, new string[] { "McLaren", "Mercedes" }),
43-
new("Max", "Verstappen", "Netherlands", 175, 45, new int[] { 2021, 2022 }, new string[] { "Red Bull Racing" })
44-
};
8+
private static List<Racer> InitializeRacers() =>
9+
[
10+
new("Nino", "Farina", "Italy", 33, 5, [1950], ["Alfa Romeo"]),
11+
new("Alberto", "Ascari", "Italy", 32, 13, [1952, 1953], ["Ferrari"]),
12+
new("Juan Manuel", "Fangio", "Argentina", 51, 24, [1951, 1954, 1955, 1956, 1957], ["Alfa Romeo", "Maserati", "Mercedes", "Ferrari"]),
13+
new("Mike", "Hawthorn", "UK", 45, 3, [1958], ["Ferrari"]),
14+
new("Phil", "Hill", "USA", 48, 3, [1961], ["Ferrari"]),
15+
new("John", "Surtees", "UK", 111, 6, [1964], ["Ferrari"]),
16+
new("Jim", "Clark", "UK", 72, 25, [1963, 1965], ["Lotus"]),
17+
new("Jack", "Brabham", "Australia", 125, 14, [1959, 1960, 1966], ["Cooper", "Brabham"]),
18+
new("Denny", "Hulme", "New Zealand", 112, 8, [1967], ["Brabham"]),
19+
new("Graham", "Hill", "UK", 176, 14, [1962, 1968], ["BRM", "Lotus"]),
20+
new("Jochen", "Rindt", "Austria", 60, 6, [1970], ["Lotus"]),
21+
new("Jackie", "Stewart", "UK", 99, 27, [1969, 1971, 1973], ["Matra", "Tyrrell"]),
22+
new("Emerson", "Fittipaldi", "Brazil", 144, 14, [1972, 1974], ["Lotus", "McLaren"]),
23+
new("James", "Hunt", "UK", 92, 10, [1976], ["McLaren"]),
24+
new("Mario", "Andretti", "USA", 128, 12, [1978], ["Lotus"]),
25+
new("Jody", "Scheckter", "South Africa", 112, 10, [1979], ["Ferrari"]),
26+
new("Alan", "Jones", "Australia", 116, 12, [1980], ["Williams"]),
27+
new("Keke", "Rosberg", "Finland", 114, 5, [1982], ["Williams"]),
28+
new("Niki", "Lauda", "Austria", 171, 25, [1975, 1977, 1984], ["Ferrari", "McLaren"]),
29+
new("Nelson", "Piquet", "Brazil", 204, 23, [1981, 1983, 1987], ["Brabham", "Williams"]),
30+
new("Ayrton", "Senna", "Brazil", 161, 41, [1988, 1990, 1991], ["McLaren"]),
31+
new("Nigel", "Mansell", "UK", 187, 31, [1992], ["Williams"]),
32+
new("Alain", "Prost", "France", 199, 51, [1985, 1986, 1989, 1993], ["McLaren", "Williams"]),
33+
new("Damon", "Hill", "UK", 115, 22, [1996], ["Williams"]),
34+
new("Jacques", "Villeneuve", "Canada", 163, 11, [1997], ["Williams"]),
35+
new("Mika", "Hakkinen", "Finland", 161, 20, [1998, 1999], ["McLaren"]),
36+
new("Michael", "Schumacher", "Germany", 306, 91, [1994, 1995, 2000, 2001, 2002, 2003, 2004], ["Benetton", "Ferrari"]),
37+
new("Fernando", "Alonso", "Spain", 404, 32, [2005, 2006], ["Renault"]),
38+
new("Kimi", "Räikkönen", "Finland", 349, 21, [2007], ["Ferrari"]),
39+
new("Jenson", "Button", "UK", 306, 16, [2009], ["Brawn GP"]),
40+
new("Sebastian", "Vettel", "Germany", 299, 53, [2010, 2011, 2012, 2013], ["Red Bull Racing"]),
41+
new("Nico", "Rosberg", "Germany", 206, 24, [2016], ["Mercedes"]),
42+
new("Lewis", "Hamilton", "UK", 335, 105, [2008, 2014, 2015, 2017, 2018, 2019, 2020], ["McLaren", "Mercedes"]),
43+
new("Max", "Verstappen", "Netherlands", 209, 63, [2021, 2022, 2023, 2024], ["Red Bull Racing"])
44+
];
4545

4646
private static List<Team>? s_teams;
47-
public static IList<Team> GetConstructorChampions() => s_teams ??= new()
48-
{
47+
public static IList<Team> GetConstructorChampions() => s_teams ??=
48+
[
4949
new("Vanwall", 1958),
5050
new("Cooper", 1959, 1960),
5151
new("BRM", 1962),
@@ -55,17 +55,17 @@ public static class Formula1
5555
new("Lotus", 1963, 1965, 1968, 1970, 1972, 1973, 1978),
5656
new("Benetton", 1995),
5757
new("Williams", 1980, 1981, 1986, 1987, 1992, 1993, 1994, 1996, 1997),
58-
new("McLaren", 1974, 1984, 1985, 1988, 1989, 1990, 1991, 1998),
58+
new("McLaren", 1974, 1984, 1985, 1988, 1989, 1990, 1991, 1998, 2024),
5959
new("Renault", 2005, 2006),
6060
new("Ferrari", 1961, 1964, 1975, 1976, 1977, 1979, 1982, 1983, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008),
6161
new("Brawn GP", 2009),
62-
new("Red Bull Racing", 2010, 2011, 2012, 2013, 2022),
62+
new("Red Bull Racing", 2010, 2011, 2012, 2013, 2022, 2023),
6363
new("Mercedes", 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021)
64-
};
64+
];
6565

6666
private static List<Championship>? s_championships;
67-
public static IEnumerable<Championship> GetChampionships() => s_championships ??= new()
68-
{
67+
public static IEnumerable<Championship> GetChampionships() => s_championships ??=
68+
[
6969
new(1950, "Nino Farina", "Juan Manuel Fangio", "Luigi Fagioli"),
7070
new(1951, "Juan Manuel Fangio", "Alberto Ascari", "Froilan Gonzalez"),
7171
new(1952, "Alberto Ascari", "Nino Farina", "Piero Taruffi"),
@@ -139,11 +139,13 @@ public static class Formula1
139139
new(2020, "Lewis Hamilton", "Valtteri Bottas", "Max Verstappen"),
140140
new(2021, "Max Verstappen", "Lewis Hamilton", "Valtteri Bottas"),
141141
new(2022, "Max Verstappen", "Charles Leclerc","Sergio Perez"),
142-
};
142+
new Championship(2023, "Max Verstappen", "Sergio Perez", "Lewis Hamilton"),
143+
new Championship(2024, "Max Verstappen", "Lando Norris", "Charles Leclerc")
144+
];
143145

144146
private static List<Racer>? s_moreRacers;
145-
public static IList<Racer> GetMoreRacers() => s_moreRacers ??= new()
146-
{
147+
public static IList<Racer> GetMoreRacers() => s_moreRacers ??=
148+
[
147149
new Racer("Luigi", "Fagioli", "Italy", Starts: 7, Wins: 1),
148150
new Racer("Jose Froilan", "Gonzalez", "Argentina", 26, 2),
149151
new Racer("Piero", "Taruffi", "Italy", Starts: 18, Wins: 1),
@@ -175,9 +177,10 @@ public static class Formula1
175177
new Racer("Juan Pablo", "Montoya", "Columbia", Starts: 94, Wins: 7),
176178
new Racer("Felipe", "Massa", "Brazil", Starts: 269, Wins: 11),
177179
new Racer("Mark", "Webber", "Australia", Starts: 215, Wins: 9),
178-
new Racer("Daniel", "Ricciardo", "Australia", Starts: 234, Wins: 8),
179-
new Racer("Valtteri", "Bottas", "Finland", Starts: 212, Wins: 10),
180-
new Racer("Charles", "Leclerc", "Monaco", Starts: 115, Wins: 5),
181-
new Racer("Sergio", "Perez", "Mexico", Starts: 248, Wins: 6),
182-
};
183-
}
180+
new Racer("Daniel", "Ricciardo", "Australia", Starts: 257, Wins: 8),
181+
new Racer("Valtteri", "Bottas", "Finland", Starts: 246, Wins: 10),
182+
new Racer("Charles", "Leclerc", "Monaco", Starts: 149, Wins: 8),
183+
new Racer("Sergio", "Perez", "Mexico", Starts: 282, Wins: 6),
184+
new Racer("Lando", "Norris", "UK", Starts: 128, Wins: 4)
185+
];
186+
}

1_CS/LINQ/DataLib/Racer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public record Racer(string FirstName, string LastName, string Country, int Starts, int Wins, IEnumerable<int> Years, IEnumerable<string> Cars) : IComparable<Racer>, IFormattable
44
{
55
public Racer(string FirstName, string LastName, string Country, int Starts, int Wins)
6-
: this(FirstName, LastName, Country, Starts, Wins, new int[] { }, new string[] { })
6+
: this(FirstName, LastName, Country, Starts, Wins, [], [])
77
{ }
88

99
public override string ToString() => $"{FirstName} {LastName}";

1_CS/LINQ/DataLib/Team.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public record Team
55
public Team(string name, params int[] years)
66
{
77
Name = name;
8-
Years = years is not null ? new List<int>(years) : new List<int>();
8+
Years = years is not null ? [.. years] : [];
99
}
1010
public string Name { get; }
1111
public IEnumerable<int> Years { get; }

1_CS/LINQ/EnumerableSample/EnumerableSample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

1_CS/LINQ/ExpressionTreeSample/ExpressionTreeSample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

1_CS/LINQ/LinqIntro/LinqIntro.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

1_CS/LINQ/ParallelLinqSample/ParallelLinqSample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

0 commit comments

Comments
 (0)