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

Add missing string comparison type to equals comparisons #15675

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

lahma
Copy link
Contributor

@lahma lahma commented Apr 6, 2024

<AnalysisLevel>latest-Recommended</AnalysisLevel> is a good starting point as it's basically industry best practices and items can be skipped when needed with #pragma with a good reason.

  • Use System.StringComparison.Ordinal by default
  • Fix minor other issues or disable with #pragma
  • Configure inspection level and allow list in Directory.Build.props

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1309

Now can make separate PRs removing analysis allow list items and making things stricter after this.

* Use System.StringComparison.Ordinal by default
* Fix minor other issues or disable with pragma
* Configure inspection level and allow list in Directory.Build.props
@@ -55,7 +55,7 @@ public void OnAuthorization(AuthorizationFilterContext context)
}

var effectiveRequestSizePolicy = context.FindEffectivePolicy<IRequestSizePolicy>();
if (effectiveRequestSizePolicy == null || effectiveRequestSizePolicy == this)
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 equality cannot be true currently as this is not IRequestSizePolicy, seemed weird and caused analysis warning (as error)

@MikeAlhayek
Copy link
Member

@lahma I use to used using System; when not imported over using System.StringComparison.Ordinal otherwise the change looks good to me.

@lahma
Copy link
Contributor Author

lahma commented Apr 8, 2024

I've added explicit using statements for System and removed the prefix from usages. I'll probably create another PR to enable implicit usings globally 😉

@MikeAlhayek MikeAlhayek merged commit aa05dee into OrchardCMS:main Apr 8, 2024
4 checks passed
@lahma lahma deleted the string-comparison branch April 9, 2024 06:02
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