Skip to content

Commit f045559

Browse files
committed
copy code for StringSyntaxAttribute from original source
1 parent 79b0161 commit f045559

File tree

1 file changed

+60
-9
lines changed

1 file changed

+60
-9
lines changed
Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,72 @@
11
#if !NET7_0_OR_GREATER
22

3+
// ReSharper disable InconsistentNaming
34
// ReSharper disable once CheckNamespace
45
namespace System.Diagnostics.CodeAnalysis;
56

6-
/// <summary>
7-
/// Stub
8-
/// </summary>
7+
/// <summary>Stub version of the StringSyntaxAttribute, which was introduced in .NET 7</summary>
98
public sealed class StringSyntaxAttribute : Attribute
109
{
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>
1234
#pragma warning disable IDE1006
1335
public const string CompositeFormat = nameof(CompositeFormat);
14-
#pragma warning restore IDE1006
1536

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
2070
}
71+
2172
#endif

0 commit comments

Comments
 (0)