Skip to content

Commit 13e3ca7

Browse files
De-conflict with new JSON obsoletion codes
- Also improve obsoletion messages
1 parent 63e0dd6 commit 13e3ca7

File tree

95 files changed

+451
-451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+451
-451
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@
442442
<!-- Warnings that should be disabled in our test projects. -->
443443
<PropertyGroup Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsPublishedAppTestProject)' == 'true'">
444444
<!-- don't warn on usage of BinaryFormatter and legacy formatter infrastructure from test projects -->
445-
<NoWarn>$(NoWarn);SYSLIB0011;SYSLIB0049;SYSLIB0050</NoWarn>
445+
<NoWarn>$(NoWarn);SYSLIB0011;SYSLIB0050;SYSLIB0051</NoWarn>
446446
<!-- don't warn about unnecessary trim warning suppressions. can be removed with preview 6. -->
447447
<NoWarn>$(NoWarn);IL2121</NoWarn>
448448
<!-- allow nullable annotated files to be incorporated into tests without warning -->

docs/project/list-of-diagnostics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
104104
| __`SYSLIB0047`__ | XmlSecureResolver is obsolete. Use XmlResolver.ThrowingResolver instead when attempting to forbid XML external entity resolution. |
105105
| __`SYSLIB0048`__ | RSA.EncryptValue and DecryptValue are not supported and throw NotSupportedException. Use RSA.Encrypt and RSA.Decrypt instead. |
106106
| __`SYSLIB0049`__ | JsonSerializerOptions.AddContext is obsolete. To register a JsonSerializerContext, use either the TypeInfoResolver or TypeInfoResolverChain properties. |
107-
| __`SYSLIB0049`__ | Legacy formatter-based serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information. |
108-
| __`SYSLIB0050`__ | (reserved) |
107+
| __`SYSLIB0050`__ | Legacy formatter-based serialization is obsolete and should not be used. |
108+
| __`SYSLIB0051`__ | This API supports legacy formatter-based serialization. It should not be called or extended by application code. |
109109

110110
## Analyzer Warnings
111111

src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ partial void RestoreRemoteStackTrace(SerializationInfo info, StreamingContext co
2424
_watsonBuckets = (byte[]?)info.GetValueNoThrow("WatsonBuckets", typeof(byte[])); // Do not rename (binary serialization)
2525

2626
// If we are constructing a new exception after a cross-appdomain call...
27-
#pragma warning disable SYSLIB0049 // StreamingContextStates is obsolete
27+
#pragma warning disable SYSLIB0050 // StreamingContextStates is obsolete
2828
if (context.State == StreamingContextStates.CrossAppDomain)
29-
#pragma warning restore SYSLIB0049
29+
#pragma warning restore SYSLIB0050
3030
{
3131
// ...this new exception may get thrown. It is logically a re-throw, but
3232
// physically a brand-new exception. Since the stack trace is cleared

src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,13 +1604,13 @@ internal static void GetCustomAttributes(RuntimeType type, RuntimeType caType, r
16041604
if (!all && !s_pca.Contains(caType))
16051605
return;
16061606

1607-
#pragma warning disable SYSLIB0049 // Legacy serialization infrastructure is obsolete
1607+
#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete
16081608
if (all || caType == typeof(SerializableAttribute))
16091609
{
16101610
if ((type.Attributes & TypeAttributes.Serializable) != 0)
16111611
pcas.Add(new SerializableAttribute());
16121612
}
1613-
#pragma warning restore SYSLIB0049
1613+
#pragma warning restore SYSLIB0050
16141614
if (all || caType == typeof(ComImportAttribute))
16151615
{
16161616
if ((type.Attributes & TypeAttributes.Import) != 0)
@@ -1623,13 +1623,13 @@ internal static bool IsDefined(RuntimeType type, RuntimeType? caType)
16231623
if (!all && !s_pca.Contains(caType!))
16241624
return false;
16251625

1626-
#pragma warning disable SYSLIB0049 // Legacy serialization infrastructure is obsolete
1626+
#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete
16271627
if (all || caType == typeof(SerializableAttribute))
16281628
{
16291629
if ((type.Attributes & TypeAttributes.Serializable) != 0)
16301630
return true;
16311631
}
1632-
#pragma warning restore SYSLIB0049
1632+
#pragma warning restore SYSLIB0050
16331633
if (all || caType == typeof(ComImportAttribute))
16341634
{
16351635
if ((type.Attributes & TypeAttributes.Import) != 0)
@@ -1756,13 +1756,13 @@ internal static void GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caT
17561756
pca = GetFieldOffsetCustomAttribute(field);
17571757
if (pca is not null) pcas.Add(pca);
17581758
}
1759-
#pragma warning disable SYSLIB0049 // Legacy serialization infrastructure is obsolete
1759+
#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete
17601760
if (all || caType == typeof(NonSerializedAttribute))
17611761
{
17621762
if ((field.Attributes & FieldAttributes.NotSerialized) != 0)
17631763
pcas.Add(new NonSerializedAttribute());
17641764
}
1765-
#pragma warning restore SYSLIB0049
1765+
#pragma warning restore SYSLIB0050
17661766
}
17671767
internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType? caType)
17681768
{
@@ -1778,13 +1778,13 @@ internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType? caType)
17781778
{
17791779
if (GetFieldOffsetCustomAttribute(field) is not null) return true;
17801780
}
1781-
#pragma warning disable SYSLIB0049 // Legacy serialization infrastructure is obsolete
1781+
#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete
17821782
if (all || caType == typeof(NonSerializedAttribute))
17831783
{
17841784
if ((field.Attributes & FieldAttributes.NotSerialized) != 0)
17851785
return true;
17861786
}
1787-
#pragma warning restore SYSLIB0049
1787+
#pragma warning restore SYSLIB0050
17881788

17891789
return false;
17901790
}

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ public sealed override IEnumerable<CustomAttributeData> CustomAttributes
6363
}
6464

