fsprojects-archive / zzarchive-VisualFSharpPowerTools

[ARCHIVED] Power commands for F# in Visual Studio
http://fsprojects.github.io/VisualFSharpPowerTools/
Apache License 2.0
310 stars 77 forks source link

Interface stub code generation for internal types with InternalsVisibleTo #1035

Open bentayloruk opened 9 years ago

bentayloruk commented 9 years ago

Hi All,

Thanks for making it so easy to get VFPT up and running locally! It only took me 10 mins to get going.

I can't seem to make implement inteface work with internal interfaces in another project, despite using InternalsVisibleTo. I have an an existing C# library that has a fair few internal interface types. I'd love to be able to stub these out using VFPT.

I've sperlunked around the VFPT code and debugged an example case. VFPT is identifying my internal interface as an interface, when I change to the word. However, the FSharpEntity.MembersFunctionsAndValues property is empty, so this returns and empty seq and causes this to return true.

Happy to have a crack at this myself, but wondering if anyone has any tips? Given that FCS is returning the FSharpEntity information, as opposed to VFPT filtering on internal, I'm guessing this needs some FCS tweaking?

dungpa commented 9 years ago

Hi Ben,

You're right; this needs some modifications in FCS. Currently FCS uses AccessibleFromSomeFSharpCode which is lowest common denominator for accessibility https://github.com/fsharp/FSharp.Compiler.Service/blob/9a3fc667180ab0a04ee68d341804d40b9d34a008/src/fsharp/vs/Symbols.fs#L410. It hasn't yet to check for InternalsVisibleTo attributes.

There is already some accessibility checking implemented at https://github.com/fsharp/FSharp.Compiler.Service/blob/5cea4e1f8025082dfcb4e5a375fa48d126701efb/src/fsharp/vs/Symbols.fs#L150 so it could be wired up to pass correct accessibility to MembersFunctionsAndValues.

I think you can open an issue at FCS repo and dig up further.

bentayloruk commented 9 years ago

Great, thanks for the pointers. I'll get back to this when I have a moment again!