The warning needs to be generated from the origin where the field reference comes from - so if it's a method body, then from the method body. This is because the instantiation is determined by that place, not the field itself (the field is defined on an open generic definition of the type).
This syncs the relevants tests with a NativeAOT work-in-progress change, but in generately it adds a lot more cases and some better comments.
The warning needs to be generated from the origin where the field reference comes from - so if it's a method body, then from the method body. This is because the instantiation is determined by that place, not the field itself (the field is defined on an open generic definition of the type).
This syncs the relevants tests with a NativeAOT work-in-progress change, but in generately it adds a lot more cases and some better comments.