You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a rule to flag P/Invoke declarations passing string parameters by value with the [Out] attribute, which can destabilize the runtime if the string is an interned string.
// Flag [Out] string[DllImport("MyLibrary")]privatestaticexternvoidFoo([Out]strings);// OK[DllImport("MyLibrary")]privatestaticexternvoidBar(outstrings1,[Out]refstrings2);
Is there any situation in which this is considered valid? It's akin to pinning a string and then writing into it, right? I'm wondering if in addition to an analyzer (which I agree is warranted; I didn't realize we allowed this), .NET 5 should simply throw an exception at runtime if you try to do this?
@terrajobst Approval for the analyzer. We were told we would need to go through an official API review process via marking this issue as api-ready-for-review. Is that still the case - should we be marking it differently or are we no longer expecting an API review for analyzers?
Activity
stephentoub commentedon May 1, 2020
Is there any situation in which this is considered valid? It's akin to pinning a string and then writing into it, right? I'm wondering if in addition to an analyzer (which I agree is warranted; I didn't realize we allowed this), .NET 5 should simply throw an exception at runtime if you try to do this?
AaronRobinsonMSFT commentedon May 1, 2020
I believe @jkoritzinsky added this.
elinor-fung commentedon May 11, 2020
@terrajobst @stephentoub Any concerns with us going ahead with this? Is there a specific/official approval we should ask for?
terrajobst commentedon Jul 15, 2020
Approval for which part? Throwing the exception, the analyzer or both? I thinking doing both seems great to me.
elinor-fung commentedon Jul 15, 2020
@terrajobst Approval for the analyzer. We were told we would need to go through an official API review process via marking this issue as
api-ready-for-review. Is that still the case - should we be marking it differently or are we no longer expecting an API review for analyzers?terrajobst commentedon Jul 16, 2020
Video
The analyzer/fixer makes sense.
elinor-fung commentedon Jul 28, 2020
Analyzer was added with dotnet/roslyn-analyzers#3879
Doc has also been added now: MicrosoftDocs/visualstudio-docs@df17e88