| | | 1 | | //======================================================================= |
| | | 2 | | // MemberNotNullAttribute.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using System; |
| | | 9 | | |
| | | 10 | | namespace SwiftCollections; |
| | | 11 | | |
| | | 12 | | /// <summary>Specifies that the method or property will ensure that the listed field and property members have not-null |
| | | 13 | | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] |
| | | 14 | | #if SYSTEM_PRIVATE_CORELIB |
| | | 15 | | public |
| | | 16 | | #else |
| | | 17 | | internal |
| | | 18 | | #endif |
| | | 19 | | sealed class MemberNotNullAttribute : Attribute |
| | | 20 | | { |
| | | 21 | | /// <summary>Initializes the attribute with a field or property member.</summary> |
| | | 22 | | /// <param name="member"> |
| | | 23 | | /// The field or property member that is promised to be not-null. |
| | | 24 | | /// </param> |
| | 2 | 25 | | public MemberNotNullAttribute(string member) => Members = new[] { member }; |
| | | 26 | | |
| | | 27 | | /// <summary>Initializes the attribute with the list of field and property members.</summary> |
| | | 28 | | /// <param name="members"> |
| | | 29 | | /// The list of field and property members that are promised to be not-null. |
| | | 30 | | /// </param> |
| | 2 | 31 | | public MemberNotNullAttribute(params string[] members) => Members = members; |
| | | 32 | | |
| | | 33 | | /// <summary>Gets field or property member names.</summary> |
| | | 34 | | public string[] Members { get; } |
| | | 35 | | } |