Closed yaakov-h closed 2 years ago
I can reproduce it with the following:
public void Method(ILGenerator g, bool shortForm, Label label) => g.Emit(shortForm ? OpCodes.Brtrue_S : OpCodes.Brtrue, label);
Seems were missing a null check here, for fieldIdentifier
:
https://github.com/WiseTechGlobal/WTG.Analyzers/blob/0c0e65d8d97a4f86dd5c1a0d0bb1950203172844/src/WTG.Analyzers/Analyzers/Emit/EmitAnalyzer.cs#L86-L87
On the one hand we could simply add that null check and effectively ignore any emit call where the opcode isn't provided by a simple reference to a static member on OpCodes
. Or we could step into things like conditional expressions (and maybe switch expressions) to build up a list of possible opcodes, then enforce that the Emit overload is valid for all of them.