Skip to content

Commit e3913cc

Browse files
Add [Obsolete] for deprecated APIs
1 parent c0b91ca commit e3913cc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Abstractions/src/Asp.Versioning.Abstractions/netstandard2.0/AmbiguousApiVersionException.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Asp.Versioning;
44

5+
using System.ComponentModel;
56
using System.Runtime.Serialization;
67

78
/// <content>
@@ -10,11 +11,23 @@ namespace Asp.Versioning;
1011
[Serializable]
1112
public partial class AmbiguousApiVersionException : Exception
1213
{
14+
private const string LegacyFormatterImplMessage = "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.";
15+
#if NET
16+
private const string LegacyFormatterImplDiagId = "SYSLIB0051";
17+
private const string SharedUrlFormat = "https://aka.ms/dotnet-warnings/{0}";
18+
#endif
19+
1320
/// <summary>
1421
/// Initializes a new instance of the <see cref="AmbiguousApiVersionException"/> class.
1522
/// </summary>
1623
/// <param name="info">The <see cref="SerializationInfo">serialization info</see> the exception is being deserialized with.</param>
1724
/// <param name="context">The <see cref="StreamingContext">streaming context</see> the exception is being deserialized from.</param>
25+
#if NET
26+
[Obsolete( LegacyFormatterImplMessage, DiagnosticId = LegacyFormatterImplDiagId, UrlFormat = SharedUrlFormat )]
27+
#else
28+
[Obsolete( LegacyFormatterImplMessage )]
29+
#endif
30+
[EditorBrowsable( EditorBrowsableState.Never )]
1831
protected AmbiguousApiVersionException( SerializationInfo info, StreamingContext context )
1932
: base( info, context ) => apiVersions = (string[]) info.GetValue( nameof( apiVersions ), typeof( string[] ) )!;
2033

@@ -23,6 +36,10 @@ protected AmbiguousApiVersionException( SerializationInfo info, StreamingContext
2336
/// </summary>
2437
/// <param name="info">The <see cref="SerializationInfo">serialization info</see> the exception is being serialized with.</param>
2538
/// <param name="context">The <see cref="StreamingContext">streaming context</see> the exception is being serialized in.</param>
39+
#if NET
40+
[Obsolete( LegacyFormatterImplMessage, DiagnosticId = LegacyFormatterImplDiagId, UrlFormat = SharedUrlFormat )]
41+
#endif
42+
[EditorBrowsable( EditorBrowsableState.Never )]
2643
public override void GetObjectData( SerializationInfo info, StreamingContext context )
2744
{
2845
base.GetObjectData( info, context );

0 commit comments

Comments
 (0)