Skip to content

Commit 3763eee

Browse files
authored
Merge pull request #173 from CommunityToolkit/dev/remove-obsolete-apis
Remove obsolete APIs
2 parents 460ebc9 + aea8962 commit 3763eee

File tree

3 files changed

+6
-97
lines changed

3 files changed

+6
-97
lines changed

CommunityToolkit.Common/Extensions/StringExtensions.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
65
using System.Diagnostics.CodeAnalysis;
76
using System.Globalization;
87
using System.Net;
@@ -140,24 +139,6 @@ public static string FixHtml(this string html)
140139
/// <returns>Truncated string.</returns>
141140
public static string Truncate(this string? value, int length) => Truncate(value, length, false);
142141

143-
/// <summary>
144-
/// Provide better linking for resourced strings.
145-
/// </summary>
146-
/// <param name="format">The format of the string being linked.</param>
147-
/// <param name="args">The object which will receive the linked String.</param>
148-
/// <returns>Truncated string.</returns>
149-
[Obsolete("This method will be removed in a future version of the Toolkit. Use the native C# string interpolation syntax instead, see: https://docs.microsoft.com/dotnet/csharp/language-reference/tokens/interpolated")]
150-
public static string AsFormat(this string format, params object[] args)
151-
{
152-
// Note: this extension was originally added to help developers using {x:Bind} in XAML, but
153-
// due to a known limitation in the UWP/WinUI XAML compiler, using either this method or the
154-
// standard string.Format method from the BCL directly doesn't always work. Since this method
155-
// doesn't actually provide any benefit over the built-in one, it has been marked as obsolete.
156-
// For more details, see the WinUI issue on the XAML compiler limitation here:
157-
// https://github.com/microsoft/microsoft-ui-xaml/issues/2654.
158-
return string.Format(format, args);
159-
}
160-
161142
/// <summary>
162143
/// Truncates a string to the specified length.
163144
/// </summary>

