← All recipes
Moderne licensed

Find List<T>.ForEach modification-during-enumeration change

Recipe IDOpenRewrite.Recipes.CSharp.Migration.Dotnet.NetFramework.FindListForEachDuringMutationArtifactOpenRewrite.Recipes.CSharp.Migration.Dotnet

Finds calls to List<T>.ForEach, which throws InvalidOperationException if the collection is modified during enumeration when retargeting to .NET Framework 4.5 (previously the modification was silently ignored).

Single recipesearchdotnetnet-frameworkcollectionsProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe OpenRewrite.Recipes.CSharp.Migration.Dotnet.NetFramework.FindListForEachDuringMutation

If the recipe isn’t available locally, install it with:

mod config recipes nuget install OpenRewrite.Recipes.CSharp.Migration.Dotnet