Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top