summaryrefslogtreecommitdiffstats
path: root/tools/Contracts/Languages/CSharp/ContractExtensions.cs
blob: 4074ffa68a3440501a6185d80d12ba033b833b7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
//  Include this file in your project if your project uses
//  ContractArgumentValidator or ContractAbbreviator methods
//
using System;

namespace System.Diagnostics.Contracts
{
  /// <summary>
  /// Enables factoring legacy if-then-throw into separate methods for reuse and full control over
  /// thrown exception and arguments
  /// </summary>
  [AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
  [Conditional("CONTRACTS_FULL")]
  internal sealed class ContractArgumentValidatorAttribute : global::System.Attribute
  {
  }

  /// <summary>
  /// Enables writing abbreviations for contracts that get copied to other methods
  /// </summary>
  [AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
  [Conditional("CONTRACTS_FULL")]
  internal sealed class ContractAbbreviatorAttribute : global::System.Attribute
  {
  }

  /// <summary>
  /// Allows setting contract and tool options at assembly, type, or method granularity.
  /// </summary>
  [AttributeUsage(AttributeTargets.All, AllowMultiple=true, Inherited=false)]
  [Conditional("CONTRACTS_FULL")]
  internal sealed class ContractOptionAttribute : global::System.Attribute
  {
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "category", Justification = "Build-time only attribute")]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "setting", Justification = "Build-time only attribute")]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "toggle", Justification = "Build-time only attribute")]
    public ContractOptionAttribute(string category, string setting, bool toggle) { }
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "category", Justification = "Build-time only attribute")]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "setting", Justification = "Build-time only attribute")]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value", Justification = "Build-time only attribute")]
    public ContractOptionAttribute(string category, string setting, string value) { }
  }
}