Currently, the generated code has the following method.
#if NETSTANDARD2_1_OR_GREATER
[DoesNotReturn]
#endif
private static TV ThrowInvalidCastException<TV>() => throw new InvalidCastException();
When targeting f.e. .NET7 the attribute is disabled. It'd be nice to have it enabled when NETCOREAPP3_0_OR_GREATER is set.