Browse Source

Add ContractAnnotation to Contract.Requires.

To tell resharper that an exception will be thrown when condition ==
false.
pull/335/head
Steven Kirk 11 years ago
parent
commit
6eadf12f96
  1. 5
      src/Perspex.Base/Contract.cs
  2. 1
      src/Perspex.Base/packages.config

5
src/Perspex.Base/Contract.cs

@ -1,12 +1,12 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
namespace Perspex
{
using System;
/// <summary>
/// A stub of Code Contract's Contract class.
/// </summary>
@ -25,6 +25,7 @@ namespace Perspex
/// </typeparam>
/// <param name="condition">The precondition.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ContractAnnotation("condition:false=>stop")]
public static void Requires<TException>(bool condition) where TException : Exception, new()
{
if (!condition)

1
src/Perspex.Base/packages.config

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="JetBrains.Annotations" version="9.2.0" targetFramework="portable45-net45+win8" />
<package id="Rx-Core" version="2.2.5" targetFramework="portable-net45+win8" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="portable-net45+win8" />
<package id="Rx-Linq" version="2.2.5" targetFramework="portable-net45+win8" />

Loading…
Cancel
Save