Skip to content

Commit 5b18897

Browse files
committed
Add diagid to obsoleted APIs
1 parent fd24341 commit 5b18897

File tree

14 files changed

+55
-44
lines changed

14 files changed

+55
-44
lines changed

src/Servers/Connections.Abstractions/src/Features/ITlsHandshakeFeature.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Security.Authentication;
55
using System.Security.Cryptography;
66
using System;
7+
using Microsoft.AspNetCore.Shared;
8+
79
#if NETCOREAPP
810
using System.Net.Security;
911
#endif
@@ -37,47 +39,47 @@ public interface ITlsHandshakeFeature
3739
/// Gets the <see cref="CipherAlgorithmType"/>.
3840
/// </summary>
3941
#if NETCOREAPP
40-
[Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties of ITlsHandshakeFeature are obsolete. Use NegotiatedCipherSuite instead.")]
42+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
4143
#endif
4244
CipherAlgorithmType CipherAlgorithm { get; }
4345

4446
/// <summary>
4547
/// Gets the cipher strength.
4648
/// </summary>
4749
#if NETCOREAPP
48-
[Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties of ITlsHandshakeFeature are obsolete. Use NegotiatedCipherSuite instead.")]
50+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
4951
#endif
5052
int CipherStrength { get; }
5153

5254
/// <summary>
5355
/// Gets the <see cref="HashAlgorithmType"/>.
5456
/// </summary>
5557
#if NETCOREAPP
56-
[Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties of ITlsHandshakeFeature are obsolete. Use NegotiatedCipherSuite instead.")]
58+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
5759
#endif
5860
HashAlgorithmType HashAlgorithm { get; }
5961

6062
/// <summary>
6163
/// Gets the hash strength.
6264
/// </summary>
6365
#if NETCOREAPP
64-
[Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties of ITlsHandshakeFeature are obsolete. Use NegotiatedCipherSuite instead.")]
66+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
6567
#endif
6668
int HashStrength { get; }
6769

6870
/// <summary>
6971
/// Gets the <see cref="ExchangeAlgorithmType"/>.
7072
/// </summary>
7173
#if NETCOREAPP
72-
[Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherStrength, HashAlgorithm and HashStrength properties of ITlsHandshakeFeature are obsolete. Use NegotiatedCipherSuite instead.")]
74+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
7375
#endif
7476
ExchangeAlgorithmType KeyExchangeAlgorithm { get; }
7577

7678
/// <summary>
7779
/// Gets the key exchange algorithm strength.
7880
/// </summary>
7981
#if NETCOREAPP
80-
[Obsolete("KeyExchangeAlgorithm, KeyExchangeStrength, CipherAlgorithm, CipherAlgorithmStrength, HashAlgorithm and HashStrength properties of ITlsHandshakeFeature are obsolete. Use NegotiatedCipherSuite instead.")]
82+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
8183
#endif
8284
int KeyExchangeStrength { get; }
8385
}

src/Servers/Connections.Abstractions/src/Microsoft.AspNetCore.Connections.Abstractions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<Compile Include="$(SharedSourceRoot)Debugger\DictionaryDebugView.cs" LinkBase="Shared" />
2323
<Compile Include="$(SharedSourceRoot)Debugger\DictionaryItemDebugView.cs" LinkBase="Shared" />
2424
<Compile Include="$(SharedSourceRoot)TrimmingAttributes.cs" LinkBase="Shared" />
25+
<Compile Include="$(SharedSourceRoot)Obsoletions.cs" LinkBase="Shared" />
2526
</ItemGroup>
2627

2728
<ItemGroup>

src/Servers/HttpSys/src/Microsoft.AspNetCore.Server.HttpSys.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<Compile Include="$(SharedSourceRoot)ServerInfrastructure\StringUtilities.cs" LinkBase="ServerInfrastructure\StringUtilities.cs" />
2929
<Compile Include="$(SharedSourceRoot)ServerInfrastructure\HttpCharacters.cs" LinkBase="ServerInfrastructure\HttpCharacters.cs" />
3030
<Compile Include="$(SharedSourceRoot)TaskToApm.cs" />
31+
<Compile Include="$(SharedSourceRoot)Obsoletions.cs" Link="Shared\Obsoletions.cs" />
3132
<Compile Include="$(SharedSourceRoot)Debugger\DictionaryItemDebugView.cs" LinkBase="Shared" />
3233
<Compile Include="$(SharedSourceRoot)Debugger\StringValuesDictionaryDebugView.cs" LinkBase="Shared" />
3334
<Compile Include="$(SharedSourceRoot)PathNormalizer\**\*.cs" LinkBase="RequestProcessing" />

src/Servers/HttpSys/src/RequestProcessing/Request.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Security.Principal;
1111
using Microsoft.AspNetCore.Http;
1212
using Microsoft.AspNetCore.HttpSys.Internal;
13+
using Microsoft.AspNetCore.Shared;
1314
using Microsoft.Extensions.Logging;
1415
using Microsoft.Extensions.Primitives;
1516
using Microsoft.Net.Http.Headers;
@@ -336,29 +337,28 @@ private AspNetCore.HttpSys.Internal.SocketAddress LocalEndPoint
336337

337338
public SslProtocols Protocol { get; private set; }
338339

339-
[Obsolete("Obsolete on SslStream.")]
340+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
340341
public CipherAlgorithmType CipherAlgorithm { get; private set; }
341342

342-
[Obsolete("Obsolete on SslStream.")]
343+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
343344
public int CipherStrength { get; private set; }
344345

345-
[Obsolete("Obsolete on SslStream.")]
346+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
346347
public HashAlgorithmType HashAlgorithm { get; private set; }
347348

348-
[Obsolete("Obsolete on SslStream.")]
349+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
349350
public int HashStrength { get; private set; }
350351

351-
[Obsolete("Obsolete on SslStream.")]
352+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
352353
public ExchangeAlgorithmType KeyExchangeAlgorithm { get; private set; }
353354

354-
[Obsolete("Obsolete on SslStream.")]
355+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
355356
public int KeyExchangeStrength { get; private set; }
356357

357358
private void GetTlsHandshakeResults()
358359
{
359360
var handshake = RequestContext.GetTlsHandshake();
360361
Protocol = (SslProtocols)handshake.Protocol;
361-
#pragma warning disable CS0618 // Type or member is obsolete
362362
#pragma warning disable SYSLIB0058 // Type or member is obsolete
363363
CipherAlgorithm = (CipherAlgorithmType)handshake.CipherType;
364364
CipherStrength = (int)handshake.CipherStrength;
@@ -367,7 +367,6 @@ private void GetTlsHandshakeResults()
367367
KeyExchangeAlgorithm = (ExchangeAlgorithmType)handshake.KeyExchangeType;
368368
KeyExchangeStrength = (int)handshake.KeyExchangeStrength;
369369
#pragma warning restore SYSLIB0058 // Type or member is obsolete
370-
#pragma warning restore CS0618 // Type or member is obsolete
371370

372371
var sni = RequestContext.GetClientSni();
373372
SniHostName = sni.Hostname.ToString();

src/Servers/HttpSys/src/RequestProcessing/RequestContext.FeatureCollection.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ bool IHttpBodyControlFeature.AllowSynchronousIO
592592

593593
SslProtocols ITlsHandshakeFeature.Protocol => Request.Protocol;
594594

595-
#pragma warning disable CS0618 // Type or member is obsolete
596595
#pragma warning disable SYSLIB0058 // Type or member is obsolete
597596
CipherAlgorithmType ITlsHandshakeFeature.CipherAlgorithm => Request.CipherAlgorithm;
598597

@@ -606,7 +605,6 @@ bool IHttpBodyControlFeature.AllowSynchronousIO
606605

607606
int ITlsHandshakeFeature.KeyExchangeStrength => Request.KeyExchangeStrength;
608607
#pragma warning restore SYSLIB0058 // Type or member is obsolete
609-
#pragma warning restore CS0618 // Type or member is obsolete
610608

611609
string ITlsHandshakeFeature.HostName => Request.SniHostName;
612610

src/Servers/HttpSys/test/FunctionalTests/HttpsTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ public async Task Https_ITlsHandshakeFeature_MatchesIHttpSysExtensionInfoFeature
219219
}
220220

221221
// Assert.Equal(tlsFeature.Protocol, tlsCopy.Protocol); // These don't directly match because the native and managed enums use different values.
222-
#pragma warning disable CS0618 // Type or member is obsolete
223222
#pragma warning disable SYSLIB0058 // Type or member is obsolete
224223
Assert.Equal((uint)tlsFeature.CipherAlgorithm, tlsCopy.CipherType);
225224
Assert.Equal(tlsFeature.CipherStrength, (int)tlsCopy.CipherStrength);
@@ -228,7 +227,6 @@ public async Task Https_ITlsHandshakeFeature_MatchesIHttpSysExtensionInfoFeature
228227
Assert.Equal((uint)tlsFeature.KeyExchangeAlgorithm, tlsCopy.KeyExchangeType);
229228
Assert.Equal(tlsFeature.KeyExchangeStrength, (int)tlsCopy.KeyExchangeStrength);
230229
#pragma warning restore SYSLIB0058 // Type or member is obsolete
231-
#pragma warning restore CS0618 // Type or member is obsolete
232230
}
233231
catch (Exception ex)
234232
{

src/Servers/IIS/IIS/src/Core/IISHttpContext.FeatureCollection.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.AspNetCore.Http.Features.Authentication;
1616
using Microsoft.AspNetCore.Server.HttpSys;
1717
using Microsoft.AspNetCore.Server.IIS.Core.IO;
18+
using Microsoft.AspNetCore.Shared;
1819
using Microsoft.AspNetCore.WebUtilities;
1920
using Microsoft.Extensions.Logging;
2021

@@ -409,22 +410,22 @@ unsafe X509Certificate2? ITlsConnectionFeature.ClientCertificate
409410

410411
string ITlsHandshakeFeature.HostName => SniHostName;
411412

412-
[Obsolete("Obsolete on SslStream.")]
413+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
413414
CipherAlgorithmType ITlsHandshakeFeature.CipherAlgorithm => CipherAlgorithm;
414415

415-
[Obsolete("Obsolete on SslStream.")]
416+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
416417
int ITlsHandshakeFeature.CipherStrength => CipherStrength;
417418

418-
[Obsolete("Obsolete on SslStream.")]
419+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
419420
HashAlgorithmType ITlsHandshakeFeature.HashAlgorithm => HashAlgorithm;
420421

421-
[Obsolete("Obsolete on SslStream.")]
422+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
422423
int ITlsHandshakeFeature.HashStrength => HashStrength;
423424

424-
[Obsolete("Obsolete on SslStream.")]
425+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
425426
ExchangeAlgorithmType ITlsHandshakeFeature.KeyExchangeAlgorithm => KeyExchangeAlgorithm;
426427

427-
[Obsolete("Obsolete on SslStream.")]
428+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
428429
int ITlsHandshakeFeature.KeyExchangeStrength => KeyExchangeStrength;
429430

430431
IEnumerator<KeyValuePair<Type, object>> IEnumerable<KeyValuePair<Type, object>>.GetEnumerator() => FastEnumerable().GetEnumerator();

src/Servers/IIS/IIS/src/Core/IISHttpContext.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.AspNetCore.Http.Features;
1919
using Microsoft.AspNetCore.HttpSys.Internal;
2020
using Microsoft.AspNetCore.Server.IIS.Core.IO;
21+
using Microsoft.AspNetCore.Shared;
2122
using Microsoft.AspNetCore.WebUtilities;
2223
using Microsoft.Extensions.Logging;
2324
using Microsoft.Net.Http.Headers;
@@ -118,17 +119,17 @@ internal unsafe IISHttpContext(
118119
public SslProtocols Protocol { get; private set; }
119120
public TlsCipherSuite? NegotiatedCipherSuite { get; private set; }
120121
public string SniHostName { get; private set; } = default!;
121-
[Obsolete("Obsolete on SslStream.")]
122+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
122123
public CipherAlgorithmType CipherAlgorithm { get; private set; }
123-
[Obsolete("Obsolete on SslStream.")]
124+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
124125
public int CipherStrength { get; private set; }
125-
[Obsolete("Obsolete on SslStream.")]
126+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
126127
public HashAlgorithmType HashAlgorithm { get; private set; }
127-
[Obsolete("Obsolete on SslStream.")]
128+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
128129
public int HashStrength { get; private set; }
129-
[Obsolete("Obsolete on SslStream.")]
130+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
130131
public ExchangeAlgorithmType KeyExchangeAlgorithm { get; private set; }
131-
[Obsolete("Obsolete on SslStream.")]
132+
[Obsolete(Obsoletions.RuntimeTlsCipherAlgorithmEnumsMessage, DiagnosticId = Obsoletions.RuntimeTlsCipherAlgorithmEnumsDiagId)]
132133
public int KeyExchangeStrength { get; private set; }
133134

134135
protected IAsyncIOEngine? AsyncIO { get; set; }
@@ -401,7 +402,6 @@ private void GetTlsHandshakeResults()
401402
{
402403
var handshake = GetTlsHandshake();
403404
Protocol = (SslProtocols)handshake.Protocol;
404-
#pragma warning disable CS0618 // Type or member is obsolete
405405
#pragma warning disable SYSLIB0058 // Type or member is obsolete
406406
CipherAlgorithm = (CipherAlgorithmType)handshake.CipherType;
407407
CipherStrength = (int)handshake.CipherStrength;
@@ -410,7 +410,6 @@ private void GetTlsHandshakeResults()
410410
KeyExchangeAlgorithm = (ExchangeAlgorithmType)handshake.KeyExchangeType;
411411
KeyExchangeStrength = (int)handshake.KeyExchangeStrength;
412412
#pragma warning restore SYSLIB0058 // Type or member is obsolete
413-
#pragma warning restore CS0618 // Type or member is obsolete
414413

415414
var sni = GetClientSni();
416415
SniHostName = sni.Hostname.ToString();

src/Servers/IIS/IIS/src/Microsoft.AspNetCore.Server.IIS.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<Compile Include="$(SharedSourceRoot)RazorViews\*.cs" LinkBase="Shared\" />
2727
<Compile Include="$(SharedSourceRoot)ErrorPage\*.cs" LinkBase="Shared\" />
2828
<Compile Include="$(SharedSourceRoot)TaskToApm.cs" Link="Shared\TaskToApm.cs" />
29+
<Compile Include="$(SharedSourceRoot)Obsoletions.cs" Link="Shared\Obsoletions.cs" />
2930
<Compile Include="$(SharedSourceRoot)ServerInfrastructure\*.cs" LinkBase="Shared\" />
3031
<Compile Include="$(SharedSourceRoot)ValueTaskExtensions\**\*.cs" LinkBase="Shared\" />
3132
<Compile Include="$(SharedSourceRoot)Debugger\DictionaryItemDebugView.cs" LinkBase="Shared" />

src/Servers/IIS/IIS/test/IIS.Tests/TlsHandshakeFeatureTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public async Task SetsTlsHandshakeFeatureForHttps()
3333
Assert.True(protocol > SslProtocols.None, "Protocol: " + protocol);
3434
Assert.True(Enum.IsDefined(typeof(SslProtocols), protocol), "Defined: " + protocol); // Mapping is required, make sure it's current
3535

36-
#pragma warning disable CS0618 // Type or member is obsolete
3736
#pragma warning disable SYSLIB0058 // Type or member is obsolete
3837
var cipherAlgorithm = tlsHandshakeFeature.CipherAlgorithm;
3938
Assert.True(cipherAlgorithm > CipherAlgorithmType.Null, "Cipher: " + cipherAlgorithm);
@@ -53,7 +52,6 @@ public async Task SetsTlsHandshakeFeatureForHttps()
5352
var keyExchangeStrength = tlsHandshakeFeature.KeyExchangeStrength;
5453
Assert.True(keyExchangeStrength >= 0, "KeyExchangeStrength: " + keyExchangeStrength);
5554
#pragma warning restore SYSLIB0058 // Type or member is obsolete
56-
#pragma warning restore CS0618 // Type or member is obsolete
5755

5856
if (Environment.OSVersion.Version > new Version(10, 0, 19043, 0))
5957
{

0 commit comments

Comments
 (0)