Stop generated code from using deprecated

The code for D2 would operating on deprecated fields resulting in a deprecation even if the user didn't make use of the code. This addresses the issue.