vendredi 23 octobre 2020

How can I use reflection to discover that SecurityProtocolType.Ssl3 is obsolete?

In my program, I want to dynamically discover the members of System.Net.SecurityProtocolType enumeration which are obsolete.

If I reflect on C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Net.ServicePoint.dll, then I can see the instance of ObsoleteAttribute on the SecurityProtocolType.Ssl3 member.

However, if I do this same check on the type at runtime, there is no such attribute. For example:

typeof(System.Net.SecurityProtocolType).GetField("Ssl3").CustomAttributes.Count(); // returns 0

I guess the first one is some sort of "reference" assembly which is different from the actual runtime assembly.

Is there any way for me to programmatically discover (at runtime), that Ssl3 is obsolete and/or not supported?





Aucun commentaire:

Enregistrer un commentaire