Skip to content

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

Merged
Aditya Patwardhan (adityapatwardhan) merged 3 commits into
PowerShell:masterfrom
adityapatwardhan:FixNet6p6Issues
Jul 9, 2021
Merged

Aditya Patwardhan (adityapatwardhan) merged 3 commits into
PowerShell:masterfrom
adityapatwardhan:FixNet6p6Issues

Conversation

@adityapatwardhan

@adityapatwardhan Aditya Patwardhan (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 Ilya (iSazonov) Jul 7, 2021
@adityapatwardhan Aditya Patwardhan (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

@daxian-dbw Dongbo Wang (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

Copy link
Copy Markdown
Collaborator

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

…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

Ilya (@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
Aditya Patwardhan (adityapatwardhan) merged commit 6d09c6e into PowerShell:master Jul 9, 2021
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) deleted the FixNet6p6Issues branch July 9, 2021 17:55
@iSazonov Ilya (iSazonov) added this to the 7.2.0-preview.8 milestone Jul 12, 2021
@ghost

Copy link
Copy Markdown

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

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
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