|
| 1 | +// <copyright file="IWebElementReference.cs" company="WebDriver Committers"> |
| 2 | +// Licensed to the Software Freedom Conservancy (SFC) under one |
| 3 | +// or more contributor license agreements. See the NOTICE file |
| 4 | +// distributed with this work for additional information |
| 5 | +// regarding copyright ownership. The SFC licenses this file |
| 6 | +// to you under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// </copyright> |
| 18 | + |
| 19 | +#if !NET8_0_OR_GREATER |
| 20 | + |
| 21 | +// Original code in https://github.com/dotnet/runtime/blob/419e949d258ecee4c40a460fb09c66d974229623/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs |
| 22 | + |
| 23 | +namespace System.Diagnostics.CodeAnalysis |
| 24 | +{ |
| 25 | + /// <summary>Specifies that null is allowed as an input even if the corresponding type disallows it.</summary> |
| 26 | + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)] |
| 27 | + internal sealed class AllowNullAttribute : Attribute |
| 28 | + { } |
| 29 | + |
| 30 | + /// <summary>Specifies that null is disallowed as an input even if the corresponding type allows it.</summary> |
| 31 | + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)] |
| 32 | + internal sealed class DisallowNullAttribute : Attribute |
| 33 | + { } |
| 34 | + |
| 35 | + /// <summary>Specifies that an output may be null even if the corresponding type disallows it.</summary> |
| 36 | + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)] |
| 37 | + internal sealed class MaybeNullAttribute : Attribute |
| 38 | + { } |
| 39 | + |
| 40 | + /// <summary>Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns.</summary> |
| 41 | + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)] |
| 42 | + internal sealed class NotNullAttribute : Attribute |
| 43 | + { } |
| 44 | + |
| 45 | + /// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter may be null even if the corresponding type disallows it.</summary> |
| 46 | + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] |
| 47 | + internal sealed class MaybeNullWhenAttribute : Attribute |
| 48 | + { |
| 49 | + /// <summary>Initializes the attribute with the specified return value condition.</summary> |
| 50 | + /// <param name="returnValue"> |
| 51 | + /// The return value condition. If the method returns this value, the associated parameter may be null. |
| 52 | + /// </param> |
| 53 | + public MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; |
| 54 | + |
| 55 | + /// <summary>Gets the return value condition.</summary> |
| 56 | + public bool ReturnValue { get; } |
| 57 | + } |
| 58 | + |
| 59 | + /// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter will not be null even if the corresponding type allows it.</summary> |
| 60 | + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] |
| 61 | + internal sealed class NotNullWhenAttribute : Attribute |
| 62 | + { |
| 63 | + /// <summary>Initializes the attribute with the specified return value condition.</summary> |
| 64 | + /// <param name="returnValue"> |
| 65 | + /// The return value condition. If the method returns this value, the associated parameter will not be null. |
| 66 | + /// </param> |
| 67 | + public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; |
| 68 | + |
| 69 | + /// <summary>Gets the return value condition.</summary> |
| 70 | + public bool ReturnValue { get; } |
| 71 | + } |
| 72 | + |
| 73 | + /// <summary>Specifies that the output will be non-null if the named parameter is non-null.</summary> |
| 74 | + [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] |
| 75 | + internal sealed class NotNullIfNotNullAttribute : Attribute |
| 76 | + { |
| 77 | + /// <summary>Initializes the attribute with the associated parameter name.</summary> |
| 78 | + /// <param name="parameterName"> |
| 79 | + /// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. |
| 80 | + /// </param> |
| 81 | + public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName; |
| 82 | + |
| 83 | + /// <summary>Gets the associated parameter name.</summary> |
| 84 | + public string ParameterName { get; } |
| 85 | + } |
| 86 | + |
| 87 | + /// <summary>Applied to a method that will never return under any circumstance.</summary> |
| 88 | + [AttributeUsage(AttributeTargets.Method, Inherited = false)] |
| 89 | + internal sealed class DoesNotReturnAttribute : Attribute |
| 90 | + { } |
| 91 | + |
| 92 | + /// <summary>Specifies that the method will not return if the associated Boolean parameter is passed the specified value.</summary> |
| 93 | + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] |
| 94 | + internal sealed class DoesNotReturnIfAttribute : Attribute |
| 95 | + { |
| 96 | + /// <summary>Initializes the attribute with the specified parameter value.</summary> |
| 97 | + /// <param name="parameterValue"> |
| 98 | + /// The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to |
| 99 | + /// the associated parameter matches this value. |
| 100 | + /// </param> |
| 101 | + public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue; |
| 102 | + |
| 103 | + /// <summary>Gets the condition parameter value.</summary> |
| 104 | + public bool ParameterValue { get; } |
| 105 | + } |
| 106 | + |
| 107 | + /// <summary>Specifies that the method or property will ensure that the listed field and property members have not-null values.</summary> |
| 108 | + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] |
| 109 | + internal sealed class MemberNotNullAttribute : Attribute |
| 110 | + { |
| 111 | + /// <summary>Initializes the attribute with a field or property member.</summary> |
| 112 | + /// <param name="member"> |
| 113 | + /// The field or property member that is promised to be not-null. |
| 114 | + /// </param> |
| 115 | + public MemberNotNullAttribute(string member) => Members = new[] { member }; |
| 116 | + |
| 117 | + /// <summary>Initializes the attribute with the list of field and property members.</summary> |
| 118 | + /// <param name="members"> |
| 119 | + /// The list of field and property members that are promised to be not-null. |
| 120 | + /// </param> |
| 121 | + public MemberNotNullAttribute(params string[] members) => Members = members; |
| 122 | + |
| 123 | + /// <summary>Gets field or property member names.</summary> |
| 124 | + public string[] Members { get; } |
| 125 | + } |
| 126 | + |
| 127 | + /// <summary>Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition.</summary> |
| 128 | + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] |
| 129 | + internal sealed class MemberNotNullWhenAttribute : Attribute |
| 130 | + { |
| 131 | + /// <summary>Initializes the attribute with the specified return value condition and a field or property member.</summary> |
| 132 | + /// <param name="returnValue"> |
| 133 | + /// The return value condition. If the method returns this value, the associated field or property member will not be null. |
| 134 | + /// </param> |
| 135 | + /// <param name="member"> |
| 136 | + /// The field or property member that is promised to be not-null. |
| 137 | + /// </param> |
| 138 | + public MemberNotNullWhenAttribute(bool returnValue, string member) |
| 139 | + { |
| 140 | + ReturnValue = returnValue; |
| 141 | + Members = new[] { member }; |
| 142 | + } |
| 143 | + |
| 144 | + /// <summary>Initializes the attribute with the specified return value condition and list of field and property members.</summary> |
| 145 | + /// <param name="returnValue"> |
| 146 | + /// The return value condition. If the method returns this value, the associated field and property members will not be null. |
| 147 | + /// </param> |
| 148 | + /// <param name="members"> |
| 149 | + /// The list of field and property members that are promised to be not-null. |
| 150 | + /// </param> |
| 151 | + public MemberNotNullWhenAttribute(bool returnValue, params string[] members) |
| 152 | + { |
| 153 | + ReturnValue = returnValue; |
| 154 | + Members = members; |
| 155 | + } |
| 156 | + |
| 157 | + /// <summary>Gets the return value condition.</summary> |
| 158 | + public bool ReturnValue { get; } |
| 159 | + |
| 160 | + /// <summary>Gets field or property member names.</summary> |
| 161 | + public string[] Members { get; } |
| 162 | + } |
| 163 | +} |
| 164 | + |
| 165 | +#endif |
0 commit comments