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
[Analyzer Proposal]: Span parameter that could be a ReadOnlySpan parameter #96587
Comments
Tagging subscribers to this area: @dotnet/area-system-memory Issue DetailsIf a
We could extend such an analyzer to locals as well. And we should probably allow it to be configurable around visibility, e.g. default to only applying to internal/private members but allow it to be applied to public, too.
|
Presumably this would apply to |
It could, yes. |
Argh. |
Tangential, but is there a system that allows you to tag a project as "internal" such that public members - for the sake of analyzers and whatnot - are classified as internal and vice versa. For me personally, there's no difference other than hiding stuff from other projects in the same solution for if I use public vs internal, but many analyzers works differently based on it. If there is no such system, would you consider it? Doing it manually for each analyzer is in no way sustainable ( some only function for internal, some only for public, and so on) |
Not to my knowledge. You could open an issue in roslyn-analyzers about such configuration. |
This actually seems like it would be useful for |
If a
Span<T>
parameter is never written to by a method body, it's better for the parameter to be aReadOnlySpan<T>
rather thanSpan<T>
. Doing so:ReadOnlySpan<T>
is cheaper than constructing aSpan<T>
, as the latter needs to perform a variance check and the former does not.We could extend such an analyzer to locals as well. This can also handle {ReadOnly}Memory.
And we should probably allow it to be configurable around visibility, e.g. default to only applying to internal/private members but allow it to be applied to public, too.
The text was updated successfully, but these errors were encountered: