Is it possible to create an object that can register, does the current thread leave the method in which it was created, or to check if this happened when the method was called on the instance?
ScopeValid obj;
void Method1()
{
obj = new ScopeValid();
obj.Something();
}
void Method2()
{
Method1();
obj.Something();
}
Can this technique be done? I would like to develop a mechanism similar to TypedReferenceand ArgIteratorthat cannot “avoid” the current method. These types are handled specifically by the compiler, so I can’t accurately simulate this behavior, but I hope it’s possible to create at least a similar rule with the same results - to deny access to the object if it escaped the method in which it was created.
, StackFrame , .