I'm working on optimizing some code. We have system where we can retrieve data from file though a function call that takes the object type and the data name, and gives back the constant in question. Something like:
float value = GetData(type, "StartValue");
It can also look like this, where type is implicit though class "A":
static class A
{
static void some_function(self)
{
float value = self.GetData("StartValue");
}
}
The value is constant in a specific release and the type is implicit though what objects defines the function (classes that sort of "inheres" from class A). What I want to try is replacing all GetData calls with the actual respective values. Then creating one function for every combination of some_function and class that can call it. That information is easy to get for me, as is the constant value that is stored in a json file. The actual function is linked in at runtime with reflection, so it's easy to map in the right one.
So something like
static class MyObject //A is "a part" of this class
{
static void some_function_MyObject_version10(self)
{
float value = 5;
}
}
I've managed to do this in the most simple case with Cecil, but when these GetData calls get nested in if statements and other similar thing, complexity quickly gets out of hand I think. So I'm looking into doing this with Roslyn/CodeAnalysis, and that is instead poorly documented, or all examples and tutorials are outdated. But of course I will dig though it and make it happen if that is the best approach, but what would be the best approach for this?