Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[StyleCleanUp] Addressing CA warnings Part 1 #10128

Closed

Conversation

himgoyalmicro
Copy link
Contributor

@himgoyalmicro himgoyalmicro commented Nov 28, 2024

Description

This work is a part of our initiative to set code-style guidelines, align WPF and WinForms, and ensure PR standards with respect to styles. This in turn will help us in better maintainability and readability of the repo overall. The changes follow up from the PR #10080 and references to the issue #10017.

The current changes address the following Errors/Warnings in the src folder of WPF:

  • CA2249: Consider using 'string.Contains' instead of 'string.IndexOf'
  • CA2251: Use String.Equals over String.Compare
  • CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters
  • CA1845: Use span-based 'string.Concat'
  • CA1846: Prefer AsSpan over Substring

A good way to go about reviewing this is to go commit by commit which pans over individual errors/warnings and hence easing out the overall understanding.

Customer Impact

None

Regression

None

Testing

Local Build Pass
The current set of changes looks fairly mechanical and probably don't need a Test Pass, but these set of PRs can be clubbed to do so at a later stage.

Risk

Low

Microsoft Reviewers: Open in CodeFlow

@himgoyalmicro himgoyalmicro requested review from a team as code owners November 28, 2024 06:53
@dotnet-policy-service dotnet-policy-service bot added the PR metadata: Label to tag PRs, to facilitate with triage label Nov 28, 2024
@himgoyalmicro
Copy link
Contributor Author

The changes in this PR will be included in another PR.

@@ -483,7 +483,7 @@ private void Initialize(FileUnit sourceFile)
}

int pathEndIndex = SourceFileInfo.RelativeSourceFilePath.LastIndexOf(Path.DirectorySeparatorChar);
string targetPath = string.Concat(TargetPath, SourceFileInfo.RelativeSourceFilePath.AsSpan(0, pathEndIndex + 1));
string targetPath = string.Concat(TargetPath, SourceFileInfo.RelativeSourceFilePath.Substring(0, pathEndIndex + 1));
Copy link
Member

Choose a reason for hiding this comment

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

Why we back to Substring here? Will it cause the warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it wasn't raising a warning, so the change was unnecessary.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 4, 2025
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants