Skip to content
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

Merged
merged 9 commits into from
Jan 26, 2024

Conversation

Rob-Hague
Copy link
Collaborator

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.

@@ -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);
Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Done

src/Renci.SshNet/Renci.SshNet.csproj Outdated Show resolved Hide resolved
@WojciechNagorski
Copy link
Collaborator

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);
Copy link
Collaborator

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.

Copy link
Collaborator

@WojciechNagorski WojciechNagorski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now LGTM!

@WojciechNagorski WojciechNagorski merged commit 64b428f into sshnet:develop Jan 26, 2024
1 check passed
@Rob-Hague Rob-Hague deleted the trimming branch January 26, 2024 08:59
@WojciechNagorski
Copy link
Collaborator

This issue has been fixed in the 2024.0.0 version.

@WojciechNagorski WojciechNagorski added this to the 2024.0.0 milestone Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants