Use generic Marshal.GetDelegateForFunctionPointer for explicitly cast closed source delegates
ProprietaryReplace explicitly cast, resolved GetDelegateForFunctionPointer(pointer, typeof(T)) calls with the generic overload for the same closed source delegate on known .NET Framework 4.5.1+, .NET Standard 1.2+ or .NET Core 1.0+ targets. Preserve the cast, pointer evaluation, ownership and method binding. Admit primitive, pointer-sized and raw-pointer signatures with known marshalling annotations; skip generic or unsupported signatures, ambiguous projects, old language syntax, comments and conditional snapshots.
OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net5. UseGenericMarshalGetDelegateForSourceDelegatesmod run . --recipe= OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net5. UseGenericMarshalGetDelegateForSourceDelegatesInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.