-
Notifications
You must be signed in to change notification settings - Fork 833
Added "You must add a reference to '<assembly>'" code fixer #2743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I've opened this PR to get some help/pick the brains of others. The problem is that ProjectSysten.OAReferences.AddProject is being called with Library1, i.e. it's attempting to add a reference to Library1 from Library1. We must be reporting our projects to Roslyn incorrectly, as the names are correct on the Roslyn end (as shown in the screenshot). ApplyProjectReferenceAdded is the first in the call-stack before we enter the F# project system code. I have a feeling that we're calling |
@saul sorry for offtopic, I cannot find the place where you started the work to enable F# <-> C# Go to Definition. Have you suspended or given up on it? We'd like to join the effort if you are stuck or something. |
@vasily-kirichenko it's very WIP state on my desktop (I'm only on my laptop for a few days). I'll push what I've got onto a branch on Sunday night/Monday. It's certainly not suspended/given up on :) |
8228545 raised a bit of a doozy in our Roslyn workspace setup code. When we setup the project references, we were passing in the dependent project as the hierarchy for the dependency. How this hasn't caused more issues is beyond me! |
This is now ready to merge 👍 |
…isualfsharp into missing-reference-codefix # Conflicts: # vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs
I've screwed my rebase up again... I really should read up on how to do this properly. |
just checkout a new branch off of master and cherry pick the important commits and you'll be back to status quo in a few mins |
@dotnet-bot test this please |
Ugh "The value, namespace, type or module 'CommonRoslynHelpers' is not defined." makes no sense @dotnet-bot test this please |
@cartermp it's because I'm an idiot - fixed |
Looks like there's a merge conflict now. Unrelated to the build error, though. |
# Conflicts: # vsintegration/src/FSharp.Editor/srFSharp.Editor.fs
It's green!! |
| Some metadataRef -> | ||
let codefix = | ||
createCodeFix( | ||
sprintf "Add an assembly reference to '%s'" metadataRef.Display, // TODO: localise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you localize this before I pull it.
| Some refProject -> | ||
let codefix = | ||
createCodeFix( | ||
sprintf "Add a project reference to '%s'" refProject.Name, // TODO: localise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@KevinRansom it is localised - see the latest commits |
@dotnet-bot test this please |
@KevinRansom you did a dodgy merge - fixed and merged master again. Hopefully this will be the final time -.- |
@cartermp @KevinRansom can this be merged? |
looking at it right now. |
Thank you for this, it looks great., |
) * Added "You must add a reference to 'foo'" code fixer * Preliminary work to enable metadata reference code fixing * Fix SetupProjectFile passing in the wrong IVsHierarchy to CreateProjectContext * Localise code fix strings, add support for metadata (assembly) references * Fix removing references not being reflected in the Roslyn workspace * Added "You must add a reference to 'foo'" code fixer * Preliminary work to enable metadata reference code fixing * Rebased onto master * Localise code fix strings, add support for metadata (assembly) references * Fix removing references not being reflected in the Roslyn workspace * Fix dodgy merge * Fix reference to CommonRoslynHelpers * Removed intellisense strings accidentally added in merge * Ignore case when comparing assembly names * Fix dodgy merge
Hey @saul, I know it's been 6 years, but maybe do you remember how to repro this? I would like to add some tests for this code fix but, whatever I am doing, I am either getting FS0039 or the the assembly is discovered and added automatically. So I wonder if this is still relevant. |
From memory, I think this would repro when you had a reference (on .NET Framework, before SDK-style projects judging by the year) onto Library2, which in turn referenced Library3 and exposed it through its public API (e.g. method parameters). I think nowadays assembly references are rare, and in the age of SDK-style projects, project references are transitive. This may be quite a difficult scenario to stumble upon now. |
Ohhhhhh this thing. Okay yeah, my brain has already purged the memories of those days and those project files :D Thanks @saul for such a prompt response - you saved me a lot of time. |
Project references
Assembly references
Remaining work