How aggressive in-lining behaves with local functions and abstract methods?
I couldn't find any specific answers to this type of problems.
EDIT: you can't put attribute before local function anymore. - C# 7 Local Functions: are attributes / aspects allowed?
Local function example.
//? Do I have to add [MethodImpl(MethodImplOptions.AggressiveInlining)] before local function for it to be in-lined or is it done by default?
public GameObject Select(LevelProvider provider, int level)
{
//! This gives an error and I can't apply attribute to local method.
// So my guess it should always be in-lined. Or does JIT still choose to whether in-line it or not?
[MethodImpl(MethodImplOptions.AggressiveInlining)]
int GetDistance(GameObject keyGameObject, int levelIndex) => provider.occurrency.TryGetValue(keyGameObject.GetInstanceID(), out int occurencyValue) ? levelIndex - occurencyValue : 0;
if (!provider.map.TryGetValue(level, out GameObject prefab))
{
...
}
return prefab;
}
Abstract example.
public abstract class Base : Object
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public abstract TData Select(TProvider provider);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual TData Other(TProvider provider)
{
...
}
}
public class Derived : Base
{
[MethodImpl(MethodImplOptions.AggressiveInlining)] // !!! Do I have to do this step? !!!
public override GameObject Select(LevelProvider provider)
{
...
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] // !!! What about this? !!!
public override GameObject Other(LevelProvider provider)
{
...
}
}