CppSharp
CppSharp copied to clipboard
Public static variables should generate code to access them by reference
struct Config{
Config() { }
Config(const Config&) {
printf("Copy constructor");
}
void Method() {}
};
struct Struct {
static ::Config Config;
};
Struct.Config.Method(); // prints copy constructor
Struct.Config.Method(); // prints copy constructor
Struct.Config.Method(); // prints copy constructor
OS: Windows
Used settings
Target: MSVC
Stack trace or incompilable generated code
public static global::Lib.Config Config
{
get
{
var __ptr = (global::Lib.Config.__Internal*)CppSharp.SymbolResolver.ResolveSymbol("Lib.dll", "?Config@Struct@@2U0@A");
return global::Lib.Config.__CreateInstance(*__ptr);
}
set
{
var __ptr = (global::Lib.Config.__Internal*)CppSharp.SymbolResolver.ResolveSymbol("Lib.dll", "?Config@Struct@@2U0@A");
if (ReferenceEquals(value, null))
throw new global::System.ArgumentNullException("value", "Cannot be null because it is passed by value.");
*__ptr = *(global::Lib.Config.__Internal*) value.__Instance;
}
}