Skip to content

Commit cbb5b55

Browse files
[API Implementation]: System.Diagnostics.CodeAnalysis.StringSyntaxAttribute (dotnet#62995)
* Add StringSyntaxAttribute * Fix attribute declaration and add usage * Address PR feedback Co-authored-by: Stephen Toub <[email protected]>
1 parent df9ba64 commit cbb5b55

File tree

24 files changed

+228
-127
lines changed

24 files changed

+228
-127
lines changed

src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public partial class ConsoleFormatterOptions
4141
{
4242
public ConsoleFormatterOptions() { }
4343
public bool IncludeScopes { get { throw null; } set { } }
44+
[System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.DateTimeFormat)]
4445
public string TimestampFormat { get { throw null; } set { } }
4546
public bool UseUtcTimestamp { get { throw null; } set { } }
4647
}

src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
1515
</ItemGroup>
1616

17+
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
18+
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\StringSyntaxAttribute.cs" />
19+
</ItemGroup>
20+
1721
<ItemGroup>
1822
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Json\ref\System.Text.Json.csproj" />
1923
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj" />

src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterOptions.cs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Diagnostics.CodeAnalysis;
56
using System.Text;
67

78
namespace Microsoft.Extensions.Logging.Console
@@ -21,6 +22,7 @@ public ConsoleFormatterOptions() { }
2122
/// <summary>
2223
/// Gets or sets format string used to format timestamp in logging messages. Defaults to <c>null</c>.
2324
/// </summary>
25+
[StringSyntax(StringSyntaxAttribute.DateTimeFormat)]
2426
public string TimestampFormat { get; set; }
2527

2628
/// <summary>

src/libraries/Microsoft.Extensions.Logging.Console/src/Microsoft.Extensions.Logging.Console.csproj

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
@@ -38,6 +38,10 @@
3838
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
3939
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
4040
</ItemGroup>
41+
42+
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
43+
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\StringSyntaxAttribute.cs" />
44+
</ItemGroup>
4145

4246
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
4347
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Bcl.AsyncInterfaces\src\Microsoft.Bcl.AsyncInterfaces.csproj" />
@@ -63,4 +67,4 @@
6367
<Reference Include="System.Runtime" />
6468
</ItemGroup>
6569

66-
</Project>
70+
</Project>

src/libraries/System.ComponentModel.Annotations/ref/System.ComponentModel.Annotations.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public RangeAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMember
235235
[System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false)]
236236
public partial class RegularExpressionAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
237237
{
238-
public RegularExpressionAttribute(string pattern) { }
238+
public RegularExpressionAttribute([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { }
239239
public int MatchTimeoutInMilliseconds { get { throw null; } set { } }
240240
public string Pattern { get { throw null; } }
241241
public override string FormatErrorMessage(string name) { throw null; }

src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/RegularExpressionAttribute.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using System.Globalization;
56
using System.Text.RegularExpressions;
67

@@ -17,7 +18,7 @@ public class RegularExpressionAttribute : ValidationAttribute
1718
/// Constructor that accepts the regular expression pattern
1819
/// </summary>
1920
/// <param name="pattern">The regular expression to use. It cannot be null.</param>
20-
public RegularExpressionAttribute(string pattern)
21+
public RegularExpressionAttribute([StringSyntax(StringSyntaxAttribute.Regex)] string pattern)
2122
: base(() => SR.RegexAttribute_ValidationError)
2223
{
2324
Pattern = pattern;

src/libraries/System.Net.WebProxy/ref/System.Net.WebProxy.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public WebProxy() { }
1818
protected WebProxy(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
1919
public WebProxy(string? Address) { }
2020
public WebProxy(string? Address, bool BypassOnLocal) { }
21-
public WebProxy(string? Address, bool BypassOnLocal, string[]? BypassList) { }
22-
public WebProxy(string? Address, bool BypassOnLocal, string[]? BypassList, System.Net.ICredentials? Credentials) { }
21+
public WebProxy(string? Address, bool BypassOnLocal, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.CultureInvariant)] string[]? BypassList) { }
22+
public WebProxy(string? Address, bool BypassOnLocal, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.CultureInvariant)] string[]? BypassList, System.Net.ICredentials? Credentials) { }
2323
public WebProxy(string Host, int Port) { }
2424
public WebProxy(System.Uri? Address) { }
2525
public WebProxy(System.Uri? Address, bool BypassOnLocal) { }
26-
public WebProxy(System.Uri? Address, bool BypassOnLocal, string[]? BypassList) { }
27-
public WebProxy(System.Uri? Address, bool BypassOnLocal, string[]? BypassList, System.Net.ICredentials? Credentials) { }
26+
public WebProxy(System.Uri? Address, bool BypassOnLocal, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.CultureInvariant)] string[]? BypassList) { }
27+
public WebProxy(System.Uri? Address, bool BypassOnLocal, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.CultureInvariant)] string[]? BypassList, System.Net.ICredentials? Credentials) { }
2828
public System.Uri? Address { get { throw null; } set { } }
2929
public System.Collections.ArrayList BypassArrayList { get { throw null; } }
3030
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]

