-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from bdukes/master
Fix references
- Loading branch information
Showing
21 changed files
with
906 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// <copyright file="BaseTypeRequiredAttribute.cs" company="JetBrains s.r.o."> | ||
// Copyright 2007-2012 JetBrains s.r.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
namespace JetBrains.Annotations | ||
{ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary>When applied to a target attribute, specifies a requirement for any type marked with | ||
/// the target attribute to implement or inherit specific type or types.</summary> | ||
/// <example> | ||
/// <code> | ||
/// [BaseTypeRequired(typeof(IComponent)] // Specify requirement | ||
/// public class ComponentAttribute : Attribute | ||
/// {} | ||
/// [Component] // ComponentAttribute requires implementing IComponent interface | ||
/// public class MyComponent : IComponent | ||
/// {} | ||
/// </code> | ||
/// </example> | ||
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "Jetbrains code")] | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] | ||
[BaseTypeRequired(typeof(Attribute))] | ||
public sealed class BaseTypeRequiredAttribute : Attribute | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="BaseTypeRequiredAttribute"/> class</summary> | ||
/// <param name="baseType">Specifies which types are required</param> | ||
public BaseTypeRequiredAttribute(Type baseType) | ||
{ | ||
this.BaseTypes = new[] { baseType }; | ||
} | ||
|
||
/// <summary>Gets enumerations of specified base types</summary> | ||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Jetbrains code")] | ||
public Type[] BaseTypes { get; private set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// <copyright file="CanBeNullAttribute.cs" company="JetBrains s.r.o."> | ||
// Copyright 2007-2012 JetBrains s.r.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
namespace JetBrains.Annotations | ||
{ | ||
using System; | ||
|
||
/// <summary>Indicates that the value of the marked element could be <c>null</c> sometimes, | ||
/// so the check for <c>null</c> is necessary before its usage.</summary> | ||
/// <example> | ||
/// <code> | ||
/// [CanBeNull] | ||
/// public object Test() | ||
/// { | ||
/// return null; | ||
/// } | ||
/// public void UseTest() | ||
/// { | ||
/// var p = Test(); | ||
/// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' | ||
/// } | ||
/// </code> | ||
/// </example> | ||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Delegate | AttributeTargets.Field, AllowMultiple = false, Inherited = true)] | ||
public sealed class CanBeNullAttribute : Attribute | ||
{ | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
Utility/Annotations/CannotApplyEqualityOperatorAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// <copyright file="CannotApplyEqualityOperatorAttribute.cs" company="JetBrains s.r.o."> | ||
// Copyright 2007-2012 JetBrains s.r.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
namespace JetBrains.Annotations | ||
{ | ||
using System; | ||
|
||
/// <summary>Indicates that the value of the marked type (or its derivatives) | ||
/// cannot be compared using '==' or '!=' operators and <c>Equals()</c> should be used instead. | ||
/// However, using '==' or '!=' for comparison with <c>null</c> is always permitted.</summary> | ||
/// <example> | ||
/// <code> | ||
/// [CannotApplyEqualityOperator] | ||
/// class NoEquality | ||
/// { | ||
/// } | ||
/// class UsesNoEquality | ||
/// { | ||
/// public void Test() | ||
/// { | ||
/// var ca1 = new NoEquality(); | ||
/// var ca2 = new NoEquality(); | ||
/// if (ca1 != null) // OK | ||
/// { | ||
/// bool condition = ca1 == ca2; // Warning | ||
/// } | ||
/// } | ||
/// } | ||
/// </code> | ||
/// </example> | ||
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)] | ||
public sealed class CannotApplyEqualityOperatorAttribute : Attribute | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// <copyright file="ContractAnnotationAttribute.cs" company="JetBrains s.r.o."> | ||
// Copyright 2007-2012 JetBrains s.r.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
namespace JetBrains.Annotations | ||
{ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary>Describes dependency between method input and output.</summary> | ||
/// <syntax> | ||
/// <p>Function Definition Table syntax:</p> | ||
/// <list> | ||
/// <item>FDT ::= FDTRow [;FDTRow]*</item> | ||
/// <item>FDTRow ::= Input => Output | Output <= Input</item> | ||
/// <item>Input ::= ParameterName: Value [, Input]*</item> | ||
/// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item> | ||
/// <item>Value ::= true | false | null | notnull | canbenull</item> | ||
/// </list> | ||
/// If method has single input parameter, it's name could be omitted. <br /> | ||
/// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for method output means that the methos doesn't return normally. <br /> | ||
/// <c>canbenull</c> annotation is only applicable for output parameters. <br /> | ||
/// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute with rows separated by semicolon. <br /> | ||
/// </syntax> | ||
/// <examples> | ||
/// <list> | ||
/// <item><code> | ||
/// [ContractAnnotation("=> halt")] | ||
/// public void TerminationMethod() | ||
/// </code></item> | ||
/// <item><code> | ||
/// [ContractAnnotation("halt <= condition: false")] | ||
/// public void Assert(bool condition, string text) // Regular Assertion method | ||
/// </code></item> | ||
/// <item><code> | ||
/// [ContractAnnotation("s:null => true")] | ||
/// public bool IsNullOrEmpty(string s) // String.IsNullOrEmpty | ||
/// </code></item> | ||
/// <item><code> | ||
/// A method that returns null if the parameter is null, and not null if the parameter is not null | ||
/// [ContractAnnotation("null => null; notnull => notnull")] | ||
/// public object Transform(object data) | ||
/// </code></item> | ||
/// <item><code> | ||
/// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] | ||
/// public bool TryParse(string s, out Person result) | ||
/// </code></item> | ||
/// </list> | ||
/// </examples> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||
public sealed class ContractAnnotationAttribute : Attribute | ||
{ | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Jetbrains code"), SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "fdt", Justification = "Jetbrains code")] | ||
public ContractAnnotationAttribute([NotNull] string fdt) | ||
: this(fdt, false) | ||
{ | ||
} | ||
|
||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Jetbrains code"), SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "fdt", Justification = "Jetbrains code")] | ||
public ContractAnnotationAttribute([NotNull] string fdt, bool forceFullStates) | ||
{ | ||
this.FDT = fdt; | ||
this.ForceFullStates = forceFullStates; | ||
} | ||
|
||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Jetbrains code"), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "FDT", Justification = "Jetbrains code")] | ||
public string FDT { get; private set; } | ||
|
||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Jetbrains code")] | ||
public bool ForceFullStates { get; private set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// <copyright file="ImplicitUseKindFlags.cs" company="JetBrains s.r.o."> | ||
// Copyright 2007-2012 JetBrains s.r.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
namespace JetBrains.Annotations | ||
{ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
[Flags] | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Jetbrains code"), SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Justification = "Jetbrains code")] | ||
public enum ImplicitUseKindFlags | ||
{ | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", Justification = "Jetbrains code")] | ||
Default = Access | Assign | InstantiatedWithFixedConstructorSignature, | ||
|
||
/// <summary>Only entity marked with attribute considered used</summary> | ||
Access = 1, | ||
|
||
/// <summary>Indicates implicit assignment to a member</summary> | ||
Assign = 2, | ||
|
||
/// <summary>Indicates implicit instantiation of a type with fixed constructor signature. | ||
/// That means any unused constructor parameters won't be reported as such.</summary> | ||
InstantiatedWithFixedConstructorSignature = 4, | ||
|
||
/// <summary>Indicates implicit instantiation of a type</summary> | ||
InstantiatedNoFixedConstructorSignature = 8, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// <copyright file="ImplicitUseTargetFlags.cs" company="JetBrains s.r.o."> | ||
// Copyright 2007-2012 JetBrains s.r.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
namespace JetBrains.Annotations | ||
{ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
/// <summary>Specify what is considered used implicitly when marked with <see cref="MeansImplicitUseAttribute"/> or <see cref="UsedImplicitlyAttribute"/></summary> | ||
[Flags] | ||
[SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Justification = "Jetbrains code")] | ||
public enum ImplicitUseTargetFlags | ||
{ | ||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", Justification = "Jetbrains code")] | ||
Default = Itself, | ||
|
||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", Justification = "Jetbrains code")] | ||
Itself = 1, | ||
|
||
/// <summary>Members of entity marked with attribute are considered used</summary> | ||
Members = 2, | ||
|
||
/// <summary>Entity marked with attribute and all its members considered used</summary> | ||
WithMembers = Itself | Members | ||
} | ||
} |
Oops, something went wrong.