|
1 | 1 | #if !NET7_0_OR_GREATER |
2 | 2 |
|
| 3 | +// ReSharper disable InconsistentNaming |
3 | 4 | // ReSharper disable once CheckNamespace |
4 | 5 | namespace System.Diagnostics.CodeAnalysis; |
5 | 6 |
|
6 | | -/// <summary> |
7 | | -/// Stub |
8 | | -/// </summary> |
| 7 | +/// <summary>Stub version of the StringSyntaxAttribute, which was introduced in .NET 7</summary> |
9 | 8 | public sealed class StringSyntaxAttribute : Attribute |
10 | 9 | { |
11 | | - // ReSharper disable once InconsistentNaming |
| 10 | + /// <summary>Initializes the <see cref="StringSyntaxAttribute"/> with the identifier of the syntax used.</summary> |
| 11 | + /// <param name="syntax">The syntax identifier.</param> |
| 12 | + public StringSyntaxAttribute(string syntax) |
| 13 | + { |
| 14 | + Syntax = syntax; |
| 15 | + Arguments = Array.Empty<object?>(); |
| 16 | + } |
| 17 | + |
| 18 | + /// <summary>Initializes the <see cref="StringSyntaxAttribute"/> with the identifier of the syntax used.</summary> |
| 19 | + /// <param name="syntax">The syntax identifier.</param> |
| 20 | + /// <param name="arguments">Optional arguments associated with the specific syntax employed.</param> |
| 21 | + public StringSyntaxAttribute(string syntax, params object?[] arguments) |
| 22 | + { |
| 23 | + Syntax = syntax; |
| 24 | + Arguments = arguments; |
| 25 | + } |
| 26 | + |
| 27 | + /// <summary>Gets the identifier of the syntax used.</summary> |
| 28 | + public string Syntax { get; } |
| 29 | + |
| 30 | + /// <summary>Optional arguments associated with the specific syntax employed.</summary> |
| 31 | + public object?[] Arguments { get; } |
| 32 | + |
| 33 | + /// <summary>The syntax identifier for strings containing composite formats for string formatting.</summary> |
12 | 34 | #pragma warning disable IDE1006 |
13 | 35 | public const string CompositeFormat = nameof(CompositeFormat); |
14 | | -#pragma warning restore IDE1006 |
15 | 36 |
|
16 | | -#pragma warning disable IDE0060 |
17 | | - public StringSyntaxAttribute(string syntax) |
18 | | - { } |
19 | | -#pragma warning restore IDE0060 |
| 37 | + /// <summary>The syntax identifier for strings containing date format specifiers.</summary> |
| 38 | + public const string DateOnlyFormat = nameof(DateOnlyFormat); |
| 39 | + |
| 40 | + /// <summary>The syntax identifier for strings containing date and time format specifiers.</summary> |
| 41 | + public const string DateTimeFormat = nameof(DateTimeFormat); |
| 42 | + |
| 43 | + /// <summary>The syntax identifier for strings containing <see cref="Enum"/> format specifiers.</summary> |
| 44 | + public const string EnumFormat = nameof(EnumFormat); |
| 45 | + |
| 46 | + /// <summary>The syntax identifier for strings containing <see cref="Guid"/> format specifiers.</summary> |
| 47 | + public const string GuidFormat = nameof(GuidFormat); |
| 48 | + |
| 49 | + /// <summary>The syntax identifier for strings containing JavaScript Object Notation (JSON).</summary> |
| 50 | + public const string Json = nameof(Json); |
| 51 | + |
| 52 | + /// <summary>The syntax identifier for strings containing numeric format specifiers.</summary> |
| 53 | + public const string NumericFormat = nameof(NumericFormat); |
| 54 | + |
| 55 | + /// <summary>The syntax identifier for strings containing regular expressions.</summary> |
| 56 | + public const string Regex = nameof(Regex); |
| 57 | + |
| 58 | + /// <summary>The syntax identifier for strings containing time format specifiers.</summary> |
| 59 | + public const string TimeOnlyFormat = nameof(TimeOnlyFormat); |
| 60 | + |
| 61 | + /// <summary>The syntax identifier for strings containing <see cref="TimeSpan"/> format specifiers.</summary> |
| 62 | + public const string TimeSpanFormat = nameof(TimeSpanFormat); |
| 63 | + |
| 64 | + /// <summary>The syntax identifier for strings containing URIs.</summary> |
| 65 | + public const string Uri = nameof(Uri); |
| 66 | + |
| 67 | + /// <summary>The syntax identifier for strings containing XML.</summary> |
| 68 | + public const string Xml = nameof(Xml); |
| 69 | +#pragma warning restore IDE1006 |
20 | 70 | } |
| 71 | + |
21 | 72 | #endif |
0 commit comments