Use AsyncLocal for closed reference logical-context slots
ProprietaryOpt-in in-process port of a static reference property backed only by a private constant CallContext slot, with an as-cast getter and a direct value setter. Store the object reference in a private AsyncLocal<object> initialized first, retaining the original as-cast and value symbols. Require one key literal, its declaration/two bound references and no other context operations/type references. Exclude partial/generic/proxy owners, key escapes, special slots, unsupported imports/comments and conditional files. External named-slot/remoting/trust contracts require separate review. Not composed into version upgrades.
OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net3_0. UseAsyncLocalForClosedReferenceContextSlotsmod run . --recipe= OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net3_0. UseAsyncLocalForClosedReferenceContextSlotsInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.