You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Breaking change]: ECDiffieHellmanPublicKey.ToByteArray() and the associated constructor are now Obsolete #28861
🏁 Release: .NET 7Work items for the .NET 7 releasebreaking-changeIndicates a .NET Core breaking changesource incompatibleSource code may encounter a breaking change in behavior when targeting the new version.
The ECDiffieHellmanPublicKey.ToByteArray() method does not have an implied file format, and for the built-in implementations it throws PlatformNotSupportedException on all non-Windows Operating Systems. Since ECDiffieHellmanPublicKey also has a standard format export (via the ExportSubjectPublicKeyInfo() method) we have declared the older member obsolete.
Version
.NET 7 Preview 4
Previous behavior
Calling ECDiffieHellmanPublicKey.ToByteArray() or the protected ECDiffieHellmanPublicKey(byte[]) constructor would not produce a warning.
New behavior
Calling ECDiffieHellmanPublicKey.ToByteArray() or the protected ECDiffieHellmanPublicKey(byte[]) constructor produces warning SYSLIB0043.
Type of breaking change
Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.
Reason for change
The method was not supported on all operating systems that .NET supports and on the ones it does support the data format was not a standard format.
Recommended action
For callers exporting the public key value, use the ExportSubjectPublicKeyInfo() method.
For existing derived types that already call the protected ECDiffieHellmanPublicKey(byte[]) constructor, continue calling the constructor and suppress the SYSLIB0043 warning.
For new derived types (or existing derived types that do not currently call the byte[]-based constructor) skip calling the protected ECDiffieHellmanPublicKey(byte[]) constructor, and either override ToByteArray() to throw an exception, or accept the default behavior of returning an empty array.
Does making this method obsolete, mean that it will be removed in a future .NET version? Especially consdering that one of the recommendation is to suppress the warning/error in case of existing derived types that already callt he byte[] based constructor.
Does making this method obsolete, mean that it will be removed in a future .NET version?
We generally don't "remove" things, as that would make assemblies that called them get MissingMethodExceptions. We could replace the method body with throw new PlatformNotSupportedException(), but that's not super likely in this case, it's not code we have an active reason to delete.
The reason it got marked as Obsolete is that callers using the base type have no idea what ToByteArray is going to do, and they can't really do anything with the value it returns (without knowing what specific derived type it came from). So, no one should ever be calling it.
FWIW, there's a 80+% chance that the whole of ECDiffieHellmanPublicKey will be marked as Obsolete in the next version (or, at least, all the members accepting or producing one), and the API simplified to do DeriveKey in terms of another ECDiffieHellman object (since the ECDHPK values are only ever produced off of an ECDH object).
🏁 Release: .NET 7Work items for the .NET 7 releasebreaking-changeIndicates a .NET Core breaking changesource incompatibleSource code may encounter a breaking change in behavior when targeting the new version.
Activity
Tohnmeister commentedon Oct 22, 2024
Does making this method obsolete, mean that it will be removed in a future .NET version? Especially consdering that one of the recommendation is to suppress the warning/error in case of existing derived types that already callt he
byte[]based constructor.bartonjs commentedon Oct 22, 2024
We generally don't "remove" things, as that would make assemblies that called them get MissingMethodExceptions. We could replace the method body with
throw new PlatformNotSupportedException(), but that's not super likely in this case, it's not code we have an active reason to delete.The reason it got marked as Obsolete is that callers using the base type have no idea what ToByteArray is going to do, and they can't really do anything with the value it returns (without knowing what specific derived type it came from). So, no one should ever be calling it.
FWIW, there's a 80+% chance that the whole of ECDiffieHellmanPublicKey will be marked as Obsolete in the next version (or, at least, all the members accepting or producing one), and the API simplified to do DeriveKey in terms of another ECDiffieHellman object (since the ECDHPK values are only ever produced off of an ECDH object).