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

Update Microsoft.CodeAnalysis.NetAnalyzers to 3.3.0-beta3.20407.4 #40560

Merged
merged 1 commit into from
Aug 9, 2020

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub merged commit aa5fdab into dotnet:master Aug 9, 2020
@stephentoub stephentoub deleted the updateanalyzers branch August 9, 2020 09:32
@@ -112,6 +113,8 @@
<Rule Id="CA1834" Action="Warning" /> <!-- Consider using 'StringBuilder.Append(char)' when applicable. -->
<Rule Id="CA1835" Action="Warning" /> <!-- Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' -->
<Rule Id="CA1836" Action="Info" /> <!-- Prefer IsEmpty over Count -->
<Rule Id="CA1837" Action="Warning" /> <!-- Use 'Environment.ProcessId' -->
<Rule Id="CA1838" Action="Warning" /> <!-- Avoid 'StringBuilder' parameters for P/Invokes -->
Copy link
Member

Choose a reason for hiding this comment

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

@stephentoub, are there side-effects of using SB with P/Invokes? I have learned the opposite of this rule as a good practice (use SB over IntPtr whenever we need to access the stringly contents in managed code right away). 😁

Copy link
Member Author

@stephentoub stephentoub Aug 9, 2020

Choose a reason for hiding this comment

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

From a convenience perspective, StringBuilder in P/Invokes is fine; it makes various operations easier. From a performance perspective, you can almost always do better. Depending on the use, marshalling a StringBuilder can incur multiple copies and allocations, both managed and native. We've made it better in core than it used to be, but even so we've systematically stomped out all usage of it in P/Invokes in the core libraries... the ones in this PR are the last ones remaining, and enabling the rule will help lock that in.

Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants