resharper-fsharp icon indicating copy to clipboard operation
resharper-fsharp copied to clipboard

Referenced projects not working, "The namespace or module is not defined" errors

Open deyanp opened this issue 6 years ago • 15 comments

Started evaluating Rider for F# a couple of minutes ago, opened an existing F# sln consisting of 5 projects, most of them referencing a project in another solution using the standard

<ProjectReference Include="..\..\..\AnotherProject\src\AnotherProject\AnotherProject.fsproj" >
  <Name>Framework.fsproj</Name>
</ProjectReference>

However in all files the types and functions from AnotherProject are marked red, with the error "The namespace or module is not defined".

Tried unloading/reloading the sln and projects, did not help. Build works fine.

deyanp avatar Sep 14 '19 22:09 deyanp

@deyanp Thank you for the report. Unfortunately, I'm not able to reproduce this behavior. Is there any chance you could share the solution it reproduces on? We can sign an NDA if needed.

auduchinok avatar Sep 15 '19 08:09 auduchinok

Would a short "Screen Sharing" session tomorrow (Monday) at some time during the day (CET) be possible instead of sending you all the whole source code? Or do you need only the *.fsproj files?

I am trying to find out what is so different about the Framework.fsproj, as references to other projects seem to work ...

I see this and don't know why it so (vscode + ionide works OK, also build is OK): image

deyanp avatar Sep 15 '19 11:09 deyanp

When I delete and try to re-add the reference to Framework.fsproj from the UI I get:

image

deyanp avatar Sep 15 '19 12:09 deyanp

my skype is: deyanp (https://join.skype.com/invite/MIJSgbdVrzMx)

deyanp avatar Sep 15 '19 18:09 deyanp

Could it be that only projects up 1 folder (..) can be referenced?

deyanp avatar Sep 16 '19 06:09 deyanp

Not sure if it is related, but if I change something in the referenced project (Framework.fsproj) then building/rebuilding the project depending on it (Shared.fsproj or any other) does not consider that change ...

deyanp avatar Sep 16 '19 07:09 deyanp

@auduchinok can you help? I am eagerly looking for moving from vs code + ionide to rider for F# development ...

deyanp avatar Sep 16 '19 20:09 deyanp

Found the reason for the red project references: <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />

deyanp avatar Sep 17 '19 08:09 deyanp

@deyanp Could you please check if adding the referenced project to solution helps in any way? What is changed if you change/remove the Functions package reference?

auduchinok avatar Sep 17 '19 09:09 auduchinok

If you could make and share a small solution where it reproduces it would really help. If not, at least sharing your fsproj is a good way to go further.

auduchinok avatar Sep 17 '19 09:09 auduchinok

well, check DepProj1 in this repo: https://github.com/deyanp/RiderProjectIssue ...

deyanp avatar Sep 17 '19 10:09 deyanp

Was this resolved? I'm trying to learn F# using rider and I am stuck on a super basic app with two modules in separate files, one referencing the other. They are in the same namespace - and the code comes from an example repo, so should be valid.

The problem I see is that my Program.fs cannot reference the Counter module exposed in the second file. The code is from here

counter-problem

In all likelihood I am making some really basic mistake. All the same I would appreciate any hints that would help me proceed with using rider for f# development.

<edit> After cloning the example repo again I got the code compiling and running. I can probably dig out my blunder by comparing. Sorry about crashing the thread. </edit>

lsim avatar Oct 28 '20 07:10 lsim

@lsim I believe in your case it's just the order of files in .fsproject. File ordering is important in fsharp, so you can't reference a module defined in a file below the current one.

heronbpv avatar Oct 28 '20 15:10 heronbpv

Dude, thank you! It would have taken me a long time to arrive at that explanation.

I was not expecting to maintain the .fsproj by hand :)

lsim avatar Oct 28 '20 16:10 lsim

I was not expecting to maintain the .fsproj by hand :)

@lsim You can also drag-and-drop files right in the Solution/Project tree. :)

auduchinok avatar Oct 28 '20 16:10 auduchinok