You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the only way to create an instruction is via Create methods on ILProcessor. Obviously, this requires creating an instance of ILProcessor and passing it around. As this instance is not actually used by the Create methods, it seems rather pointless to create it and pass it around. Put differently: the Create methods can and should be static, in which case they belong on the Instruction class.
In the example above, the method currently needs and additional parameter, either an ILProcessor or a MethodBody.
In the case of passing an ILProcessor, there's no way that the method can check that the instructions parameter corresponds to the instructions collection hidden inside the ILProcessor (and hidden it is).
In the case of passing the MethodBody, the instructions collection does not need to be passed separately, but an ILProcessor must be created to be able to create an instruction.
Furthermore, creating instructions is the only thing that an ILProcessor is required for. Every other operation offered by ILProcessor is easy to do directly on an instructions collection.
I therefor propose the following:
static Create methods are added to the Instruction class
Create methods on ILProcessor delegate to Create methods on instruction class
Create methods on ILProcessor are marked obsolete
The text was updated successfully, but these errors were encountered:
It should be possible to write the following method:
Currently, the only way to create an instruction is via Create methods on ILProcessor. Obviously, this requires creating an instance of ILProcessor and passing it around. As this instance is not actually used by the Create methods, it seems rather pointless to create it and pass it around. Put differently: the Create methods can and should be static, in which case they belong on the Instruction class.
In the example above, the method currently needs and additional parameter, either an ILProcessor or a MethodBody.
In the case of passing an ILProcessor, there's no way that the method can check that the instructions parameter corresponds to the instructions collection hidden inside the ILProcessor (and hidden it is).
In the case of passing the MethodBody, the instructions collection does not need to be passed separately, but an ILProcessor must be created to be able to create an instruction.
Furthermore, creating instructions is the only thing that an ILProcessor is required for. Every other operation offered by ILProcessor is easy to do directly on an instructions collection.
I therefor propose the following:
The text was updated successfully, but these errors were encountered: