public override void RewriteConditional(ref BasicBlock block) { var evaluated = Context.Options.IsFeatureEnabled(Feature); Scanner.LogDebug(1, $"REWRITE FEATURE CONDITIONAL: {Feature} {evaluated}"); if (evaluated) { BlockList.DeleteBlock(ref block); return; } Context.LogMessage(MessageImportance.High, Environment.NewLine); Context.LogMessage(MessageImportance.High, $"Required feature `{Feature}` not available."); #if FIXME Context.Context.Tracer.Dump(); #endif Context.LogMessage(MessageImportance.High, Environment.NewLine); var pns = Context.Context.GetType("System.PlatformNotSupportedException"); var ctor = pns?.Methods.FirstOrDefault(m => m.Name == ".ctor"); if (ctor == null) { throw new OptimizerAssertionException($"Can't find `System.PlatformNotSupportedException`."); } Scanner.LogDebug(1, $"REWRITE FEATURE CONDITIONAL #1: {pns} {ctor}"); var reference = Method.DeclaringType.Module.ImportReference(ctor); BlockList.ReplaceInstructionAt(ref block, 0, Instruction.Create(OpCodes.Newobj, reference)); BlockList.ReplaceInstructionAt(ref block, 1, Instruction.Create(OpCodes.Throw)); }