We have a project that's compiled into a DLL called consts.dll that contains something like:
public static class Consts
{
public const string a = "a";
public const string b = "b";
public const string c = "c";
}
We have multiple projects of this sort, each compiled into a DLL of the same name (consts.dll) and we replace them according to need.
We have another class that uses these consts:
public class ConstsUser
{
string f() { return Consts.a; }
}
Unfortunately, Consts.a
is optimized to "a" , so even if we replace Consts.dll implementation, we still get "a" instead of the correct value and we need to recompile ConstsUser
. Is there anyway to stop the optimizer from replacing const variables with their values?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…