1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+
4+ namespace System . Diagnostics . CodeAnalysis ;
5+
6+ /// <summary>Specifies the syntax used in a string.</summary>
7+ [ AttributeUsage ( AttributeTargets . Parameter | AttributeTargets . Field | AttributeTargets . Property , AllowMultiple = false , Inherited = false ) ]
8+ internal sealed class StringSyntaxAttribute : Attribute
9+ {
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>
34+ public const string CompositeFormat = nameof ( CompositeFormat ) ;
35+
36+ /// <summary>The syntax identifier for strings containing date format specifiers.</summary>
37+ public const string DateOnlyFormat = nameof ( DateOnlyFormat ) ;
38+
39+ /// <summary>The syntax identifier for strings containing date and time format specifiers.</summary>
40+ public const string DateTimeFormat = nameof ( DateTimeFormat ) ;
41+
42+ /// <summary>The syntax identifier for strings containing <see cref="Enum"/> format specifiers.</summary>
43+ public const string EnumFormat = nameof ( EnumFormat ) ;
44+
45+ /// <summary>The syntax identifier for strings containing <see cref="Guid"/> format specifiers.</summary>
46+ public const string GuidFormat = nameof ( GuidFormat ) ;
47+
48+ /// <summary>The syntax identifier for strings containing JavaScript Object Notation (JSON).</summary>
49+ public const string Json = nameof ( Json ) ;
50+
51+ /// <summary>The syntax identifier for strings containing numeric format specifiers.</summary>
52+ public const string NumericFormat = nameof ( NumericFormat ) ;
53+
54+ /// <summary>The syntax identifier for strings containing regular expressions.</summary>
55+ public const string Regex = nameof ( Regex ) ;
56+
57+ /// <summary>The syntax identifier for strings containing time format specifiers.</summary>
58+ public const string TimeOnlyFormat = nameof ( TimeOnlyFormat ) ;
59+
60+ /// <summary>The syntax identifier for strings containing <see cref="TimeSpan"/> format specifiers.</summary>
61+ public const string TimeSpanFormat = nameof ( TimeSpanFormat ) ;
62+
63+ /// <summary>The syntax identifier for strings containing URIs.</summary>
64+ public const string Uri = nameof ( Uri ) ;
65+
66+ /// <summary>The syntax identifier for strings containing XML.</summary>
67+ public const string Xml = nameof ( Xml ) ;
68+ }
0 commit comments