Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable nullable #2392

Merged
merged 32 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ff016f3
Enable nullable
ErikSchierboom Feb 17, 2025
160d446
Several nullable fixes
ErikSchierboom Feb 17, 2025
7224d74
Fix dot-dsl
ErikSchierboom Feb 17, 2025
2f23d26
calculator-conundrum: fix nullable
ErikSchierboom Feb 18, 2025
49a7836
developer-privileges: fix nullable
ErikSchierboom Feb 18, 2025
8fffdd5
face-id2: fix
ErikSchierboom Feb 18, 2025
4e9b126
zebra-puzzle: fix
ErikSchierboom Feb 18, 2025
a8c3725
pov: fix
ErikSchierboom Feb 18, 2025
67e7a96
zipper: fix
ErikSchierboom Feb 18, 2025
d2d53cf
tournament: fix
ErikSchierboom Feb 18, 2025
5585def
simple-linked-list: fix
ErikSchierboom Feb 18, 2025
afe8353
sgf-parsing: fix
ErikSchierboom Feb 18, 2025
a935891
rest-api: fix
ErikSchierboom Feb 18, 2025
e7ce50e
react: fix
ErikSchierboom Feb 18, 2025
4dbfe24
robot-name: fix
ErikSchierboom Feb 18, 2025
a574c2f
say: fix
ErikSchierboom Feb 18, 2025
4544766
satellite: fix
ErikSchierboom Feb 18, 2025
6ce4d1f
change: fix
ErikSchierboom Feb 18, 2025
f9b5d4b
custom-set: fix
ErikSchierboom Feb 18, 2025
77e7cff
grep: fix
ErikSchierboom Feb 18, 2025
a0f7606
binary-search-tree: fix
ErikSchierboom Feb 18, 2025
00326bc
linked-list: fix
ErikSchierboom Feb 18, 2025
23670b3
alphametics: fix
ErikSchierboom Feb 18, 2025
fcc0bf0
hangman: fix
ErikSchierboom Feb 18, 2025
98788b4
wizards-and-warriors-2: fix
ErikSchierboom Feb 18, 2025
2cb6b76
remote-control-cleanup: fix
ErikSchierboom Feb 18, 2025
2e903f9
land-grab-in-space: fix
ErikSchierboom Feb 18, 2025
a4649ef
instruments-of-texas: fix
ErikSchierboom Feb 18, 2025
a3ba076
markdown: fix
ErikSchierboom Feb 18, 2025
f91be2d
Dont remove nullable in new exercise
ErikSchierboom Feb 18, 2025
caca361
More fixes
ErikSchierboom Feb 18, 2025
5b59b0c
remote-control: fix
ErikSchierboom Feb 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bin/add-practice-exercise.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ $project = "${exerciseDir}/${ExerciseName}.csproj"
[xml]$projectXml = Get-Content "${project}"
$projectXml.Project.RemoveChild($projectXml.Project.ItemGroup[1])
$projectXml.Project.PropertyGroup.RemoveChild($projectXml.Project.PropertyGroup.SelectSingleNode("ImplicitUsings"))
$projectXml.Project.PropertyGroup.RemoveChild($projectXml.Project.PropertyGroup.SelectSingleNode("Nullable"))
$projectXml.Save("${project}")

# Update project packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/bird-watcher/BirdWatcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/calculator-conundrum/.meta/Exemplar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public static class SimpleCalculator
{
public static string Calculate(int operand1, int operand2, string operation)
public static string Calculate(int operand1, int operand2, string? operation)
{
int result;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public static class SimpleCalculator
{
public static string Calculate(int operand1, int operand2, string operation)
public static string Calculate(int operand1, int operand2, string? operation)
{
throw new NotImplementedException("Please implement the SimpleCalculator.Calculate() method");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/cars-assemble/CarsAssemble.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
10 changes: 5 additions & 5 deletions exercises/concept/developer-privileges/.meta/Exemplar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public class Authenticator
//**** please do not modify the FacialFeatures class ****
public class FacialFeatures
{
public string EyeColor { get; set; }
public decimal PhiltrumWidth { get; set; }
public required string EyeColor { get; set; }
public required decimal PhiltrumWidth { get; set; }
}

//**** please do not modify the Identity class ****
public class Identity
{
public string Email { get; set; }
public FacialFeatures FacialFeatures { get; set; }
public IList<string> NameAndAddress { get; set; }
public required string Email { get; set; }
public required FacialFeatures FacialFeatures { get; set; }
public required IList<string> NameAndAddress { get; set; }
}
10 changes: 5 additions & 5 deletions exercises/concept/developer-privileges/DeveloperPrivileges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public class Authenticator
//**** please do not modify the FacialFeatures class ****
public class FacialFeatures
{
public string EyeColor { get; set; }
public decimal PhiltrumWidth { get; set; }
public required string EyeColor { get; set; }
public required decimal PhiltrumWidth { get; set; }
}

//**** please do not modify the Identity class ****
public class Identity
{
public string Email { get; set; }
public FacialFeatures FacialFeatures { get; set; }
public IList<string> NameAndAddress { get; set; }
public required string Email { get; set; }
public required FacialFeatures FacialFeatures { get; set; }
public required IList<string> NameAndAddress { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/elons-toys/ElonsToys.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions exercises/concept/faceid-2/.meta/Exemplar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected bool Equals(FacialFeatures other)
return EyeColor == other.EyeColor && PhiltrumWidth.Equals(other.PhiltrumWidth);
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
Expand Down Expand Up @@ -47,7 +47,7 @@ protected bool Equals(Identity other)
return Email == other.Email && Equals(FacialFeatures, other.FacialFeatures);
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
Expand Down
1 change: 1 addition & 0 deletions exercises/concept/faceid-2/Faceid2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/hyperia-forex/HyperiaForex.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions exercises/concept/instruments-of-texas/.meta/Exemplar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public string TestMultiplication(int x, int y)
}
catch (CalculationException cex) when (cex.Operand1 < 0 && cex.Operand2 < 0)
{
return "Multiply failed for negative operands. " + cex.InnerException.Message;
return "Multiply failed for negative operands. " + cex.InnerException!.Message;
}
catch (CalculationException cex)
{
return "Multiply failed for mixed or positive operands. " + cex.InnerException.Message;
return "Multiply failed for mixed or positive operands. " + cex.InnerException!.Message;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
11 changes: 4 additions & 7 deletions exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,13 @@ public void GetLongestSideReverseInsertionOrder()
private Plot CreatePlot(Coord coord1, Coord coord2, Coord coord3, Coord coord4)
{
Type plotType = typeof(Plot);
Type[] types = new Type[] { typeof(Coord), typeof(Coord), typeof(Coord), typeof(Coord) };
ConstructorInfo constructorInfoObj = plotType.GetConstructor(types);
Type[] types = [typeof(Coord), typeof(Coord), typeof(Coord), typeof(Coord)];
ConstructorInfo? constructorInfoObj = plotType.GetConstructor(types);
if (constructorInfoObj != null)
{
return (Plot)constructorInfoObj.Invoke(new object[] { coord1, coord2, coord3, coord4 });
return (Plot)constructorInfoObj.Invoke([coord1, coord2, coord3, coord4]);
}

else
{
throw new InvalidOperationException("You need to implement a constructor for the struct Plot. The constructor must take 4 co-ordinates. No such constructor can be found.");
}
throw new InvalidOperationException("You need to implement a constructor for the struct Plot. The constructor must take 4 co-ordinates. No such constructor can be found.");
}
}
1 change: 1 addition & 0 deletions exercises/concept/log-analysis/LogAnalysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/log-levels/LogLevels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/logs-logs-logs/LogsLogsLogs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/need-for-speed/NeedForSpeed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/orm-in-one-go/OrmInOneGo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions exercises/concept/parsing-log-files/ParsingLogFiles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
4 changes: 4 additions & 0 deletions exercises/concept/remote-control-cleanup/.meta/Exemplar.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable CS8618

public class RemoteControlCar
{
private enum SpeedUnits
Expand Down Expand Up @@ -95,3 +97,5 @@ private void SetSpeed(Speed speed)
currentSpeed = speed;
}
}

#pragma warning restore CS8618
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Drive()
DistanceTravelled += 10;
}

public int CompareTo(ProductionRemoteControlCar other)
public int CompareTo(ProductionRemoteControlCar? other)
{
if (ReferenceEquals(this, other)) return 0;
if (ReferenceEquals(null, other)) return 1;
Expand Down
Loading