src/libraries/System.Net.WebProxy/ref/System.Net.WebProxy.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<ProjectReference Include="..\..\System.Net.Primitives\ref\System.Net.Primitives.csproj" />
1212
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
1313
<ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" />
14+
<ProjectReference Include="..\..\System.Text.RegularExpressions\ref\System.Text.RegularExpressions.csproj" />
1415
</ItemGroup>
15-
</Project>
16+
</Project>

src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public WebProxy(Uri? Address) : this(Address, false, null, null) { }
2020

2121
public WebProxy(Uri? Address, bool BypassOnLocal) : this(Address, BypassOnLocal, null, null) { }
2222

23-
public WebProxy(Uri? Address, bool BypassOnLocal, string[]? BypassList) : this(Address, BypassOnLocal, BypassList, null) { }
23+
public WebProxy(Uri? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] string[]? BypassList) : this(Address, BypassOnLocal, BypassList, null) { }
2424

25-
public WebProxy(Uri? Address, bool BypassOnLocal, string[]? BypassList, ICredentials? Credentials)
25+
public WebProxy(Uri? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] string[]? BypassList, ICredentials? Credentials)
2626
{
2727
this.Address = Address;
2828
this.Credentials = Credentials;
@@ -49,12 +49,12 @@ public WebProxy(string? Address, bool BypassOnLocal)
4949
{
5050
}
5151

52-
public WebProxy(string? Address, bool BypassOnLocal, string[]? BypassList)
52+
public WebProxy(string? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] string[]? BypassList)
5353
: this(CreateProxyUri(Address), BypassOnLocal, BypassList, null)
5454
{
5555
}
5656

57-
public WebProxy(string? Address, bool BypassOnLocal, string[]? BypassList, ICredentials? Credentials)
57+
public WebProxy(string? Address, bool BypassOnLocal, [StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)] string[]? BypassList, ICredentials? Credentials)
5858
: this(CreateProxyUri(Address), BypassOnLocal, BypassList, Credentials)
5959
{
6060
}

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

+7-6
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
<Compile Include="$(MSBuildThisFileDirectory)Internal\Console.cs" />
5858
<Compile Include="$(MSBuildThisFileDirectory)Internal\Padding.cs" />
5959
<Compile Include="$(MSBuildThisFileDirectory)Internal\Runtime\CompilerServices\Unsafe.cs" />
60-
<Compile Include="$(MSBuildThisFileDirectory)\Internal\Runtime\InteropServices\ComponentActivator.cs" />
61-
<Compile Include="$(MSBuildThisFileDirectory)\Internal\Runtime\InteropServices\IsolatedComponentLoadContext.cs" />
60+
<Compile Include="$(MSBuildThisFileDirectory)Internal\Runtime\InteropServices\ComponentActivator.cs" />
61+
<Compile Include="$(MSBuildThisFileDirectory)Internal\Runtime\InteropServices\IsolatedComponentLoadContext.cs" />
6262
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleMinusOneIsInvalid.cs" />
6363
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleZeroOrMinusOneIsInvalid.cs" />
6464
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeHandleMinusOneIsInvalid.cs" />
@@ -254,15 +254,16 @@
254254
<Compile Include="$(MSBuildThisFileDirectory)System\DefaultBinder.cs" />
255255
<Compile Include="$(MSBuildThisFileDirectory)System\Delegate.cs" />
256256
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\ConstantExpectedAttribute.cs" />
257-
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\RequiresAssemblyFilesAttribute.cs" />
258-
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\RequiresDynamicCodeAttribute.cs" />
259-
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
260257
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMemberTypes.cs" />
261258
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMembersAttribute.cs" />
262259
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\DynamicDependencyAttribute.cs" />
263260
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\NullableAttributes.cs" />
264-
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
261+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\RequiresAssemblyFilesAttribute.cs" />
262+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\RequiresDynamicCodeAttribute.cs" />
263+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
264+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\StringSyntaxAttribute.cs" />
265265
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\SuppressMessageAttribute.cs" />
266+
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
266267
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\ConditionalAttribute.cs" />
267268
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Contracts\ContractException.cs" />
268269
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Contracts\ContractFailedEventArgs.cs" />

src/libraries/System.Private.CoreLib/src/System/DateTime.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ public static DateTime Parse(ReadOnlySpan<char> s, IFormatProvider? provider = n
11341134
// date and optionally a time in a culture-specific or universal format.
11351135
// Leading and trailing whitespace characters are allowed.
11361136
//
1137-
public static DateTime ParseExact(string s, string format, IFormatProvider? provider)
1137+
public static DateTime ParseExact(string s, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, IFormatProvider? provider)
11381138
{
11391139
if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
11401140
if (format == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.format);
@@ -1145,28 +1145,28 @@ public static DateTime ParseExact(string s, string format, IFormatProvider? prov
11451145
// date and optionally a time in a culture-specific or universal format.
11461146
// Leading and trailing whitespace characters are allowed.
11471147
//
1148-
public static DateTime ParseExact(string s, string format, IFormatProvider? provider, DateTimeStyles style)
1148+
public static DateTime ParseExact(string s, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, IFormatProvider? provider, DateTimeStyles style)
11491149
{
11501150
DateTimeFormatInfo.ValidateStyles(style);
11511151
if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
11521152
if (format == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.format);
11531153
return DateTimeParse.ParseExact(s, format, DateTimeFormatInfo.GetInstance(provider), style);
11541154
}
11551155

1156-
public static DateTime ParseExact(ReadOnlySpan<char> s, ReadOnlySpan<char> format, IFormatProvider? provider, DateTimeStyles style = DateTimeStyles.None)
1156+
public static DateTime ParseExact(ReadOnlySpan<char> s, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] ReadOnlySpan<char> format, IFormatProvider? provider, DateTimeStyles style = DateTimeStyles.None)
11571157
{
11581158
DateTimeFormatInfo.ValidateStyles(style);
11591159
return DateTimeParse.ParseExact(s, format, DateTimeFormatInfo.GetInstance(provider), style);
11601160
}
11611161

1162-
public static DateTime ParseExact(string s, string[] formats, IFormatProvider? provider, DateTimeStyles style)
1162+
public static DateTime ParseExact(string s, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string[] formats, IFormatProvider? provider, DateTimeStyles style)
11631163
{
11641164
DateTimeFormatInfo.ValidateStyles(style);
11651165
if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
11661166
return DateTimeParse.ParseExactMultiple(s, formats, DateTimeFormatInfo.GetInstance(provider), style);
11671167
}
11681168

1169-
public static DateTime ParseExact(ReadOnlySpan<char> s, string[] formats, IFormatProvider? provider, DateTimeStyles style = DateTimeStyles.None)
1169+
public static DateTime ParseExact(ReadOnlySpan<char> s, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string[] formats, IFormatProvider? provider, DateTimeStyles style = DateTimeStyles.None)
11701170
{
11711171
DateTimeFormatInfo.ValidateStyles(style);
11721172
return DateTimeParse.ParseExactMultiple(s, formats, DateTimeFormatInfo.GetInstance(provider), style);
@@ -1282,7 +1282,7 @@ public override string ToString()
12821282
return DateTimeFormat.Format(this, null, null);
12831283
}
12841284

1285-
public string ToString(string? format)
1285+
public string ToString([StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string? format)
12861286
{
12871287
return DateTimeFormat.Format(this, format, null);
12881288
}
@@ -1292,12 +1292,12 @@ public string ToString(IFormatProvider? provider)
12921292
return DateTimeFormat.Format(this, null, provider);
12931293
}
12941294

1295-
public string ToString(string? format, IFormatProvider? provider)
1295+
public string ToString([StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string? format, IFormatProvider? provider)
12961296
{
12971297
return DateTimeFormat.Format(this, format, provider);
12981298
}
12991299

1300-
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null) =>
1300+
public bool TryFormat(Span<char> destination, out int charsWritten, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] ReadOnlySpan<char> format = default, IFormatProvider? provider = null) =>
13011301
DateTimeFormat.TryFormat(this, destination, out charsWritten, format, provider);
13021302

13031303
public DateTime ToUniversalTime()
@@ -1339,7 +1339,7 @@ public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, Dat
13391339
return DateTimeParse.TryParse(s, DateTimeFormatInfo.GetInstance(provider), styles, out result);
13401340
}
13411341

