All code written in .NET languages compiles to MSIL, but are there specific tasks / operations that you can do only using MSIL directly?
Let us also have things done easier in MSIL than C#, VB.NET, F#, j# or any other .NET language.
So far we have this:
- Tail recursion
- Generic Co/Contravariance
- Overloads which differ only in return types
- Override access modifiers
- Have a class which cannot inherit from System.Object
- Filtered exceptions (can be done in vb.net)
- Calling a virtual method of the current static class type.
- Get a handle on the boxed version of a value type.
- Do a try/fault.
- Usage of forbidden names.
- Define your own parameterless constructors for value types.
- Define events with a
raise
element.
- Some conversions allowed by the CLR but not by C#.
- Make a non
main()
method as the .entrypoint
.
- work with the native
int
and native unsigned int
types directly.
- Play with transient pointers
- emitbyte directive in MethodBodyItem
- Throw and catch non System.Exception types
- Inherit Enums (Unverified)
- You can treat an array of bytes as a (4x smaller) array of ints.
- You can have a field/method/property/event all have the same name(Unverified).
- You can branch back into a try block from its own catch block.
- You have access to the famandassem access specifier (
protected internal
is famorassem)
- Direct access to the
<Module>
class for defining global functions, or a module initializer.