Skip to content

InstructionOrEnumerable Class

A wrapper which represents Instruction or its IEnumerable<T>.

You don’t need to directly interact with this type; implicit type conversions are provided which allow using e.g. ILWeaver’s Insert methods seamlessly while mixing up Instruction and its IEnumerable<T> in parameters marked as params IEnumerable<T> of InstructionOrEnumerable.

C#
public sealed class InstructionOrEnumerable : IEnumerable<Instruction>, IEnumerable

Inheritance object

Implements IEnumerable<Instruction>, IEnumerable

This is a hacky workaround for the fact that C# does not have discriminated unions (as of C# 14).

InstructionOrEnumerable(IEnumerable<Instruction>)

Section titled “InstructionOrEnumerable(IEnumerable<Instruction>)”

A wrapper which represents Instruction or its IEnumerable<T>.

You don’t need to directly interact with this type; implicit type conversions are provided which allow using e.g. ILWeaver’s Insert methods seamlessly while mixing up Instruction and its IEnumerable<T> in parameters marked as params IEnumerable<T> of InstructionOrEnumerable.

C#
public InstructionOrEnumerable(IEnumerable<Instruction> instructions)

instructions IEnumerable<Instruction>
Value to wrap as InstructionOrEnumerable.

This is a hacky workaround for the fact that C# does not have discriminated unions (as of C# 14).

A wrapper which represents Instruction or its IEnumerable<T>.

You don’t need to directly interact with this type; implicit type conversions are provided which allow using e.g. ILWeaver’s Insert methods seamlessly while mixing up Instruction and its IEnumerable<T> in parameters marked as params IEnumerable<T> of InstructionOrEnumerable.

C#
public InstructionOrEnumerable(Instruction instruction)

instruction Instruction
Value to wrap as InstructionOrEnumerable.

This is a hacky workaround for the fact that C# does not have discriminated unions (as of C# 14).

Returns an enumerator that iterates through the collection.

C#
public IEnumerator<Instruction> GetEnumerator()

IEnumerator<Instruction>
An enumerator that can be used to iterate through the collection.