.NET Framework Code Contracts Postconditions

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Postconditions ensure that the returned results from a method will match the provided definition. This provides the caller with a definition of the expected result. Postconditions may allowed for simplied implmentations as some possible outcomes can be provided by the static analyizer.

Example...

string GetValue()
{
    Contract.Ensures(Contract.Result<string>() != null);

    return null;
}

Static Analyis Result...

enter image description here



Got any .NET Framework Question?