Code contracts are used to assert things that will always be true, and if they are incorrect, then there is an error in the code. This means that it can only be applied to conditions that are controlled by code. Thus, you cannot use them to indicate "the user will never supply an empty string" because it is out of code control. A static verifier can never prove this statement - how can he know what the user will do?
What you can do is make expressions like "Given user input, the method will either return a non-empty string or throw an exception."
source share