diff --git a/bin/update-exercises.ps1 b/bin/update-exercises.ps1 index 78009459d..ea977064c 100644 --- a/bin/update-exercises.ps1 +++ b/bin/update-exercises.ps1 @@ -24,9 +24,9 @@ $PSNativeCommandUseErrorActionPreference = $true & bin/fetch-configlet if ($Exercise) { - & configlet sync --docs --metadata --filepaths --update --yes --exercise $Exercise + & bin/configlet sync --docs --metadata --filepaths --update --yes --exercise $Exercise & dotnet run --project generators update --exercise $Exercise } else { - & configlet sync --docs --metadata --filepaths --update --yes + & bin/configlet sync --docs --metadata --filepaths --update --yes & dotnet run --project generators update } diff --git a/exercises/practice/bank-account/.meta/Generator.tpl b/exercises/practice/bank-account/.meta/Generator.tpl index 95cb3d697..299beab7b 100644 --- a/exercises/practice/bank-account/.meta/Generator.tpl +++ b/exercises/practice/bank-account/.meta/Generator.tpl @@ -33,9 +33,9 @@ public class {{ testClass }} Assert.Equal({{ test.expected }}m, account.{{ op | to_call }}); {{ end -}} {{- else if op.operation == "concurrent" }} + var tasks = new List(); for (int i = 0; i < 500; i++) { - var tasks = new List(); tasks.Add(Task.Factory.StartNew(() => { for (int j = 0; j < 100; j++) @@ -44,9 +44,9 @@ public class {{ testClass }} account.{{ nested_op | to_call }}; {{- end -}} } - })); - await Task.WhenAll(tasks.ToArray()); + }, TestContext.Current.CancellationToken)); } + await Task.WhenAll(tasks.ToArray()); {{- else }} account.{{ op | to_call }}; {{- end -}} diff --git a/exercises/practice/bank-account/BankAccountTests.cs b/exercises/practice/bank-account/BankAccountTests.cs index 50d6b66cc..88cb9b987 100644 --- a/exercises/practice/bank-account/BankAccountTests.cs +++ b/exercises/practice/bank-account/BankAccountTests.cs @@ -152,9 +152,9 @@ public async Task Can_handle_concurrent_transactions() { var account = new BankAccount(); account.Open(); + var tasks = new List(); for (int i = 0; i < 500; i++) { - var tasks = new List(); tasks.Add(Task.Factory.StartNew(() => { for (int j = 0; j < 100; j++) @@ -163,8 +163,8 @@ public async Task Can_handle_concurrent_transactions() account.Withdraw(1m); } }, TestContext.Current.CancellationToken)); - await Task.WhenAll(tasks.ToArray()); } + await Task.WhenAll(tasks.ToArray()); Assert.Equal(0m, account.Balance); } } diff --git a/generators/Generators.csproj b/generators/Generators.csproj index a7a792ecb..cfb9d3fa3 100644 --- a/generators/Generators.csproj +++ b/generators/Generators.csproj @@ -14,7 +14,7 @@ - + diff --git a/generators/Templates.cs b/generators/Templates.cs index 17753eaf0..81ea8a936 100644 --- a/generators/Templates.cs +++ b/generators/Templates.cs @@ -18,7 +18,7 @@ public static string RenderTestsCode(CanonicalData canonicalData) scriptObject.Import("enum", new Func((text, enumType) => $"{enumType.Pascalize()}.{text.Pascalize()}")); scriptObject.Import("property", new Func((testCases, name) => - new ScriptArray(testCases.Cast().Where(testCase => testCase["property"].ToString() == name)))); + new ScriptArray(testCases.Cast().Where(testCase => testCase["property"]?.ToString() == name)))); scriptObject.Import(TemplateData.ForCanonicalData(canonicalData)); var context = new TemplateContext(); diff --git a/generators/packages.lock.json b/generators/packages.lock.json index 5fc5350d3..97c4f02ba 100644 --- a/generators/packages.lock.json +++ b/generators/packages.lock.json @@ -39,9 +39,9 @@ }, "Scriban": { "type": "Direct", - "requested": "[6.5.5, )", - "resolved": "6.5.5", - "contentHash": "TxsmDVQ9agPQaY+SvdTO+zntGpJOnL1QaO4dzACfc6gEKRYhoMpzCCFuVixEZXet291sRnjyym6lB69Cr/EXPQ==" + "requested": "[7.0.6, )", + "resolved": "7.0.6", + "contentHash": "bOtHyk30sjl0y3+KYImIJv0ETZYLuFFJvlBF2ks2YLNtydhJqxRTGe4WaBDvg/3VRhhI6uf+qVfixuFROsOi+w==" }, "Tomlyn": { "type": "Direct", @@ -56,8 +56,8 @@ }, "Microsoft.CodeAnalysis.Analyzers": { "type": "Transitive", - "resolved": "5.3.0-2.final", - "contentHash": "VzdevMuvWpgH5s7bj+Y8CHaAPvJvzdRjBL/f2bzCEugZIOFOCZfblsbHwbCJ3hUFvvrbbcLcTrLt6HIj3bngAw==" + "resolved": "5.3.0-2.25625.1", + "contentHash": "4Yhh2fnu3G+J0J1lDc8WZVgMjgbynSeTfkl5IFJMFrmiIO0sc7Tjx+f3sFVV8Sd35PrIUWfof0RWc3lAMl7Azg==" }, "Microsoft.CodeAnalysis.Common": { "type": "Transitive",