Add an editorconfig option to supress LibraryImport suggestion for blittable PInvokes

Open
#111,593 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp

Research direction

Start with the LibraryImport analyzer and its existing editorconfig options. Trace how it suggests converting blittable PInvokes from DllImport, then identify the analyzer tests covering that suggestion. Done means an editorconfig switch can suppress the suggestion without affecting other LibraryImport diagnostics, including multitargeting scenarios.

Written by the indexing model from the issue text.

Description

area-Interop-coreclr code-analyzer help wanted

The current LibraryImport analyzer always suggests to convert to it from DllImport, even when it's not necessary due to the signature being blittable. This is especially annoying when multitargeting with older TFMs without LibraryImport.
As discussed on Discord, there should be an option to opt out of this with an editorconfig switch.

cc @jkoritzinsky @tannergooding

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.