Skip to content

Commit f036ca8

Browse files
authored
Add more StringSyntaxAttrbute syntaxes (#44663)
1 parent bc9255b commit f036ca8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Components/Components/src/BindConverter.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private static string FormatDecimalValueCore(decimal value, CultureInfo? culture
335335
/// </param>
336336
/// <returns>The formatted value.</returns>
337337
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
338-
public static string FormatValue(DateTime value, string format, CultureInfo? culture = null) => FormatDateTimeValueCore(value, format, culture);
338+
public static string FormatValue(DateTime value, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, CultureInfo? culture = null) => FormatDateTimeValueCore(value, format, culture);
339339

340340
private static string FormatDateTimeValueCore(DateTime value, string? format, CultureInfo? culture)
341341
{
@@ -373,7 +373,7 @@ private static string FormatDateTimeValueCore(DateTime value, CultureInfo? cultu
373373
/// </param>
374374
/// <returns>The formatted value.</returns>
375375
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
376-
public static string? FormatValue(DateTime? value, string? format, CultureInfo? culture = null) => FormatNullableDateTimeValueCore(value, format, culture);
376+
public static string? FormatValue(DateTime? value, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string? format, CultureInfo? culture = null) => FormatNullableDateTimeValueCore(value, format, culture);
377377

378378
private static string? FormatNullableDateTimeValueCore(DateTime? value, string? format, CultureInfo? culture)
379379
{
@@ -507,7 +507,7 @@ private static string FormatDateTimeOffsetValueCore(DateTimeOffset value, Cultur
507507
/// </param>
508508
/// <returns>The formatted value.</returns>
509509
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
510-
public static string FormatValue(DateOnly value, string format, CultureInfo? culture = null) => FormatDateOnlyValueCore(value, format, culture);
510+
public static string FormatValue(DateOnly value, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, CultureInfo? culture = null) => FormatDateOnlyValueCore(value, format, culture);
511511

512512
private static string FormatDateOnlyValueCore(DateOnly value, string? format, CultureInfo? culture)
513513
{
@@ -546,7 +546,7 @@ private static string FormatDateOnlyValueCore(DateOnly value, CultureInfo? cultu
546546
/// </param>
547547
/// <returns>The formatted value.</returns>
548548
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
549-
public static string? FormatValue(DateOnly? value, string format, CultureInfo? culture = null) => FormatNullableDateOnlyValueCore(value, format, culture);
549+
public static string? FormatValue(DateOnly? value, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, CultureInfo? culture = null) => FormatNullableDateOnlyValueCore(value, format, culture);
550550

551551
private static string? FormatNullableDateOnlyValueCore(DateOnly? value, string? format, CultureInfo? culture)
552552
{
@@ -595,7 +595,7 @@ private static string FormatDateOnlyValueCore(DateOnly value, CultureInfo? cultu
595595
/// </param>
596596
/// <returns>The formatted value.</returns>
597597
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
598-
public static string FormatValue(TimeOnly value, string format, CultureInfo? culture = null) => FormatTimeOnlyValueCore(value, format, culture);
598+
public static string FormatValue(TimeOnly value, [StringSyntax(StringSyntaxAttribute.TimeOnlyFormat)] string format, CultureInfo? culture = null) => FormatTimeOnlyValueCore(value, format, culture);
599599

600600
private static string FormatTimeOnlyValueCore(TimeOnly value, string? format, CultureInfo? culture)
601601
{
@@ -634,7 +634,7 @@ private static string FormatTimeOnlyValueCore(TimeOnly value, CultureInfo? cultu
634634
/// </param>
635635
/// <returns>The formatted value.</returns>
636636
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
637-
public static string? FormatValue(TimeOnly? value, string format, CultureInfo? culture = null) => FormatNullableTimeOnlyValueCore(value, format, culture);
637+
public static string? FormatValue(TimeOnly? value, [StringSyntax(StringSyntaxAttribute.TimeOnlyFormat)] string format, CultureInfo? culture = null) => FormatNullableTimeOnlyValueCore(value, format, culture);
638638

639639
private static string? FormatNullableTimeOnlyValueCore(TimeOnly? value, string? format, CultureInfo? culture)
640640
{
@@ -1183,7 +1183,7 @@ public static bool TryConvertToDateTime(object? obj, CultureInfo? culture, out D
11831183
/// <param name="format">The format string to use in conversion.</param>
11841184
/// <param name="value">The converted value.</param>
11851185
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
1186-
public static bool TryConvertToDateTime(object? obj, CultureInfo? culture, string format, out DateTime value)
1186+
public static bool TryConvertToDateTime(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, out DateTime value)
11871187
{
11881188
return ConvertToDateTimeCore(obj, culture, format, out value);
11891189
}
@@ -1208,7 +1208,7 @@ public static bool TryConvertToNullableDateTime(object? obj, CultureInfo? cultur
12081208
/// <param name="format">The format string to use in conversion.</param>
12091209
/// <param name="value">The converted value.</param>
12101210
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
1211-
public static bool TryConvertToNullableDateTime(object? obj, CultureInfo? culture, string format, out DateTime? value)
1211+
public static bool TryConvertToNullableDateTime(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, out DateTime? value)
12121212
{
12131213
return ConvertToNullableDateTimeCore(obj, culture, format, out value);
12141214
}
@@ -1409,7 +1409,7 @@ public static bool TryConvertToDateOnly(object? obj, CultureInfo? culture, out D
14091409
/// <param name="format">The format string to use in conversion.</param>
14101410
/// <param name="value">The converted value.</param>
14111411
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
1412-
public static bool TryConvertToDateOnly(object? obj, CultureInfo? culture, string format, out DateOnly value)
1412+
public static bool TryConvertToDateOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, out DateOnly value)
14131413
{
14141414
return ConvertToDateOnlyCore(obj, culture, format, out value);
14151415
}
@@ -1434,7 +1434,7 @@ public static bool TryConvertToNullableDateOnly(object? obj, CultureInfo? cultur
14341434
/// <param name="format">The format string to use in conversion.</param>
14351435
/// <param name="value">The converted value.</param>
14361436
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
1437-
public static bool TryConvertToNullableDateOnly(object? obj, CultureInfo? culture, string format, out DateOnly? value)
1437+
public static bool TryConvertToNullableDateOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, out DateOnly? value)
14381438
{
14391439
return ConvertToNullableDateOnlyCore(obj, culture, format, out value);
14401440
}
@@ -1500,7 +1500,7 @@ public static bool TryConvertToTimeOnly(object? obj, CultureInfo? culture, out T
15001500
/// <param name="format">The format string to use in conversion.</param>
15011501
/// <param name="value">The converted value.</param>
15021502
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
1503-
public static bool TryConvertToTimeOnly(object? obj, CultureInfo? culture, string format, out TimeOnly value)
1503+
public static bool TryConvertToTimeOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.TimeOnlyFormat)] string format, out TimeOnly value)
15041504
{
15051505
return ConvertToTimeOnlyCore(obj, culture, format, out value);
15061506
}
@@ -1525,7 +1525,7 @@ public static bool TryConvertToNullableTimeOnly(object? obj, CultureInfo? cultur
15251525
/// <param name="format">The format string to use in conversion.</param>
15261526
/// <param name="value">The converted value.</param>
15271527
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
1528-
public static bool TryConvertToNullableTimeOnly(object? obj, CultureInfo? culture, string format, out TimeOnly? value)
1528+
public static bool TryConvertToNullableTimeOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.TimeOnlyFormat)] string format, out TimeOnly? value)
15291529
{
15301530
return ConvertToNullableTimeOnlyCore(obj, culture, format, out value);
15311531
}

0 commit comments

Comments
 (0)