dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.9k stars 783 forks source link

extern function arguments are marked as unused #4473

Open enricosada opened 6 years ago

enricosada commented 6 years ago

Arguments of extern function are always flagged as unused by intellisense.

ref https://github.com/ionide/ionide-vscode-fsharp/issues/727

Repro steps

Normal netcoreapp2.0 console app with

open System
open System.Runtime.InteropServices

let private add x y = x + y 

[<DllImport("abc.dll", CallingConvention = CallingConvention.Cdecl, CharSet=CharSet.Ansi)>]
extern IntPtr private test1 (string procname) 

[<DllImport("abc.dll", CallingConvention = CallingConvention.Cdecl, CharSet=CharSet.Ansi)>]
extern IntPtr test2 (string procname) 

[<EntryPoint>]
let main _args =
    test2("dad") |> ignore
    0

Expected behavior

the test1 that is unused and private (or internal), should be flagged as unused like the add function the test2 is used, no unused warning

Actual behavior

Both have the arguments flagged as unused. private/internal doesnt change as modifier

image

Known workarounds

None.

Related information

Microsoft Visual Studio Enterprise 2017 
Version 15.6.1
VisualStudio.15.Release/15.6.1+27428.2002
Microsoft .NET Framework
Version 4.7.02556

Installed Version: Enterprise

Visual F# Tools 10.1 for F# 4.1   00369-60000-00001-AA834
Microsoft Visual F# Tools 10.1 for F# 4.1
cartermp commented 6 years ago

Yep, actually saw that in @kekyo's awesome talk at MVP summit! Thanks for the report.