InliningAnalyzer
InliningAnalyzer copied to clipboard
Does it work for properties and/or x64 targets?
In the following example:
using System.Runtime.CompilerServices;
namespace ex
{
public struct Cell
{
public int X;
public int Y;
}
public sealed unsafe class CellArray1
{
private Cell* _data;
Cell[] cells;
public CellArray1(int size)
{
cells = new Cell[size];
fixed (Cell* c = &cells[0])
{
_data = c;
}
}
public ref Cell this[int pos]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return ref *(_data + pos); }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref Cell At(int pos)
{
return ref *(_data + pos);
}
}
class Program
{
static void Main(string[] args)
{
var m1 = new CellArray1(4096);
var sum1 = 0;
for (var i = 0; i < 4096; i++)
{
m1[i].X = i;
m1.At(i).Y = -1;
sum1 += m1[i].X;
}
}
}
}
I can't get the analyzer to work on the property invocation m1[i].
Also I didn't see any annotations when targeting x64 release, and the analysis time seemed slow.
The issue with the m1[i] invocation was that ref returns for properties and indexers where not handled correctly. This should be fixed now.
This sample worked for me with x64 release in a project with just a few other files. Did you test it as part of a larger project? If so, it could be that another file caused an issue. Is the project you used available somewhere? Or are any errors logged in the 'Inlining Analyzer' output window in VS?