diff --git a/bin/add-practice-exercise.ps1 b/bin/add-practice-exercise.ps1
index 21ab2d6f6..16b1cabbc 100644
--- a/bin/add-practice-exercise.ps1
+++ b/bin/add-practice-exercise.ps1
@@ -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
diff --git a/exercises/concept/annalyns-infiltration/AnnalynsInfiltration.csproj b/exercises/concept/annalyns-infiltration/AnnalynsInfiltration.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/annalyns-infiltration/AnnalynsInfiltration.csproj
+++ b/exercises/concept/annalyns-infiltration/AnnalynsInfiltration.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/attack-of-the-trolls/AttackOfTheTrolls.csproj b/exercises/concept/attack-of-the-trolls/AttackOfTheTrolls.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/attack-of-the-trolls/AttackOfTheTrolls.csproj
+++ b/exercises/concept/attack-of-the-trolls/AttackOfTheTrolls.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/authentication-system/AuthenticationSystem.csproj b/exercises/concept/authentication-system/AuthenticationSystem.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/authentication-system/AuthenticationSystem.csproj
+++ b/exercises/concept/authentication-system/AuthenticationSystem.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/beauty-salon-goes-global/BeautySalonGoesGlobal.csproj b/exercises/concept/beauty-salon-goes-global/BeautySalonGoesGlobal.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/beauty-salon-goes-global/BeautySalonGoesGlobal.csproj
+++ b/exercises/concept/beauty-salon-goes-global/BeautySalonGoesGlobal.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/bird-watcher/BirdWatcher.csproj b/exercises/concept/bird-watcher/BirdWatcher.csproj
index be8126449..8b75d52b0 100644
--- a/exercises/concept/bird-watcher/BirdWatcher.csproj
+++ b/exercises/concept/bird-watcher/BirdWatcher.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/booking-up-for-beauty/BookingUpForBeauty.csproj b/exercises/concept/booking-up-for-beauty/BookingUpForBeauty.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/booking-up-for-beauty/BookingUpForBeauty.csproj
+++ b/exercises/concept/booking-up-for-beauty/BookingUpForBeauty.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/building-telemetry/BuildingTelemetry.csproj b/exercises/concept/building-telemetry/BuildingTelemetry.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/building-telemetry/BuildingTelemetry.csproj
+++ b/exercises/concept/building-telemetry/BuildingTelemetry.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/calculator-conundrum/.meta/Exemplar.cs b/exercises/concept/calculator-conundrum/.meta/Exemplar.cs
index 405c4c727..325304451 100644
--- a/exercises/concept/calculator-conundrum/.meta/Exemplar.cs
+++ b/exercises/concept/calculator-conundrum/.meta/Exemplar.cs
@@ -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
diff --git a/exercises/concept/calculator-conundrum/CalculatorConundrum.cs b/exercises/concept/calculator-conundrum/CalculatorConundrum.cs
index fc87406a4..e56ac5ca8 100644
--- a/exercises/concept/calculator-conundrum/CalculatorConundrum.cs
+++ b/exercises/concept/calculator-conundrum/CalculatorConundrum.cs
@@ -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");
}
diff --git a/exercises/concept/calculator-conundrum/CalculatorConundrum.csproj b/exercises/concept/calculator-conundrum/CalculatorConundrum.csproj
index 34a056ea9..54d543da1 100644
--- a/exercises/concept/calculator-conundrum/CalculatorConundrum.csproj
+++ b/exercises/concept/calculator-conundrum/CalculatorConundrum.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/cars-assemble/CarsAssemble.csproj b/exercises/concept/cars-assemble/CarsAssemble.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/cars-assemble/CarsAssemble.csproj
+++ b/exercises/concept/cars-assemble/CarsAssemble.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/developer-privileges/.meta/Exemplar.cs b/exercises/concept/developer-privileges/.meta/Exemplar.cs
index d53799069..9a4a58d72 100644
--- a/exercises/concept/developer-privileges/.meta/Exemplar.cs
+++ b/exercises/concept/developer-privileges/.meta/Exemplar.cs
@@ -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 NameAndAddress { get; set; }
+ public required string Email { get; set; }
+ public required FacialFeatures FacialFeatures { get; set; }
+ public required IList NameAndAddress { get; set; }
}
diff --git a/exercises/concept/developer-privileges/DeveloperPrivileges.cs b/exercises/concept/developer-privileges/DeveloperPrivileges.cs
index eaf6906e3..76e431764 100644
--- a/exercises/concept/developer-privileges/DeveloperPrivileges.cs
+++ b/exercises/concept/developer-privileges/DeveloperPrivileges.cs
@@ -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 NameAndAddress { get; set; }
+ public required string Email { get; set; }
+ public required FacialFeatures FacialFeatures { get; set; }
+ public required IList NameAndAddress { get; set; }
}
diff --git a/exercises/concept/developer-privileges/DeveloperPrivileges.csproj b/exercises/concept/developer-privileges/DeveloperPrivileges.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/developer-privileges/DeveloperPrivileges.csproj
+++ b/exercises/concept/developer-privileges/DeveloperPrivileges.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/elons-toys/ElonsToys.csproj b/exercises/concept/elons-toys/ElonsToys.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/elons-toys/ElonsToys.csproj
+++ b/exercises/concept/elons-toys/ElonsToys.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/faceid-2/.meta/Exemplar.cs b/exercises/concept/faceid-2/.meta/Exemplar.cs
index 20c143543..e21b101d2 100644
--- a/exercises/concept/faceid-2/.meta/Exemplar.cs
+++ b/exercises/concept/faceid-2/.meta/Exemplar.cs
@@ -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;
@@ -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;
diff --git a/exercises/concept/faceid-2/Faceid2.csproj b/exercises/concept/faceid-2/Faceid2.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/faceid-2/Faceid2.csproj
+++ b/exercises/concept/faceid-2/Faceid2.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/high-school-sweethearts/HighSchoolSweethearts.csproj b/exercises/concept/high-school-sweethearts/HighSchoolSweethearts.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/high-school-sweethearts/HighSchoolSweethearts.csproj
+++ b/exercises/concept/high-school-sweethearts/HighSchoolSweethearts.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/hyper-optimized-telemetry/HyperOptimizedTelemetry.csproj b/exercises/concept/hyper-optimized-telemetry/HyperOptimizedTelemetry.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/hyper-optimized-telemetry/HyperOptimizedTelemetry.csproj
+++ b/exercises/concept/hyper-optimized-telemetry/HyperOptimizedTelemetry.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/hyperia-forex/HyperiaForex.csproj b/exercises/concept/hyperia-forex/HyperiaForex.csproj
index 0c1593de1..508bd277f 100644
--- a/exercises/concept/hyperia-forex/HyperiaForex.csproj
+++ b/exercises/concept/hyperia-forex/HyperiaForex.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/hyperinflation-hits-hyperia/HyperinflationHitsHyperia.csproj b/exercises/concept/hyperinflation-hits-hyperia/HyperinflationHitsHyperia.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/hyperinflation-hits-hyperia/HyperinflationHitsHyperia.csproj
+++ b/exercises/concept/hyperinflation-hits-hyperia/HyperinflationHitsHyperia.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/instruments-of-texas/.meta/Exemplar.cs b/exercises/concept/instruments-of-texas/.meta/Exemplar.cs
index 9d8a76d1e..a9c1d11df 100644
--- a/exercises/concept/instruments-of-texas/.meta/Exemplar.cs
+++ b/exercises/concept/instruments-of-texas/.meta/Exemplar.cs
@@ -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;
}
}
diff --git a/exercises/concept/instruments-of-texas/InstrumentsOfTexas.csproj b/exercises/concept/instruments-of-texas/InstrumentsOfTexas.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/instruments-of-texas/InstrumentsOfTexas.csproj
+++ b/exercises/concept/instruments-of-texas/InstrumentsOfTexas.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/interest-is-interesting/InterestIsInteresting.csproj b/exercises/concept/interest-is-interesting/InterestIsInteresting.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/interest-is-interesting/InterestIsInteresting.csproj
+++ b/exercises/concept/interest-is-interesting/InterestIsInteresting.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/international-calling-connoisseur/InternationalCallingConnoisseur.csproj b/exercises/concept/international-calling-connoisseur/InternationalCallingConnoisseur.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/international-calling-connoisseur/InternationalCallingConnoisseur.csproj
+++ b/exercises/concept/international-calling-connoisseur/InternationalCallingConnoisseur.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/land-grab-in-space/LandGrabInSpace.csproj b/exercises/concept/land-grab-in-space/LandGrabInSpace.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/land-grab-in-space/LandGrabInSpace.csproj
+++ b/exercises/concept/land-grab-in-space/LandGrabInSpace.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs b/exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs
index 9f64a20c6..f52580ffc 100644
--- a/exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs
+++ b/exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs
@@ -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.");
}
}
diff --git a/exercises/concept/log-analysis/LogAnalysis.csproj b/exercises/concept/log-analysis/LogAnalysis.csproj
index 34a056ea9..54d543da1 100644
--- a/exercises/concept/log-analysis/LogAnalysis.csproj
+++ b/exercises/concept/log-analysis/LogAnalysis.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/log-levels/LogLevels.csproj b/exercises/concept/log-levels/LogLevels.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/log-levels/LogLevels.csproj
+++ b/exercises/concept/log-levels/LogLevels.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/logs-logs-logs/LogsLogsLogs.csproj b/exercises/concept/logs-logs-logs/LogsLogsLogs.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/logs-logs-logs/LogsLogsLogs.csproj
+++ b/exercises/concept/logs-logs-logs/LogsLogsLogs.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/lucians-luscious-lasagna/LuciansLusciousLasagna.csproj b/exercises/concept/lucians-luscious-lasagna/LuciansLusciousLasagna.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/lucians-luscious-lasagna/LuciansLusciousLasagna.csproj
+++ b/exercises/concept/lucians-luscious-lasagna/LuciansLusciousLasagna.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/need-for-speed/NeedForSpeed.csproj b/exercises/concept/need-for-speed/NeedForSpeed.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/need-for-speed/NeedForSpeed.csproj
+++ b/exercises/concept/need-for-speed/NeedForSpeed.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/object-relational-mapping/ObjectRelationalMapping.csproj b/exercises/concept/object-relational-mapping/ObjectRelationalMapping.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/object-relational-mapping/ObjectRelationalMapping.csproj
+++ b/exercises/concept/object-relational-mapping/ObjectRelationalMapping.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/orm-in-one-go/OrmInOneGo.csproj b/exercises/concept/orm-in-one-go/OrmInOneGo.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/orm-in-one-go/OrmInOneGo.csproj
+++ b/exercises/concept/orm-in-one-go/OrmInOneGo.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/parsing-log-files/ParsingLogFiles.csproj b/exercises/concept/parsing-log-files/ParsingLogFiles.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/parsing-log-files/ParsingLogFiles.csproj
+++ b/exercises/concept/parsing-log-files/ParsingLogFiles.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/phone-number-analysis/PhoneNumberAnalysis.csproj b/exercises/concept/phone-number-analysis/PhoneNumberAnalysis.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/phone-number-analysis/PhoneNumberAnalysis.csproj
+++ b/exercises/concept/phone-number-analysis/PhoneNumberAnalysis.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/red-vs-blue-darwin-style/RedVsBlueDarwinStyle.csproj b/exercises/concept/red-vs-blue-darwin-style/RedVsBlueDarwinStyle.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/red-vs-blue-darwin-style/RedVsBlueDarwinStyle.csproj
+++ b/exercises/concept/red-vs-blue-darwin-style/RedVsBlueDarwinStyle.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/remote-control-cleanup/.meta/Exemplar.cs b/exercises/concept/remote-control-cleanup/.meta/Exemplar.cs
index 0fd5986a8..d9023f560 100644
--- a/exercises/concept/remote-control-cleanup/.meta/Exemplar.cs
+++ b/exercises/concept/remote-control-cleanup/.meta/Exemplar.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CS8618
+
public class RemoteControlCar
{
private enum SpeedUnits
@@ -95,3 +97,5 @@ private void SetSpeed(Speed speed)
currentSpeed = speed;
}
}
+
+#pragma warning restore CS8618
diff --git a/exercises/concept/remote-control-cleanup/RemoteControlCleanup.csproj b/exercises/concept/remote-control-cleanup/RemoteControlCleanup.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/remote-control-cleanup/RemoteControlCleanup.csproj
+++ b/exercises/concept/remote-control-cleanup/RemoteControlCleanup.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/remote-control-competition/.meta/Exemplar.cs b/exercises/concept/remote-control-competition/.meta/Exemplar.cs
index 8ce1b2ef6..70e892824 100644
--- a/exercises/concept/remote-control-competition/.meta/Exemplar.cs
+++ b/exercises/concept/remote-control-competition/.meta/Exemplar.cs
@@ -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;
diff --git a/exercises/concept/remote-control-competition/RemoteControlCompetition.cs b/exercises/concept/remote-control-competition/RemoteControlCompetition.cs
index 560245751..70e892824 100644
--- a/exercises/concept/remote-control-competition/RemoteControlCompetition.cs
+++ b/exercises/concept/remote-control-competition/RemoteControlCompetition.cs
@@ -1,9 +1,13 @@
using System;
using System.Collections.Generic;
-// TODO implement the IRemoteControlCar interface
+public interface IRemoteControlCar
+{
+ void Drive();
+ int DistanceTravelled { get; }
+}
-public class ProductionRemoteControlCar
+public class ProductionRemoteControlCar : IRemoteControlCar, IComparable
{
public int DistanceTravelled { get; private set; }
public int NumberOfVictories { get; set; }
@@ -12,9 +16,16 @@ public void Drive()
{
DistanceTravelled += 10;
}
+
+ public int CompareTo(ProductionRemoteControlCar? other)
+ {
+ if (ReferenceEquals(this, other)) return 0;
+ if (ReferenceEquals(null, other)) return 1;
+ return NumberOfVictories.CompareTo(other.NumberOfVictories);
+ }
}
-public class ExperimentalRemoteControlCar
+public class ExperimentalRemoteControlCar : IRemoteControlCar
{
public int DistanceTravelled { get; private set; }
@@ -28,12 +39,14 @@ public static class TestTrack
{
public static void Race(IRemoteControlCar car)
{
- throw new NotImplementedException($"Please implement the (static) TestTrack.Race() method");
+ car.Drive();
}
public static List GetRankedCars(ProductionRemoteControlCar prc1,
ProductionRemoteControlCar prc2)
{
- throw new NotImplementedException($"Please implement the (static) TestTrack.GetRankedCars() method");
+ var rankings = new List { prc1, prc2 };
+ rankings.Sort();
+ return rankings;
}
}
diff --git a/exercises/concept/remote-control-competition/RemoteControlCompetition.csproj b/exercises/concept/remote-control-competition/RemoteControlCompetition.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/remote-control-competition/RemoteControlCompetition.csproj
+++ b/exercises/concept/remote-control-competition/RemoteControlCompetition.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/roll-the-die/RollTheDie.csproj b/exercises/concept/roll-the-die/RollTheDie.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/roll-the-die/RollTheDie.csproj
+++ b/exercises/concept/roll-the-die/RollTheDie.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/secure-munchester-united/SecureMunchesterUnited.csproj b/exercises/concept/secure-munchester-united/SecureMunchesterUnited.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/secure-munchester-united/SecureMunchesterUnited.csproj
+++ b/exercises/concept/secure-munchester-united/SecureMunchesterUnited.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/squeaky-clean/SqueakyClean.csproj b/exercises/concept/squeaky-clean/SqueakyClean.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/squeaky-clean/SqueakyClean.csproj
+++ b/exercises/concept/squeaky-clean/SqueakyClean.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/the-weather-in-deather/TheWeatherInDeather.csproj b/exercises/concept/the-weather-in-deather/TheWeatherInDeather.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/the-weather-in-deather/TheWeatherInDeather.csproj
+++ b/exercises/concept/the-weather-in-deather/TheWeatherInDeather.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/tracks-on-tracks-on-tracks/TracksOnTracksOnTracks.csproj b/exercises/concept/tracks-on-tracks-on-tracks/TracksOnTracksOnTracks.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/tracks-on-tracks-on-tracks/TracksOnTracksOnTracks.csproj
+++ b/exercises/concept/tracks-on-tracks-on-tracks/TracksOnTracksOnTracks.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/weighing-machine/WeighingMachine.csproj b/exercises/concept/weighing-machine/WeighingMachine.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/concept/weighing-machine/WeighingMachine.csproj
+++ b/exercises/concept/weighing-machine/WeighingMachine.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/wizards-and-warriors-2/.meta/Exemplar.cs b/exercises/concept/wizards-and-warriors-2/.meta/Exemplar.cs
index f34eab43b..eba0f8cde 100644
--- a/exercises/concept/wizards-and-warriors-2/.meta/Exemplar.cs
+++ b/exercises/concept/wizards-and-warriors-2/.meta/Exemplar.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CS8618
+
static class GameMaster
{
public static string Describe(Character character)
@@ -44,3 +46,5 @@ enum TravelMethod
Walking,
Horseback
}
+
+#pragma warning restore CS8618
diff --git a/exercises/concept/wizards-and-warriors-2/WizardsAndWarriors2.csproj b/exercises/concept/wizards-and-warriors-2/WizardsAndWarriors2.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/wizards-and-warriors-2/WizardsAndWarriors2.csproj
+++ b/exercises/concept/wizards-and-warriors-2/WizardsAndWarriors2.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/concept/wizards-and-warriors/WizardsAndWarriors.csproj b/exercises/concept/wizards-and-warriors/WizardsAndWarriors.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/concept/wizards-and-warriors/WizardsAndWarriors.csproj
+++ b/exercises/concept/wizards-and-warriors/WizardsAndWarriors.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/accumulate/Accumulate.csproj b/exercises/practice/accumulate/Accumulate.csproj
index 48c7eb965..73826fe6c 100644
--- a/exercises/practice/accumulate/Accumulate.csproj
+++ b/exercises/practice/accumulate/Accumulate.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/acronym/Acronym.csproj b/exercises/practice/acronym/Acronym.csproj
index b4fd39c09..b0f97fdf7 100644
--- a/exercises/practice/acronym/Acronym.csproj
+++ b/exercises/practice/acronym/Acronym.csproj
@@ -3,6 +3,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/affine-cipher/AffineCipher.csproj b/exercises/practice/affine-cipher/AffineCipher.csproj
index e1a3b4466..1b40aeb20 100644
--- a/exercises/practice/affine-cipher/AffineCipher.csproj
+++ b/exercises/practice/affine-cipher/AffineCipher.csproj
@@ -3,6 +3,7 @@
Exe
net9.0
+ enable
true
diff --git a/exercises/practice/all-your-base/AllYourBase.csproj b/exercises/practice/all-your-base/AllYourBase.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/all-your-base/AllYourBase.csproj
+++ b/exercises/practice/all-your-base/AllYourBase.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/allergies/Allergies.csproj b/exercises/practice/allergies/Allergies.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/allergies/Allergies.csproj
+++ b/exercises/practice/allergies/Allergies.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/alphametics/.meta/Example.cs b/exercises/practice/alphametics/.meta/Example.cs
index 7af1e1ae6..81c3622b2 100644
--- a/exercises/practice/alphametics/.meta/Example.cs
+++ b/exercises/practice/alphametics/.meta/Example.cs
@@ -57,7 +57,7 @@ private void ProcessOperand(string operand, long multiplyCountBy)
public static class AlphameticsSolver
{
- private static AlphameticsEquation _equation;
+ private static AlphameticsEquation? _equation;
public static IDictionary Solve(AlphameticsEquation equation)
{
@@ -77,19 +77,19 @@ private static bool IsSolution(int[] letterCountCombination)
if (LetterCountHasInvalidNonZeroLetter())
return false;
- return _equation.LettersWithCount.Values
+ return _equation!.LettersWithCount.Values
.Zip(letterCountCombination, (count, solutionCount) => count * solutionCount).Sum() == 0;
bool LetterCountHasInvalidNonZeroLetter()
{
var zeroLetterIndex = Array.IndexOf(letterCountCombination, 0);
- return zeroLetterIndex != -1 && _equation.NonZeroLetters.Contains(_equation.LettersWithCount.Keys.ElementAt(zeroLetterIndex));
+ return zeroLetterIndex != -1 && _equation!.NonZeroLetters.Contains(_equation.LettersWithCount.Keys.ElementAt(zeroLetterIndex));
}
}
private static Dictionary SolutionForLetterCount(IEnumerable letterCount)
=> letterCount
- .Zip(_equation.LettersWithCount.Keys, (x, y) => new KeyValuePair(y, x))
+ .Zip(_equation!.LettersWithCount.Keys, (x, y) => new KeyValuePair(y, x))
.ToDictionary(x => x.Key, x => x.Value);
}
diff --git a/exercises/practice/alphametics/Alphametics.csproj b/exercises/practice/alphametics/Alphametics.csproj
index 2374c328a..5544c7f0f 100644
--- a/exercises/practice/alphametics/Alphametics.csproj
+++ b/exercises/practice/alphametics/Alphametics.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/anagram/Anagram.csproj b/exercises/practice/anagram/Anagram.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/anagram/Anagram.csproj
+++ b/exercises/practice/anagram/Anagram.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/armstrong-numbers/ArmstrongNumbers.csproj b/exercises/practice/armstrong-numbers/ArmstrongNumbers.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/armstrong-numbers/ArmstrongNumbers.csproj
+++ b/exercises/practice/armstrong-numbers/ArmstrongNumbers.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/atbash-cipher/AtbashCipher.csproj b/exercises/practice/atbash-cipher/AtbashCipher.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/atbash-cipher/AtbashCipher.csproj
+++ b/exercises/practice/atbash-cipher/AtbashCipher.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/bank-account/BankAccount.csproj b/exercises/practice/bank-account/BankAccount.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/bank-account/BankAccount.csproj
+++ b/exercises/practice/bank-account/BankAccount.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/beer-song/BeerSong.csproj b/exercises/practice/beer-song/BeerSong.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/beer-song/BeerSong.csproj
+++ b/exercises/practice/beer-song/BeerSong.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/binary-search-tree/.meta/Example.cs b/exercises/practice/binary-search-tree/.meta/Example.cs
index a77fc35bf..34155833f 100644
--- a/exercises/practice/binary-search-tree/.meta/Example.cs
+++ b/exercises/practice/binary-search-tree/.meta/Example.cs
@@ -29,9 +29,9 @@ public BinarySearchTree(IEnumerable values)
public int Value { get; }
- public BinarySearchTree Left { get; private set; }
+ public BinarySearchTree? Left { get; private set; }
- public BinarySearchTree Right { get; private set; }
+ public BinarySearchTree? Right { get; private set; }
public BinarySearchTree Add(int value)
{
@@ -47,7 +47,7 @@ public BinarySearchTree Add(int value)
return this;
}
- private static BinarySearchTree Add(int value, BinarySearchTree tree)
+ private static BinarySearchTree Add(int value, BinarySearchTree? tree)
{
if (tree == null)
{
diff --git a/exercises/practice/binary-search-tree/.meta/Generator.tpl b/exercises/practice/binary-search-tree/.meta/Generator.tpl
index d7ad8d896..90f7c5599 100644
--- a/exercises/practice/binary-search-tree/.meta/Generator.tpl
+++ b/exercises/practice/binary-search-tree/.meta/Generator.tpl
@@ -2,11 +2,11 @@
checks = [$"Assert.Equal({string.to_int node.data}, tree.{path}Value);"]
if node.left
- checks = array.add_range checks (assertions node.left (path + "Left."))
+ checks = array.add_range checks (assertions node.left (path + "Left?."))
end
if node.right
- checks = array.add_range checks (assertions node.right (path + "Right."))
+ checks = array.add_range checks (assertions node.right (path + "Right?."))
end
ret checks
diff --git a/exercises/practice/binary-search-tree/BinarySearchTree.cs b/exercises/practice/binary-search-tree/BinarySearchTree.cs
index f1a20129b..71f354de0 100644
--- a/exercises/practice/binary-search-tree/BinarySearchTree.cs
+++ b/exercises/practice/binary-search-tree/BinarySearchTree.cs
@@ -20,7 +20,7 @@ public int Value
}
}
- public BinarySearchTree Left
+ public BinarySearchTree? Left
{
get
{
@@ -28,7 +28,7 @@ public BinarySearchTree Left
}
}
- public BinarySearchTree Right
+ public BinarySearchTree? Right
{
get
{
diff --git a/exercises/practice/binary-search-tree/BinarySearchTree.csproj b/exercises/practice/binary-search-tree/BinarySearchTree.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/binary-search-tree/BinarySearchTree.csproj
+++ b/exercises/practice/binary-search-tree/BinarySearchTree.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/binary-search-tree/BinarySearchTreeTests.cs b/exercises/practice/binary-search-tree/BinarySearchTreeTests.cs
index 18698389f..1eae96771 100644
--- a/exercises/practice/binary-search-tree/BinarySearchTreeTests.cs
+++ b/exercises/practice/binary-search-tree/BinarySearchTreeTests.cs
@@ -15,7 +15,7 @@ public void Insert_data_at_proper_node_smaller_number_at_left_node()
{
var tree = new BinarySearchTree(new[] { 4, 2 });
Assert.Equal(4, tree.Value);
- Assert.Equal(2, tree.Left.Value);
+ Assert.Equal(2, tree.Left?.Value);
}
[Fact(Skip = "Remove this Skip property to run this test")]
@@ -23,7 +23,7 @@ public void Insert_data_at_proper_node_same_number_at_left_node()
{
var tree = new BinarySearchTree(new[] { 4, 4 });
Assert.Equal(4, tree.Value);
- Assert.Equal(4, tree.Left.Value);
+ Assert.Equal(4, tree.Left?.Value);
}
[Fact(Skip = "Remove this Skip property to run this test")]
@@ -31,7 +31,7 @@ public void Insert_data_at_proper_node_greater_number_at_right_node()
{
var tree = new BinarySearchTree(new[] { 4, 5 });
Assert.Equal(4, tree.Value);
- Assert.Equal(5, tree.Right.Value);
+ Assert.Equal(5, tree.Right?.Value);
}
[Fact(Skip = "Remove this Skip property to run this test")]
@@ -39,12 +39,12 @@ public void Can_create_complex_tree()
{
var tree = new BinarySearchTree(new[] { 4, 2, 6, 1, 3, 5, 7 });
Assert.Equal(4, tree.Value);
- Assert.Equal(2, tree.Left.Value);
- Assert.Equal(1, tree.Left.Left.Value);
- Assert.Equal(3, tree.Left.Right.Value);
- Assert.Equal(6, tree.Right.Value);
- Assert.Equal(5, tree.Right.Left.Value);
- Assert.Equal(7, tree.Right.Right.Value);
+ Assert.Equal(2, tree.Left?.Value);
+ Assert.Equal(1, tree.Left?.Left?.Value);
+ Assert.Equal(3, tree.Left?.Right?.Value);
+ Assert.Equal(6, tree.Right?.Value);
+ Assert.Equal(5, tree.Right?.Left?.Value);
+ Assert.Equal(7, tree.Right?.Right?.Value);
}
[Fact(Skip = "Remove this Skip property to run this test")]
diff --git a/exercises/practice/binary-search/BinarySearch.csproj b/exercises/practice/binary-search/BinarySearch.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/binary-search/BinarySearch.csproj
+++ b/exercises/practice/binary-search/BinarySearch.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/binary/Binary.csproj b/exercises/practice/binary/Binary.csproj
index 09fcf4d6e..5553da3b4 100644
--- a/exercises/practice/binary/Binary.csproj
+++ b/exercises/practice/binary/Binary.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/bob/Bob.csproj b/exercises/practice/bob/Bob.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/bob/Bob.csproj
+++ b/exercises/practice/bob/Bob.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/book-store/BookStore.csproj b/exercises/practice/book-store/BookStore.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/book-store/BookStore.csproj
+++ b/exercises/practice/book-store/BookStore.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/bowling/Bowling.csproj b/exercises/practice/bowling/Bowling.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/bowling/Bowling.csproj
+++ b/exercises/practice/bowling/Bowling.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/change/.meta/Example.cs b/exercises/practice/change/.meta/Example.cs
index 775648083..566521e12 100644
--- a/exercises/practice/change/.meta/Example.cs
+++ b/exercises/practice/change/.meta/Example.cs
@@ -37,7 +37,7 @@ Dictionary> UpdateMinimalCoinsMap(Dictionary> curr
return current;
}
- List MinimalCoins(Dictionary> current, int subTarget)
+ List? MinimalCoins(Dictionary> current, int subTarget)
{
return coins
.Where(coin => coin <= subTarget)
@@ -45,7 +45,7 @@ List MinimalCoins(Dictionary> current, int subTarget)
? subTargetMinimalCoins.Append(coin).ToList()
: null)
.Where(subTargetMinimalCoins => subTargetMinimalCoins != null)
- .OrderBy(subTargetMinimalCoins => subTargetMinimalCoins.Count)
+ .OrderBy(subTargetMinimalCoins => subTargetMinimalCoins!.Count)
.FirstOrDefault();
}
}
diff --git a/exercises/practice/change/Change.csproj b/exercises/practice/change/Change.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/change/Change.csproj
+++ b/exercises/practice/change/Change.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/circular-buffer/CircularBuffer.csproj b/exercises/practice/circular-buffer/CircularBuffer.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/circular-buffer/CircularBuffer.csproj
+++ b/exercises/practice/circular-buffer/CircularBuffer.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/clock/Clock.csproj b/exercises/practice/clock/Clock.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/clock/Clock.csproj
+++ b/exercises/practice/clock/Clock.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/collatz-conjecture/CollatzConjecture.csproj b/exercises/practice/collatz-conjecture/CollatzConjecture.csproj
index 53f95ed2a..7625d0c3c 100644
--- a/exercises/practice/collatz-conjecture/CollatzConjecture.csproj
+++ b/exercises/practice/collatz-conjecture/CollatzConjecture.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/complex-numbers/ComplexNumbers.csproj b/exercises/practice/complex-numbers/ComplexNumbers.csproj
index a5b5aa41c..02b41704e 100644
--- a/exercises/practice/complex-numbers/ComplexNumbers.csproj
+++ b/exercises/practice/complex-numbers/ComplexNumbers.csproj
@@ -3,6 +3,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/connect/Connect.csproj b/exercises/practice/connect/Connect.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/connect/Connect.csproj
+++ b/exercises/practice/connect/Connect.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/crypto-square/CryptoSquare.csproj b/exercises/practice/crypto-square/CryptoSquare.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/crypto-square/CryptoSquare.csproj
+++ b/exercises/practice/crypto-square/CryptoSquare.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/custom-set/.meta/Example.cs b/exercises/practice/custom-set/.meta/Example.cs
index f4f9ae718..f6273f67b 100644
--- a/exercises/practice/custom-set/.meta/Example.cs
+++ b/exercises/practice/custom-set/.meta/Example.cs
@@ -45,7 +45,7 @@ public CustomSet Union(CustomSet right)
private int[] GetValuesFromKeys(IEnumerable keys) => keys.Select(key => items[key]).ToArray();
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (!(obj is CustomSet other))
{
diff --git a/exercises/practice/custom-set/CustomSet.csproj b/exercises/practice/custom-set/CustomSet.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/custom-set/CustomSet.csproj
+++ b/exercises/practice/custom-set/CustomSet.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/darts/Darts.csproj b/exercises/practice/darts/Darts.csproj
index be8126449..8b75d52b0 100644
--- a/exercises/practice/darts/Darts.csproj
+++ b/exercises/practice/darts/Darts.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/diamond/Diamond.csproj b/exercises/practice/diamond/Diamond.csproj
index 2bac419d2..425016c2d 100644
--- a/exercises/practice/diamond/Diamond.csproj
+++ b/exercises/practice/diamond/Diamond.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/difference-of-squares/DifferenceOfSquares.csproj b/exercises/practice/difference-of-squares/DifferenceOfSquares.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/difference-of-squares/DifferenceOfSquares.csproj
+++ b/exercises/practice/difference-of-squares/DifferenceOfSquares.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/diffie-hellman/DiffieHellman.csproj b/exercises/practice/diffie-hellman/DiffieHellman.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/diffie-hellman/DiffieHellman.csproj
+++ b/exercises/practice/diffie-hellman/DiffieHellman.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/dnd-character/DndCharacter.csproj b/exercises/practice/dnd-character/DndCharacter.csproj
index be8126449..8b75d52b0 100644
--- a/exercises/practice/dnd-character/DndCharacter.csproj
+++ b/exercises/practice/dnd-character/DndCharacter.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/dominoes/Dominoes.csproj b/exercises/practice/dominoes/Dominoes.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/dominoes/Dominoes.csproj
+++ b/exercises/practice/dominoes/Dominoes.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/dot-dsl/.meta/Example.cs b/exercises/practice/dot-dsl/.meta/Example.cs
index 80723f973..907f4b4f3 100644
--- a/exercises/practice/dot-dsl/.meta/Example.cs
+++ b/exercises/practice/dot-dsl/.meta/Example.cs
@@ -10,7 +10,7 @@ public Node(string name)
public string Name { get; }
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj == null || GetType() != obj.GetType())
return false;
@@ -32,7 +32,7 @@ public Edge(string node1, string node2)
public string Node1 { get; }
public string Node2 { get; }
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj == null || GetType() != obj.GetType())
return false;
@@ -55,7 +55,7 @@ public Attr(string key, string value)
public string Key { get; }
public string Value { get; }
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj == null || GetType() != obj.GetType())
return false;
diff --git a/exercises/practice/dot-dsl/DotDsl.csproj b/exercises/practice/dot-dsl/DotDsl.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/dot-dsl/DotDsl.csproj
+++ b/exercises/practice/dot-dsl/DotDsl.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/dot-dsl/DotDslTests.cs b/exercises/practice/dot-dsl/DotDslTests.cs
index 40adfcd09..225e25324 100644
--- a/exercises/practice/dot-dsl/DotDslTests.cs
+++ b/exercises/practice/dot-dsl/DotDslTests.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
@@ -23,7 +22,7 @@ public void Graph_with_one_node()
new Node("a")
};
- Assert.Equal(new[] { new Node("a") }, g.Nodes);
+ Assert.Equal([new Node("a")], g.Nodes);
Assert.Empty(g.Edges);
Assert.Empty(g.Attrs);
}
@@ -36,7 +35,7 @@ public void Graph_with_one_node_with_keywords()
new Node("a") { { "color", "green" } }
};
- Assert.Equal(new[] { new Node("a") { { "color", "green" } } }, g.Nodes);
+ Assert.Equal([new Node("a") { { "color", "green" } }], g.Nodes);
Assert.Empty(g.Edges);
Assert.Empty(g.Attrs);
}
@@ -50,7 +49,7 @@ public void Graph_with_one_edge()
};
Assert.Empty(g.Nodes);
- Assert.Equal(new[] { new Edge("a", "b") }, g.Edges);
+ Assert.Equal([new Edge("a", "b")], g.Edges);
Assert.Empty(g.Attrs);
}
@@ -64,7 +63,7 @@ public void Graph_with_one_attribute()
Assert.Empty(g.Nodes);
Assert.Empty(g.Edges);
- Assert.Equal(new[] { new Attr("foo", "1") }, g.Attrs);
+ Assert.Equal([new Attr("foo", "1")], g.Attrs);
}
[Fact(Skip = "Remove this Skip property to run this test")]
@@ -82,20 +81,11 @@ public void Graph_with_attributes()
{ "bar", "true" }
};
- Assert.Equal(new[] { new Node("a") { { "color", "green" } }, new Node("b") { { "label", "Beta!" } }, new Node("c") }, g.Nodes, EnumerableEqualityComparer.Instance);
- Assert.Equal(new[] { new Edge("a", "b") { { "color", "blue" } }, new Edge("b", "c") }, g.Edges, EnumerableEqualityComparer.Instance);
- Assert.Equal(new[] { new Attr("bar", "true"), new Attr("foo", "1"), new Attr("title", "Testing Attrs") }, g.Attrs, EnumerableEqualityComparer.Instance);
- }
-
- private class EnumerableEqualityComparer : IEqualityComparer>
- {
- public static readonly EnumerableEqualityComparer Instance = new EnumerableEqualityComparer();
-
- public bool Equals(IEnumerable x, IEnumerable y) => new HashSet(x).SetEquals(y);
-
- public int GetHashCode(IEnumerable obj)
- {
- throw new NotImplementedException("You need to implement this method.");
- }
+ HashSet expectedNodes = [new Node("a") { { "color", "green" } }, new Node("b") { { "label", "Beta!" } }, new Node("c")];
+ Assert.Equal(expectedNodes, g.Nodes.ToHashSet());
+ HashSet expectedEdges = [new Edge("a", "b") { { "color", "blue" } }, new Edge("b", "c")];
+ Assert.Equal(expectedEdges, g.Edges.ToHashSet());
+ HashSet expectedAttrs = [new Attr("bar", "true"), new Attr("foo", "1"), new Attr("title", "Testing Attrs")];
+ Assert.Equal(expectedAttrs, g.Attrs.ToHashSet());
}
}
\ No newline at end of file
diff --git a/exercises/practice/eliuds-eggs/EliudsEggs.csproj b/exercises/practice/eliuds-eggs/EliudsEggs.csproj
index c97331f70..ce2468564 100644
--- a/exercises/practice/eliuds-eggs/EliudsEggs.csproj
+++ b/exercises/practice/eliuds-eggs/EliudsEggs.csproj
@@ -7,6 +7,7 @@
false
true
+ enable
true
diff --git a/exercises/practice/error-handling/ErrorHandling.csproj b/exercises/practice/error-handling/ErrorHandling.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/error-handling/ErrorHandling.csproj
+++ b/exercises/practice/error-handling/ErrorHandling.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/etl/Etl.csproj b/exercises/practice/etl/Etl.csproj
index 06c91ac7a..590e2b629 100644
--- a/exercises/practice/etl/Etl.csproj
+++ b/exercises/practice/etl/Etl.csproj
@@ -2,6 +2,7 @@
net9.0
+ enable
true
diff --git a/exercises/practice/flatten-array/.meta/Generator.tpl b/exercises/practice/flatten-array/.meta/Generator.tpl
index 02583b06b..e30030318 100644
--- a/exercises/practice/flatten-array/.meta/Generator.tpl
+++ b/exercises/practice/flatten-array/.meta/Generator.tpl
@@ -2,10 +2,10 @@
case (object.typeof input)
when "array"
if input.empty?
- ret "Array.Empty