Skip to content

Fix CA1846 and CA1845 for using AsSpan instead of Substring#15738

Merged
adityapatwardhan merged 3 commits into
PowerShell:masterfrom
adityapatwardhan:FixNet6p6Issues
Jul 9, 2021
Merged

Fix CA1846 and CA1845 for using AsSpan instead of Substring#15738
adityapatwardhan merged 3 commits into
PowerShell:masterfrom
adityapatwardhan:FixNet6p6Issues

Conversation

@adityapatwardhan

@adityapatwardhan adityapatwardhan commented Jul 7, 2021

Copy link
Copy Markdown
Member

PR Summary

Fix CA1846 and CA1845 violations by replacing Substring with AsSpan.

PR Context

These violations cause build break when used with .NET 6 Preview 6.

PR Checklist

@ghost ghost assigned iSazonov Jul 7, 2021
@adityapatwardhan adityapatwardhan added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Jul 7, 2021
Comment thread src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs Outdated
Comment thread src/System.Management.Automation/engine/debugger/debugger.cs Outdated

@daxian-dbw daxian-dbw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Look good other than what Steve already pointed out.

@iSazonov

iSazonov commented Jul 8, 2021

Copy link
Copy Markdown
Collaborator

I think it makes sense to add the rules in .globalconfig.

adityapatwardhan and others added 2 commits July 9, 2021 10:24
…letionCompleters.cs

Co-authored-by: Steve Lee <slee@microsoft.com>
Co-authored-by: Steve Lee <slee@microsoft.com>
@adityapatwardhan

Copy link
Copy Markdown
Member Author

@iSazonov they are already there:

PowerShell/.globalconfig

Lines 473 to 479 in c49cf06

# CA1845: Use span-based 'string.Concat'
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1845
dotnet_diagnostic.CA1845.severity = warning
# CA1846: Prefer 'AsSpan' over 'Substring'
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1846
dotnet_diagnostic.CA1846.severity = warning

@adityapatwardhan adityapatwardhan merged commit 6d09c6e into PowerShell:master Jul 9, 2021
@adityapatwardhan adityapatwardhan deleted the FixNet6p6Issues branch July 9, 2021 17:55
@iSazonov iSazonov added this to the 7.2.0-preview.8 milestone Jul 12, 2021
@ghost

ghost commented Jul 22, 2021

Copy link
Copy Markdown

🎉v7.2.0-preview.8 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants