Preserve reviewed deserialized JsonDocument null guards
ProprietaryPreserve a legacy null branch when .NET 9 deserializes JSON null into a non-null JsonDocument. Admit only a typed JsonSerializer.Deserialize<JsonDocument> using declaration immediately followed by a null-only throwing if guard on that same local. Extend the condition to recognize JsonValueKind.Null; keep the original call, options, branches and using disposal. Requires explicit converter-policy review. Skip nonthrowing guards, guards observing the local, captures/async/ref scopes, other producers, ordinary locals, intervening statements, unresolved symbols and conditional snapshots. Standalone opt-in; do not apply to a project intentionally adopting the new null-document behavior.
OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net9. PreserveJsonDocumentNullGuardsOptional
Confirm these calls use the framework JsonDocument converter's legacy null behavior, including any supplied options, and that the existing null branch should retain its meaning. Custom converters, unknown converter policy and intentional new semantics are not admitted.
mod run . --recipe= OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net9. PreserveJsonDocumentNullGuardsInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.