-
-
Notifications
You must be signed in to change notification settings - Fork 940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable trim analysis and fix warnings #1216
Conversation
@@ -41,13 +41,20 @@ public RsaDigitalSignature(RsaKey rsaKey, HashAlgorithmName hashAlgorithmName) | |||
/// </returns> | |||
protected override byte[] Hash(byte[] input) | |||
{ | |||
return _hash.ComputeHash(input); | |||
#if !NET462 | |||
using var hash = IncrementalHash.CreateHash(_hashAlgorithmName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we benefit (performance wise) from creating the hash in the ctor and reusing it here.
Please create a small benchmark to help us decide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to my other comment: this is a correctness fix, not a performance improvement. I would rather work on other things than to run a benchmark for such a change. Sorry for being blunt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maybe let's move the hash creating to the constructor. What do you think? this is the last change and I will be able to merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Done
I don't know how IsTrimmable works with references (i.e. to SshNet.Security.Cryptography)
I will review this next week. |
@@ -41,13 +41,20 @@ public RsaDigitalSignature(RsaKey rsaKey, HashAlgorithmName hashAlgorithmName) | |||
/// </returns> | |||
protected override byte[] Hash(byte[] input) | |||
{ | |||
return _hash.ComputeHash(input); | |||
#if !NET462 | |||
using var hash = IncrementalHash.CreateHash(_hashAlgorithmName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maybe let's move the hash creating to the constructor. What do you think? this is the last change and I will be able to merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now LGTM!
This issue has been fixed in the 2024.0.0 version. |
While the library is not really so modern as to think about trimming and AOT, with the default behaviour to trim all assemblies when trimming an application we have seen issues such as #1167, and I believe #859 (comment) is related.
Fortunately it does not require many changes.