Issue
I generated some code using SQLMetal and worked with it for some time. Just now, I looked through the generated code, and fond in each class a few partial functions, that I never implemented, nor were they implemented by SQLMetal. These functions were called in the code. I wonder - whats happening when I call a function like that - that doesn't exist?
Solution
These functions were called in the code. I wonder - whats happening when I call a function like that - that doesn't exist?
The call is completely removed by the compiler. Any expressions which are evaluated in order to call the method are removed too - so if you have this:
SomePartialMethod(ComputeSomeValue());
and SomePartialMethod
isn't implemented, ComputeSomeValue
won't be called.
Or as MSDN puts it:
If the method is not implemented, then the compiler removes the method signature and all calls to the method. The calls to the method, including any results that would occur from evaluation of arguments in the calls, have no effect at run time. Therefore, any code in the partial class can freely use a partial method, even if the implementation is not supplied. No compile-time or run-time errors will result if the method is called but not implemented.
Answered By - Jon Skeet Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.