I'm using Linq to SQL, which generates partial classes and partial methods. You then extend that generated code by implementing your your customizations manually in another partial class. One of the hooks L2S gives you is the ability to implement partial methods that get called when a property changes. For example, if you have a property named "MyProp", then you can implement a partial method like so:
' Given to you in the generator
Partial Private Sub OnMyPropChanged()
End Sub
' Manually implemented in my custom class
' I cannot specify that this is an implementation of a Partial, even though it is...
Private Sub OnMyPropChanged()
Console.WriteLine("My prop changed... do something here")
End Sub
The problem I'm having is the name of "MyProp" has now changed to "MyNewPropName", so now the partial in the generator creates Partial Private Sub OnMyNewPropNameChanged()
, but my version of the partial method still has the old name. Effectively, I now have an orphaned private method that never gets called which means my code is broken at runtime. How would you test for something like this, or even better - is there a way to specify that my version of OnMyPropChanged()
is an implementation of a partial method such that the I get a compile time breakage if there isn't a corresponding partial in the generated code?