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

Rule S4071: Unmanaged Win32 APIs should not be used #1169

Closed
Evangelink opened this issue Feb 12, 2018 · 3 comments · Fixed by SonarSource/rspec#1105
Closed

Rule S4071: Unmanaged Win32 APIs should not be used #1169

Evangelink opened this issue Feb 12, 2018 · 3 comments · Fixed by SonarSource/rspec#1105
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues.

Comments

@Evangelink
Copy link
Contributor

RSPEC-4071

An incorrectly defined platform invoke method (marked with System.Runtime.InteropServices.DllImportAttribute) can lead to runtime exceptions because of issues such as a misnamed function, faulty mapping of parameter and return value data types, and incorrect field specifications. If available, it is a lot less error prone, not to mention more secure and quite simpler, to call the equivalent managed method.

@agigleux agigleux added this to the 7.5 milestone May 23, 2018
@agigleux agigleux modified the milestones: 7.5, 8.0 Jul 30, 2018
@Evangelink Evangelink modified the milestones: CFG + Symbolic Execution, Rules Aug 9, 2018
@Evangelink Evangelink added Area: VB.NET VB.NET rules related issues. Area: C# C# rules related issues. labels Dec 7, 2018
@pavel-mikula-sonarsource pavel-mikula-sonarsource removed this from the Rules milestone Dec 4, 2019
@Corniel
Copy link
Contributor

Corniel commented Jun 15, 2022

An approach that could work is to mark all [DllImport] attributes, and provide a fix where possible. Or would that be problematic?

@Evangelink
Copy link
Contributor Author

I would recommend to close this issue. I discussed it on runtime (see CA2205) and they said it's not worth porting it as it makes a lot less sense now that .NET is cross-platform.

cc @andrei-epure-sonarsource

@andrei-epure-sonarsource
Copy link
Contributor

thanks @Evangelink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants