-
Notifications
You must be signed in to change notification settings - Fork 346
Add a code analyzer to fix certain Span<T> usage #2206
Conversation
Fixed all AsSpan() calls in aspnet: |
And corefxlab: #2207 |
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27604.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpanUsage", "SpanUsage\SpanUsage\SpanUsage.csproj", "{A99829A8-F185-4044-904F-211077DD11B8}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really a sample?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: 1. Add to corefxlab.sln
It could be considered a sample code analyzer for span. I wanted to start it there, and move it to the solution. Would you be fine with adding it to the solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@terrajobst is working on a package for many .NET analyzers. I think this analyzer might be a good fit for such package.
Having said that, I am totally fine with adding it to this samples project short term.
@dotnet-bot test Innerloop Ubuntu16.04 Release Build and Test |
I wanted to try and create a code analyzer and used the following
Span<T>
usage scenario as motivation:Collapse AsSpan().Slice(start, length) into AsSpan(start, length)
This can be used to fix https://github.com/dotnet/corefx/issues/27330 (see dotnet/corefx#29078)
Screenshots:
Majority of the code here is template code. Focus on the following files:
TODOs (I will file separate issues, and address outside this PR):
Update the VSIX descriptionFuture code analysis rules that we can introduce:
Memory<T>.Slice(...).Span
=>Memory<T>.Span.Slice(...)
- Extend the SpanUsage code analyzer to check for Memory<T>.Slice(...).Span #2215cc @dotnet/corefxlab-contrib, @tarekgh, @stephentoub, @atsushikan, @khellang, @VSadov, @KrzysztofCwalina