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

IDE0057 simplify substring #11149

Merged

Conversation

gerhardol
Copy link
Member

Proposed changes

VS suggested change, simplifies displayed code using range operator.
(Should be no change to runtime execution.)

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0057

Typical like

diff --git a/BugReporter/GitHubUrlBuilder.cs b/BugReporter/GitHubUrlBuilder.cs
index 8377b..5b8b8 100644
--- a/BugReporter/GitHubUrlBuilder.cs
+++ b/BugReporter/GitHubUrlBuilder.cs
@@ -46,7 +46,7 @@ public GitHubUrlBuilder(IErrorReportUrlBuilder errorReportUrlBuilder)
             if (subject.Length > 69)
             {
                 // if the subject is longer than 70 characters, trim it
-                subject = subject.Substring(0, 66) + "...";
+                subject = subject[..66] + "...";
             }
 
             string urlEncodedError = _errorReportUrlBuilder.Build(exception, exceptionInfo, environmentInfo, additionalInfo);

Test methodology

Refactoring

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned gerhardol Aug 13, 2023
Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

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

I'm not used to this syntax, but I'm not going to stand in the way of progress :)

@RussKie RussKie merged commit 368c324 into gitextensions:master Aug 15, 2023
3 of 4 checks passed
@ghost ghost added this to the vNext milestone Aug 15, 2023
@gerhardol gerhardol deleted the feature/ide0057-simplify-substring branch August 15, 2023 05:52
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.

None yet

3 participants