1342-
public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(true)] string? format, IFormatProvider? provider, DateTimeStyles style, out DateTime result)
1342+
public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string? format, IFormatProvider? provider, DateTimeStyles style, out DateTime result)
13431343
{
13441344
DateTimeFormatInfo.ValidateStyles(style);
13451345

@@ -1352,13 +1352,13 @@ public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(tru
13521352
return DateTimeParse.TryParseExact(s, format, DateTimeFormatInfo.GetInstance(provider), style, out result);
13531353
}
13541354

1355-
public static bool TryParseExact(ReadOnlySpan<char> s, ReadOnlySpan<char> format, IFormatProvider? provider, DateTimeStyles style, out DateTime result)
1355+
public static bool TryParseExact(ReadOnlySpan<char> s, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] ReadOnlySpan<char> format, IFormatProvider? provider, DateTimeStyles style, out DateTime result)
13561356
{
13571357
DateTimeFormatInfo.ValidateStyles(style);
13581358
return DateTimeParse.TryParseExact(s, format, DateTimeFormatInfo.GetInstance(provider), style, out result);
13591359
}
13601360

1361-
public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(true)] string?[]? formats, IFormatProvider? provider, DateTimeStyles style, out DateTime result)
1361+
public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string?[]? formats, IFormatProvider? provider, DateTimeStyles style, out DateTime result)
13621362
{
13631363
DateTimeFormatInfo.ValidateStyles(style);
13641364

@@ -1371,7 +1371,7 @@ public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(tru
13711371
return DateTimeParse.TryParseExactMultiple(s, formats, DateTimeFormatInfo.GetInstance(provider), style, out result);
13721372
}
13731373

1374-
public static bool TryParseExact(ReadOnlySpan<char> s, [NotNullWhen(true)] string?[]? formats, IFormatProvider? provider, DateTimeStyles style, out DateTime result)
1374+
public static bool TryParseExact(ReadOnlySpan<char> s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string?[]? formats, IFormatProvider? provider, DateTimeStyles style, out DateTime result)
13751375
{
13761376
DateTimeFormatInfo.ValidateStyles(style);
13771377
return DateTimeParse.TryParseExactMultiple(s, formats, DateTimeFormatInfo.GetInstance(provider), style, out result);

0 commit comments

Comments
 (0)