6565
FieldAttributes attributes = Attributes;
66-
#pragma warning disable SYSLIB0049 // Legacy serialization infrastructure is obsolete
66+
#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete
6767
if (0 != (attributes & FieldAttributes.NotSerialized))
6868
{
6969
yield return new RuntimePseudoCustomAttributeData(typeof(NonSerializedAttribute), null);
7070
}
71-
#pragma warning restore SYSLIB0049
71+
#pragma warning restore SYSLIB0050
7272
}
7373
}
7474

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeArrayTypeInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public sealed override int GetArrayRank()
4141
protected sealed override TypeAttributes GetAttributeFlagsImpl()
4242
{
4343
TypeAttributes attrs = TypeAttributes.AutoLayout | TypeAttributes.AnsiClass | TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed;
44-
#pragma warning disable SYSLIB0049 // Legacy serialization infrastructure is obsolete
44+
#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete
4545
attrs |= TypeAttributes.Serializable;
46-
#pragma warning restore SYSLIB0049
46+
#pragma warning restore SYSLIB0050
4747
return attrs;
4848
}
4949

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeNamedTypeInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public sealed override IEnumerable<CustomAttributeData> CustomAttributes
4242
if (0 != (attributes & TypeAttributes.Import))
4343
yield return new RuntimePseudoCustomAttributeData(typeof(ComImportAttribute), null);
4444

45-
#pragma warning disable SYSLIB0049 // Legacy serialization infrastructure is obsolete
45+
#pragma warning disable SYSLIB0050 // Legacy serialization infrastructure is obsolete
4646
if (0 != (attributes & TypeAttributes.Serializable))
4747
yield return new RuntimePseudoCustomAttributeData(typeof(SerializableAttribute), null);
48-
#pragma warning restore SYSLIB0049
48+
#pragma warning restore SYSLIB0050
4949
}
5050
}
5151

src/libraries/Common/src/System/Obsoletions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ internal static class Obsoletions
160160
internal const string JsonSerializerOptionsAddContextMessage = "JsonSerializerOptions.AddContext is obsolete. To register a JsonSerializerContext, use either the TypeInfoResolver or TypeInfoResolverChain properties.";
161161
internal const string JsonSerializerOptionsAddContextDiagId = "SYSLIB0049";
162162

163-
internal const string LegacyFormatterMessage = "Legacy formatter-based serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.";
164-
internal const string LegacyFormatterDiagId = "SYSLIB0049";
163+
internal const string LegacyFormatterMessage = "Legacy formatter-based serialization is obsolete and should not be used.";
164+
internal const string LegacyFormatterDiagId = "SYSLIB0050";
165165

166-
internal const string LegacyFormatterImplMessage = "Legacy formatter-based serialization (IMPL) is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.";
167-
internal const string LegacyFormatterImplDiagId = "SYSLIB0050";
166+
internal const string LegacyFormatterImplMessage = "This API supports legacy formatter-based serialization. It should not be called or extended by application code.";
167+
internal const string LegacyFormatterImplDiagId = "SYSLIB0051";
168168
}
169169
}

src/libraries/Common/tests/System/MockType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ internal class MockType : Type
8787
public override bool IsSecuritySafeCritical => throw Unexpected;
8888
public override bool IsSecurityTransparent => throw Unexpected;
8989
#if NET8_0_OR_GREATER
90-
[Obsolete("Legacy formatter-based serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0049", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
90+
[Obsolete("Legacy formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
9191
#endif
9292
public override bool IsSerializable => throw Unexpected;
9393
public override bool IsSubclassOf(Type c) => throw Unexpected;

src/libraries/Microsoft.CSharp/ref/Microsoft.CSharp.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public enum CSharpBinderFlags
6868
public partial class RuntimeBinderException : System.Exception
6969
{
7070
public RuntimeBinderException() { }
71-
[System.ObsoleteAttribute("Legacy formatter-based serialization (IMPL) is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
71+
[System.ObsoleteAttribute("This API supports legacy formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
7272
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
7373
protected RuntimeBinderException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
7474
public RuntimeBinderException(string? message) { }
@@ -77,7 +77,7 @@ public RuntimeBinderException(string? message, System.Exception? innerException)
7777
public partial class RuntimeBinderInternalCompilerException : System.Exception
7878
{
7979
public RuntimeBinderInternalCompilerException() { }
80-
[System.ObsoleteAttribute("Legacy formatter-based serialization (IMPL) is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
80+
[System.ObsoleteAttribute("This API supports legacy formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
8181
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
8282
protected RuntimeBinderInternalCompilerException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
8383
public RuntimeBinderInternalCompilerException(string? message) { }

0 commit comments

Comments
 (0)