zzarchive-VisualFSharpPowerTools icon indicating copy to clipboard operation
zzarchive-VisualFSharpPowerTools copied to clipboard

[Unused open declarations] Doesn't work correctly on interfaces

Open dungpa opened this issue 11 years ago • 23 comments
trafficstars

1st repro: image

2nd repro: image

Link:

https://github.com/dungpa/PowerTools/blob/3ea3e5dea66231ef315ac50e6fbf2aafd933c3a4/tests/FSharpVSPowerTools.Tests/MockGeneralOptionsPage.fs

https://github.com/dungpa/PowerTools/blob/3ea3e5dea66231ef315ac50e6fbf2aafd933c3a4/tests/FSharpVSPowerTools.Tests/Mocks.fs

It might be the case that the AST walker doesn't go inside interface declarations.

dungpa avatar Jul 24 '14 12:07 dungpa

I cannot build vs-tests branch:

L:\github\FSharpVSPowerTools\tests\TestUtilities\AzureUtility.cs(76,28,76,37): error CS1061: 'System.Management.Automation.PowerShell' does not contain a definition for 'HadErrors' and no extension method 'HadErrors' accepting a first argument of type 'System.Management.Automation.PowerShell' could be found (are you missing a using directive or an assembly reference?)
2>L:\github\FSharpVSPowerTools\tests\TestUtilities\AzureUtility.cs(95,28,95,37): error CS1061: 'System.Management.Automation.PowerShell' does not contain a definition for 'HadErrors' and no extension method 'HadErrors' accepting a first argument of type 'System.Management.Automation.PowerShell' could be found (are you missing a using directive or an assembly reference?)
1>C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets(155,9): error : Build was canceled.

vasily-kirichenko avatar Jul 24 '14 12:07 vasily-kirichenko

OMG

open namespace but

This is definitely a VFPT/FCS bug. What will we do with it?

vasily-kirichenko avatar Jul 24 '14 13:07 vasily-kirichenko

Same thing with the second sample

image

vasily-kirichenko avatar Jul 24 '14 13:07 vasily-kirichenko

Trying to go to definition

image

Maybe something went really wrong with assembly references?

vasily-kirichenko avatar Jul 24 '14 13:07 vasily-kirichenko

IGeneralOptionsPage is defined in a C# project, Go To Definition will not work obviously.

FCS doesn't have correct information on tooltips in this case. We can't do anything to improve that.

dungpa avatar Jul 24 '14 13:07 dungpa

Do you think FCS never gives a proper tooltip for C# namespaces? I suspect this is a special case.

vasily-kirichenko avatar Jul 24 '14 13:07 vasily-kirichenko

I checked on my solution at work, tooltips for C# namespaces are shown correctly.

vasily-kirichenko avatar Jul 24 '14 13:07 vasily-kirichenko

I consider this as a bug in FCS and we should not make a work around for it.

vasily-kirichenko avatar Jul 24 '14 17:07 vasily-kirichenko

Shouldn't work around this. It would be good if we could create a standalone repro and report upstream.

dungpa avatar Jul 24 '14 18:07 dungpa

I 've seen the same with Provided types:

 //File1.fs
module MyModule
type MyProvidedType = XmlProvider<"...">
//File2.fs
module Usage
open MyModule // it is grayed... should not !

let (t: MyProvidedType.SomeGeneratedType) = ...

thinkbeforecoding avatar Aug 12 '14 13:08 thinkbeforecoding

How about that one? (SchemaProvider)

image

EDIT: this comment contains deprecated information.

OkayX6 avatar Aug 12 '14 14:08 OkayX6

Please open a separate issue. We might have skipped symbols from provided types.

dungpa avatar Aug 12 '14 14:08 dungpa

Actually this is the behavior of an old version of FS Power tools... Sorry for the noise guys, it was in my bug backlog for a long time!

OkayX6 avatar Aug 12 '14 14:08 OkayX6

@OkayX6 Well, it would be better to file the bug when it first appears. It's going to save us maintenance efforts in the long run :-).

dungpa avatar Aug 12 '14 21:08 dungpa

Every F# file that I open thinks that ALL open statements are unused.

jtmueller avatar Aug 13 '14 22:08 jtmueller

Hey question: is there a way we could avoid false positives, at the price of not graying some open statements?

OkayX6 avatar Aug 13 '14 23:08 OkayX6

@jtmueller this is how it's supposed to work.

vasily-kirichenko avatar Aug 14 '14 04:08 vasily-kirichenko

@jtmueller I really appreciate if you could provide a minimal repro. If the internal state is corrupted, it will mark all open statements as unused. We should definitely fix that.

dungpa avatar Aug 14 '14 06:08 dungpa

@dungpa I'll try to put together a minimal repro. So far I've just noticed that since the update every F# file in any project of a rather large solution greys-out all open statements and lights up the scrollbar. I haven't seen it work right anywhere, but I haven't taken the time to explore outside of my main solution. If it works in a trivial case, I'm going to have a hell of a time figuring out what's unique about my particular solution.

jtmueller avatar Aug 15 '14 18:08 jtmueller

@jtmueller Try to delete all binaries and build the solution again. It should help.

vasily-kirichenko avatar Sep 06 '14 06:09 vasily-kirichenko

Thanks Vasily, that did help - after I closed and restarted Visual Studio.

jtmueller avatar Sep 08 '14 20:09 jtmueller

@vasily-kirichenko i got the same problem building another project. the Powershell.HadErrors property was added in powershell v3 (system.manangement.automation). I installed powershell 3 and after that the project works, now visual studio resolve the reference using the 3.0.0.0 assembly instead of v 1.0.0.0.

Maybe is better to write it as 3.0.0.0 in the csproj, at least i can see i dont have the correct assembly referenced:

<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
    </Reference>

@dungpa you want a pr about that?

enricosada avatar Sep 09 '15 15:09 enricosada

@enricosada Sure. Please do so.

dungpa avatar Sep 09 '15 17:09 dungpa