Skip to content

Commit 4e704e2

Browse files
Merge pull request #127 from ProfessionalCSharp/main
updates from main
2 parents 6ce9636 + 1531e7e commit 4e704e2

File tree

264 files changed

+13850
-9040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+13850
-9040
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on:
2323
jobs:
2424
analyze:
2525
name: Analyze
26-
runs-on: ubuntu-latest
26+
runs-on: windows-latest
2727
permissions:
2828
actions: read
2929
contents: read
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
language: [ 'javascript' ]
35+
language: [ 'javascript', 'csharp' ]
3636
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3737
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3838

@@ -42,7 +42,7 @@ jobs:
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v1
45+
uses: github/codeql-action/init@v2
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
5353
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5454
# If this step fails, then you should remove it and run the build manually (see below)
5555
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v1
56+
uses: github/codeql-action/autobuild@v2
5757

5858
# ℹ️ Command-line programs to run using the OS shell.
5959
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
6767
# make release
6868

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v1
70+
uses: github/codeql-action/analyze@v2

1_CS/Arrays/SortingSample/Person.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public record Person(string FirstName, string LastName) : IComparable<Person>
44
{
55
public int CompareTo(Person? other)
66
{
7-
if (other == null) throw new ArgumentNullException("other");
7+
ArgumentNullException.ThrowIfNull(other);
88

99
int result = LastName.CompareTo(other.LastName);
1010
if (result == 0)

1_CS/Collections/DictionarySample/Employee.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
public record Employee
1+
namespace DictionarySample;
2+
3+
public record Employee
24
{
35
private readonly string _name;
46
private readonly decimal _salary;

1_CS/Collections/DictionarySample/EmployeeId.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
public class EmployeeIdException : Exception
1+
namespace DictionarySample;
2+
3+
public class EmployeeIdException : Exception
24
{
35
public EmployeeIdException(string message) : base(message) { }
46
}
@@ -10,7 +12,7 @@ public struct EmployeeId : IEquatable<EmployeeId>
1012

1113
public EmployeeId(string id)
1214
{
13-
if (id == null) throw new ArgumentNullException(nameof(id));
15+
ArgumentNullException.ThrowIfNull(id);
1416

1517
_prefix = (id.ToUpper())[0];
1618
int last = id.Length > 7 ? 7 : id.Length;

1_CS/Collections/DictionarySample/Program.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
EmployeeId idKyle = new("J18");
2-
Employee kyle = new Employee(idKyle, "Kyle Bush", 138_000.00m );
1+
using DictionarySample;
2+
3+
EmployeeId idKyle = new("J18");
4+
Employee kyle = new(idKyle, "Kyle Bush", 138_000.00m );
35

46
EmployeeId idMartin = new("J19");
57
Employee martin = new(idMartin, "Martin Truex Jr", 73_000.00m);
68

79
EmployeeId idKevin = new("S4");
810
Employee kevin = new(idKevin, "Kevin Harvick", 116_000.00m);
911

10-
EmployeeId idDenny = new EmployeeId("J11");
11-
Employee denny = new Employee(idDenny, "Denny Hamlin", 127_000.00m);
12+
EmployeeId idDenny = new("J11");
13+
Employee denny = new(idDenny, "Denny Hamlin", 127_000.00m);
1214

1315
EmployeeId idJoey = new("T22");
1416
Employee joey = new(idJoey, "Joey Logano", 96_000.00m);

1_CS/Collections/ImmutableCollectionSample/GlobalUsings.cs

Lines changed: 0 additions & 1 deletion
This file was deleted.

1_CS/Collections/ImmutableCollectionSample/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
SimpleArrayDemo();
1+
using System.Collections.Immutable;
2+
3+
SimpleArrayDemo();
24
ImmutableList<Account> accounts = CreateImmutableList();
35
UsingABuilder(accounts);
46
LinqDemo();

1_CS/Collections/ListSamples/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
Console.WriteLine("object not found in collection");
4747
}
4848

49-
List<Racer> racers2 = new(new Racer[] {
50-
new(12, "Jochen", "Rindt", "Austria", 6),
51-
new(22, "Ayrton", "Senna", "Brazil", 41) });
49+
List<Racer> racers2 = new(
50+
new Racer[]
51+
{
52+
new(12, "Jochen", "Rindt", "Austria", 6),
53+
new(22, "Ayrton", "Senna", "Brazil", 41)
54+
});

1_CS/Collections/Readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Please check my blog [csharp.christiannagel.com](https://csharp.christiannagel.c
2020

2121
Thank you!
2222

23-
## Updates with C# 10
23+
## Updates with C# 10 .NET 6
2424

25-
See [Updates with C# 10](../../Dotnet6Updates.md)
25+
.NET 6 contains a new PriorityQueue class which returns items based on a priority. See the new sample code [PriorityQueueSample](../../5_More/Collections/PriorityQueueSample/).
26+
27+
Also see [Updates with C# 10](../../Dotnet6Updates.md)

1_CS/LINQ/DataLib/Formula1.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,28 @@ public static class Formula1
1919
new("Graham", "Hill", "UK", 176, 14, new int[] { 1962, 1968 }, new string[] { "BRM", "Lotus" }),
2020
new("Jochen", "Rindt", "Austria", 60, 6, new int[] { 1970 }, new string[] { "Lotus" }),
2121
new("Jackie", "Stewart", "UK", 99, 27, new int[] { 1969, 1971, 1973 }, new string[] { "Matra", "Tyrrell" }),
22-
new("Emerson", "Fittipaldi", "Brazil", 143, 14, new int[] { 1972, 1974 }, new string[] { "Lotus", "McLaren" }),
23-
new("James", "Hunt", "UK", 91, 10, new int[] { 1976 }, new string[] { "McLaren" }),
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" }),
2424
new("Mario", "Andretti", "USA", 128, 12, new int[] { 1978 }, new string[] { "Lotus" }),
2525
new("Jody", "Scheckter", "South Africa", 112, 10, new int[] { 1979 }, new string[] { "Ferrari" }),
26-
new("Alan", "Jones", "Australia", 115, 12, new int[] { 1980 }, new string[] { "Williams" }),
26+
new("Alan", "Jones", "Australia", 116, 12, new int[] { 1980 }, new string[] { "Williams" }),
2727
new("Keke", "Rosberg", "Finland", 114, 5, new int[] { 1982 }, new string[] { "Williams" }),
28-
new("Niki", "Lauda", "Austria", 173, 25, new int[] { 1975, 1977, 1984 }, new string[] { "Ferrari", "McLaren" }),
28+
new("Niki", "Lauda", "Austria", 171, 25, new int[] { 1975, 1977, 1984 }, new string[] { "Ferrari", "McLaren" }),
2929
new("Nelson", "Piquet", "Brazil", 204, 23, new int[] { 1981, 1983, 1987 }, new string[] { "Brabham", "Williams" }),
3030
new("Ayrton", "Senna", "Brazil", 161, 41, new int[] { 1988, 1990, 1991 }, new string[] { "McLaren" }),
3131
new("Nigel", "Mansell", "UK", 187, 31, new int[] { 1992 }, new string[] { "Williams" }),
32-
new("Alain", "Prost", "France", 197, 51, new int[] { 1985, 1986, 1989, 1993 }, new string[] { "McLaren", "Williams" }),
33-
new("Damon", "Hill", "UK", 114, 22, new int[] { 1996 }, new string[] { "Williams" }),
34-
new("Jacques", "Villeneuve", "Canada", 165, 11, new int[] { 1997 }, new string[] { "Williams" }),
35-
new("Mika", "Hakkinen", "Finland", 160, 20, new int[] { 1998, 1999 }, new string[] { "McLaren" }),
36-
new("Michael", "Schumacher", "Germany", 287, 91, new int[] { 1994, 1995, 2000, 2001, 2002, 2003, 2004 }, new string[] { "Benetton", "Ferrari" }),
37-
new("Fernando", "Alonso", "Spain", 336, 32, new int[] { 2005, 2006 }, new string[] { "Renault" }),
38-
new("Kimi", "Räikkönen", "Finland", 352, 21, new int[] { 2007 }, new string[] { "Ferrari" }),
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", 347, 32, new int[] { 2005, 2006 }, new string[] { "Renault" }),
38+
new("Kimi", "Räikkönen", "Finland", 349, 21, new int[] { 2007 }, new string[] { "Ferrari" }),
3939
new("Jenson", "Button", "UK", 306, 16, new int[] { 2009 }, new string[] { "Brawn GP" }),
40-
new("Sebastian", "Vettel", "Germany", 280, 53, new int[] { 2010, 2011, 2012, 2013 }, new string[] { "Red Bull Racing" }),
41-
new("Nico", "Rosberg", "Germany", 207, 24, new int[] { 2016 }, new string[] { "Mercedes" }),
42-
new("Lewis", "Hamilton", "UK", 288, 103, new int[] { 2008, 2014, 2015, 2017, 2018, 2019, 2020 }, new string[] { "McLaren", "Mercedes" }),
43-
new("Max", "Verstappen", "Netherlands", 141, 20, new int[] { 2021 }, new string[] { "Red Bull Racing" })
40+
new("Sebastian", "Vettel", "Germany", 291, 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", 302, 103, new int[] { 2008, 2014, 2015, 2017, 2018, 2019, 2020 }, new string[] { "McLaren", "Mercedes" }),
43+
new("Max", "Verstappen", "Netherlands", 155, 29, new int[] { 2021 }, new string[] { "Red Bull Racing" })
4444
};
4545

4646
private static List<Team>? s_teams;
@@ -169,12 +169,12 @@ public static class Formula1
169169
new Racer("Riccardo", "Patrese", "Italy", Starts: 256, Wins: 6),
170170
new Racer("David", "Coulthard", "UK", Starts: 246, Wins: 13),
171171
new Racer("Heinz-Harald", "Frentzen", "Germany", Starts: 156, Wins: 3),
172-
new Racer("Eddie", "Irvine", "UK", Starts: 147, Wins: 4),
172+
new Racer("Eddie", "Irvine", "UK", Starts: 145, Wins: 4),
173173
new Racer("Rubens", "Barrichello", "Brazil", Starts: 322, Wins: 11),
174174
new Racer("Juan Pablo", "Montoya", "Columbia", Starts: 94, Wins: 7),
175175
new Racer("Felipe", "Massa", "Brazil", Starts: 269, Wins: 11),
176176
new Racer("Mark", "Webber", "Australia", Starts: 215, Wins: 9),
177-
new Racer("Daniel", "Ricciardo", "Australia", Starts: 210, Wins: 8),
178-
new Racer("Valtteri", "Bottas", "Finland", Starts: 178, Wins: 10)
177+
new Racer("Daniel", "Ricciardo", "Australia", Starts: 224, Wins: 8),
178+
new Racer("Valtteri", "Bottas", "Finland", Starts: 192, Wins: 10)
179179
};
180180
}

0 commit comments

Comments
 (0)