diff --git a/src/libraries/Common/src/System/Obsoletions.cs b/src/libraries/Common/src/System/Obsoletions.cs index 45decebe154745..1b409c7628f3cc 100644 --- a/src/libraries/Common/src/System/Obsoletions.cs +++ b/src/libraries/Common/src/System/Obsoletions.cs @@ -43,6 +43,9 @@ internal static class Obsoletions internal const string CodeBaseMessage = "Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead."; internal const string CodeBaseDiagId = "SYSLIB0012"; + internal const string EscapeUriStringMessage = "Uri.EscapeUriString can corrupt the Uri string in some cases. Consider using Uri.EscapeDataString for query string components instead."; + internal const string EscapeUriStringDiagId = "SYSLIB0013"; + internal const string WebRequestMessage = "Use HttpClient instead."; internal const string WebRequestDiagId = "SYSLIB0014"; } diff --git a/src/libraries/System.Private.Uri/src/System.Private.Uri.csproj b/src/libraries/System.Private.Uri/src/System.Private.Uri.csproj index 731f081a11eb9c..df8a1db87995b4 100644 --- a/src/libraries/System.Private.Uri/src/System.Private.Uri.csproj +++ b/src/libraries/System.Private.Uri/src/System.Private.Uri.csproj @@ -9,6 +9,8 @@ Link="Common\System\Collections\Generic\ArrayBuilder.cs" /> + diff --git a/src/libraries/System.Private.Uri/src/System/Uri.cs b/src/libraries/System.Private.Uri/src/System/Uri.cs index 754ac60bf5b87b..3b4cb458127578 100644 --- a/src/libraries/System.Private.Uri/src/System/Uri.cs +++ b/src/libraries/System.Private.Uri/src/System/Uri.cs @@ -5190,7 +5190,7 @@ protected virtual string Unescape(string path) return new string(dest, 0, count); } - [Obsolete("The method has been deprecated. Please use GetComponents() or static EscapeUriString() to escape a Uri component or a string. https://go.microsoft.com/fwlink/?linkid=14202")] + [Obsolete("The method has been deprecated. Please use GetComponents() or static EscapeDataString() to escape a Uri component or a string. https://go.microsoft.com/fwlink/?linkid=14202")] protected static string EscapeString(string? str) => str is null ? string.Empty : UriHelper.EscapeString(str, checkExistingEscaped: true, UriHelper.UnreservedReservedTable, '?', '#'); diff --git a/src/libraries/System.Private.Uri/src/System/UriExt.cs b/src/libraries/System.Private.Uri/src/System/UriExt.cs index ff74af22a9bd94..1491d0715c98e6 100644 --- a/src/libraries/System.Private.Uri/src/System/UriExt.cs +++ b/src/libraries/System.Private.Uri/src/System/UriExt.cs @@ -548,6 +548,7 @@ public static string UnescapeDataString(string stringToUnescape) // Where stringToEscape is intended to be a completely unescaped URI string. // This method will escape any character that is not a reserved or unreserved character, including percent signs. + [Obsolete(Obsoletions.EscapeUriStringMessage, DiagnosticId = Obsoletions.EscapeUriStringDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static string EscapeUriString(string stringToEscape) => UriHelper.EscapeString(stringToEscape, checkExistingEscaped: false, UriHelper.UnreservedReservedTable); diff --git a/src/libraries/System.Private.Uri/tests/FunctionalTests/System.Private.Uri.Functional.Tests.csproj b/src/libraries/System.Private.Uri/tests/FunctionalTests/System.Private.Uri.Functional.Tests.csproj index 0a9b7602b60dd4..4aa4be66cd6a76 100644 --- a/src/libraries/System.Private.Uri/tests/FunctionalTests/System.Private.Uri.Functional.Tests.csproj +++ b/src/libraries/System.Private.Uri/tests/FunctionalTests/System.Private.Uri.Functional.Tests.csproj @@ -1,6 +1,7 @@ $(NetCoreAppCurrent) + $(NoWarn),SYSLIB0013 @@ -26,4 +27,4 @@ - \ No newline at end of file + diff --git a/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj b/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj index 8db00f6e9dd484..3d22e60dfd35c5 100644 --- a/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj +++ b/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj @@ -5,6 +5,7 @@ false true + $(NoWarn),SYSLIB0013 true true $(NetCoreAppCurrent)-Windows_NT + $(NoWarn),SYSLIB0013 true - $(NoWarn),1718 + $(NoWarn),1718,SYSLIB0013 true true $(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser