Skip to content

Strong name signing of assemblies #18

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

Merged
merged 5 commits into from
May 18, 2021
Merged

Strong name signing of assemblies #18

merged 5 commits into from
May 18, 2021

Conversation

gfoidl
Copy link
Contributor

@gfoidl gfoidl commented May 17, 2021

Strong name signing

It's viral, so libraries that are itself strong-named can't used our lib if it's not signed.
Strong naming is no security measure, it's an artifact from the code sandbox security of old .NET days and not brought over to .NET Core. So it's OK to check the snk-file in (it is unique for this project, so no leaking of secrets, etc.)

Fixes #17

.NET Standard 2.0

Is enabled with this PR too, as the changes are minimal and broadens the potential target audience (if someone needs to stick to .NET Full and ASP.NET Core they deserve to get some goodness).

@gfoidl gfoidl requested a review from BenjaminAbt May 17, 2021 21:21
@@ -15,9 +16,18 @@
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
<IsBenchmarkProject>$(MsBuildProjectName.Contains('Benchmark'))</IsBenchmarkProject>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Copy link
Contributor Author

@gfoidl gfoidl May 17, 2021

Choose a reason for hiding this comment

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

No errors (in local build) 😃
Edit: ah shit, Debug build, hence no XML comments...CI fails. Will have a look.

Shall we keep it enabled?
(Personally I prefer this -- on some projects, not always)

}

public static bool Contains(this string instance, string value, StringComparison comparison)
=> instance.IndexOf(value, comparison) >= 0;
Copy link
Member

Choose a reason for hiding this comment

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

I thought Contains is now more efficient, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for .NET Standard 2.0 (see filename) as this the string.Contains API with the StringComparison is .NS 2.1.
string.Contains itself is exactely implemented in this way. More efficient on .NET Core is the IndexOf.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is only built iif .netstandard2.0, and there the rule shouldn't fire as the suitable overload doesn't exist.
I didn't see this analyzer warning. Did you get it?

For .NS 2.1 we use string.Contains(..., ignorecase) as it's cleaner to read.

@gfoidl gfoidl merged commit 44d7ed9 into main May 18, 2021
@gfoidl gfoidl deleted the gfoidl/strong-name branch May 18, 2021 12:45
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.

Strong-naming?
2 participants