CommunityToolkit.Diagnostics/Guard.String.cs

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,6 @@ public static void IsNullOrWhiteSpace(string? text, [CallerArgumentExpression("t
6565
ThrowHelper.ThrowArgumentExceptionForIsNullOrWhiteSpace(text, name);
6666
}
6767

68-
/// <summary>
69-
/// Asserts that the input <see cref="string"/> instance must be <see langword="null"/> or whitespace.
70-
/// </summary>
71-
/// <param name="text">The input <see cref="string"/> instance to test.</param>
72-
/// <param name="name">The name of the input parameter being tested.</param>
73-
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
74-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
75-
[Obsolete("Use " + nameof(IsNullOrWhiteSpace))]
76-
public static void IsNullOrWhitespace(string? text, [CallerArgumentExpression("text")] string name = "")
77-
{
78-
if (string.IsNullOrWhiteSpace(text))
79-
{
80-
return;
81-
}
82-
83-
ThrowHelper.ThrowArgumentExceptionForIsNullOrWhiteSpace(text, name);
84-
}
85-
8668
/// <summary>
8769
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
8870
/// </summary>
@@ -101,24 +83,6 @@ public static void IsNotNullOrWhiteSpace([NotNull] string? text, [CallerArgument
10183
ThrowHelper.ThrowArgumentExceptionForIsNotNullOrWhiteSpace(text, name);
10284
}
10385

104-
/// <summary>
105-
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
106-
/// </summary>
107-
/// <param name="text">The input <see cref="string"/> instance to test.</param>
108-
/// <param name="name">The name of the input parameter being tested.</param>
109-
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
110-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
111-
[Obsolete("Use " + nameof(IsNotNullOrWhiteSpace))]
112-
public static void IsNotNullOrWhitespace([NotNull] string? text, [CallerArgumentExpression("text")] string name = "")
113-
{
114-
if (!string.IsNullOrWhiteSpace(text))
115-
{
116-
return;
117-
}
118-
119-
ThrowHelper.ThrowArgumentExceptionForIsNotNullOrWhiteSpace(text, name);
120-
}
121-
12286
/// <summary>
12387
/// Asserts that the input <see cref="string"/> instance must be empty.
12488
/// </summary>
@@ -150,7 +114,7 @@ public static void IsNotEmpty(string text, [CallerArgumentExpression("text")] st
150114
return;
151115
}
152116

153-
ThrowHelper.ThrowArgumentExceptionForIsNotEmpty(text, name);
117+
ThrowHelper.ThrowArgumentExceptionForIsNotEmpty(name);
154118
}
155119

156120
/// <summary>
@@ -170,24 +134,6 @@ public static void IsWhiteSpace(string text, [CallerArgumentExpression("text")]
170134
ThrowHelper.ThrowArgumentExceptionForIsWhiteSpace(text, name);
171135
}
172136

173-
/// <summary>
174-
/// Asserts that the input <see cref="string"/> instance must be whitespace.
175-
/// </summary>
176-
/// <param name="text">The input <see cref="string"/> instance to test.</param>
177-
/// <param name="name">The name of the input parameter being tested.</param>
178-
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
179-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
180-
[Obsolete("Use " + nameof(IsWhiteSpace))]
181-
public static void IsWhitespace(string text, [CallerArgumentExpression("text")] string name = "")
182-
{
183-
if (string.IsNullOrWhiteSpace(text))
184-
{
185-
return;
186-
}
187-
188-
ThrowHelper.ThrowArgumentExceptionForIsWhiteSpace(text, name);
189-
}
190-
191137
/// <summary>
192138
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
193139
/// </summary>
@@ -205,24 +151,6 @@ public static void IsNotWhiteSpace(string text, [CallerArgumentExpression("text"
205151
ThrowHelper.ThrowArgumentExceptionForIsNotWhiteSpace(text, name);
206152
}
207153

208-
/// <summary>
209-
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
210-
/// </summary>
211-
/// <param name="text">The input <see cref="string"/> instance to test.</param>
212-
/// <param name="name">The name of the input parameter being tested.</param>
213-
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
214-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
215-
[Obsolete("Use " + nameof(IsNotWhiteSpace))]
216-
public static void IsNotWhitespace(string text, [CallerArgumentExpression("text")] string name = "")
217-
{
218-
if (!string.IsNullOrWhiteSpace(text))
219-
{
220-
return;
221-
}
222-
223-
ThrowHelper.ThrowArgumentExceptionForIsNotWhiteSpace(text, name);
224-
}
225-
226154
/// <summary>
227155
/// Asserts that the input <see cref="string"/> instance must have a size of a specified value.
228156
/// </summary>

CommunityToolkit.Diagnostics/Internals/Guard.String.ThrowHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static Exception GetException(string? text, string name)
4444
}
4545

4646
/// <summary>
47-
/// Throws an <see cref="ArgumentException"/> when <see cref="IsNullOrWhitespace"/> fails.
47+
/// Throws an <see cref="ArgumentException"/> when <see cref="IsNullOrWhiteSpace"/> fails.
4848
/// </summary>
4949
[DoesNotReturn]
5050
public static void ThrowArgumentExceptionForIsNullOrWhiteSpace(string? text, string name)
@@ -53,7 +53,7 @@ public static void ThrowArgumentExceptionForIsNullOrWhiteSpace(string? text, str
5353
}
5454

5555
/// <summary>
56-
/// Throws an <see cref="ArgumentException"/> when <see cref="IsNotNullOrWhitespace"/> fails.
56+
/// Throws an <see cref="ArgumentException"/> when <see cref="IsNotNullOrWhiteSpace"/> fails.
5757
/// </summary>
5858
[DoesNotReturn]
5959
public static void ThrowArgumentExceptionForIsNotNullOrWhiteSpace(string? text, string name)
@@ -85,13 +85,13 @@ public static void ThrowArgumentExceptionForIsEmpty(string text, string name)
8585
/// Throws an <see cref="ArgumentException"/> when <see cref="IsNotEmpty"/> fails.
8686
/// </summary>
8787
[DoesNotReturn]
88-
public static void ThrowArgumentExceptionForIsNotEmpty(string text, string name)
88+
public static void ThrowArgumentExceptionForIsNotEmpty(string name)
8989
{
9090
throw new ArgumentException($"Parameter {AssertString(name)} (string) must not be empty.", name);
9191
}
9292

9393
/// <summary>
94-
/// Throws an <see cref="ArgumentException"/> when <see cref="IsWhitespace"/> fails.
94+
/// Throws an <see cref="ArgumentException"/> when <see cref="IsWhiteSpace"/> fails.
9595
/// </summary>
9696
[DoesNotReturn]
9797
public static void ThrowArgumentExceptionForIsWhiteSpace(string text, string name)
@@ -100,7 +100,7 @@ public static void ThrowArgumentExceptionForIsWhiteSpace(string text, string nam
100100
}
101101

102102
/// <summary>
103-
/// Throws an <see cref="ArgumentException"/> when <see cref="IsNotWhitespace"/> fails.
103+
/// Throws an <see cref="ArgumentException"/> when <see cref="IsNotWhiteSpace"/> fails.
104104
/// </summary>
105105
[DoesNotReturn]
106106
public static void ThrowArgumentExceptionForIsNotWhiteSpace(string text, string name)

0 commit comments

Comments
 (0)