-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Allow loading of projects that are missing imports. #206
Conversation
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.
Before this is merged I want to add a test that has a project that would fail without this - to ensure we don't regress. |
I tested the The branch fixes one of two cases:
By "able to load" I mean that proj-info/test/Ionide.ProjInfo.Tests/Tests.fs Lines 1993 to 2016 in 6fe2b3b
parsedProjs .
Per our chat on Discord yesterday, perhaps VS is employing additional tricks to load case 2. |
1/2 is progress! there are some other project-load-related flags that we might be able to set to address the gap here. I'll make sure to have examples for both of the scenarios you mentioned in the tests I make for this PR so we can make sure we get it right. |
Gonna convert to draft until we have some tests |
@ronnieholm what version of that webjobs publish package are you using? 1.1.0 is the latest one I can find that has this bad import pattern, and it is 7 years old. There are a few more recent versions that wouldn't have this same problem. |
It's a .NET 4.8 project referencing Commenting out that
line in the
The So I created a new .NET 4.8 console app with only That behavior is hard to explain :-/ Today I cannot successfully reproduce case 1 above anymore. I suspect I might have messed up restore/recreation of |
Went down a rabbit hold, did a kinda-large refactor that was needed because of some bad usage practices we had, and now we are green. I've left a summary in the PR description, but I'm happy to talk through the changes/add more docs/etc. |
@@ -459,6 +536,9 @@ module ProjectLoader = | |||
"DotnetProjInfo", "true" | |||
yield! globalProperties | |||
] | |||
|> List.filter (fun (ourProp, _) -> not (propsSetFromParentCollection.Contains ourProp)) |
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.
The only reason that I had to do this filtering step is because Configuration
is set by default here but some of our tests set Release
and expect that to work.
If we removed this default it would be cleaner IMO, plus the SDK already defaults to Debug. Happy to discuss for a different PR.
@@ -505,7 +585,7 @@ module ProjectLoader = | |||
Init.setupForLegacyFramework msbuildBinaryDir | |||
| _ -> () | |||
|
|||
let loadProject (path: string) (binaryLogs: BinaryLogGeneration) globalProperties = | |||
let loadProject (path: string) (binaryLogs: BinaryLogGeneration) (projectCollection: ProjectCollection) = |
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.
a lot of these calls dropped globalProperties
in favor of projectCollection
because the projectCollection holds the global properties.
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.
Looks good, just some minor changes I think we should make sure to do for our future selves.
…is case) multiple times we don't need to keep the nugets from PR builds so we'll save that step just for the release.
Fixes #205.
This one got away from me a bit, but I think it's for the best.
The Problem
To load project files with missing Imports, we need to supply one or two ProjectLoadSettings flags to everywhere a project file could be parsed. These flags are
ProjectLoadSettings.IgnoreMissingImports
andProjectLoadSettings.IgnoreInvalidImports
. Ideally we need to find everywhere that a project would be loaded (so anywhereProject(...)
orProjectInstance(...)
occur) and make sure these flags are applied.Phase 1 - protecting the main constructors
For our purposes there are two main places that
ProjectLoadSettings
can be specifiedProject
constructor is called in theWorkspaceLoader
buildParameters
for theWorkspaceLoaderViaProjectGraph
Applying these changes to the existing call-sites was fairly easy - there were something like 6 places that Projects/Project Instances were directly created. Here we come to our first hurdle - the
ProjectInstance
constructor doesn't surfaceProjectLoadSettings
in any way. So step one was to turn any sort ofProjectInstance
creation into a two-phase operation:Project
with appropriate load settingsProjectInstance
from thatProject
This got us most of the way through the tests.
Phase 2 - TFM detection
With one hurdle - the way we detected the TFM for a project involved loading a
ProjectInstance
directly and reading properties from it, and this turned out to be error prone because of the reasons mentioned above -ProjectInstance
doesn't haveProjectLoadSettings
. So we needed to create aProject
to get theProjectInstance
from, as described above.Phase 3 - ProjectCollection management
The above fix worked for more tests, but others still failed because the 'same project' was being created (and implicitly assigned to the global
ProjectCollection
) multiple times - a big no-no forProjectCollections
. So this required two changes:ProjectCollection
as a 'container' for a given call toLoadProjects
- this allows us to cache the evaluations and design-time builds over the course of a single call toLoadProjects
while also not cluttering/clobbering the global defaultProjectCollection
Project
from theProjectCollection
if one exists for the same project path + global properties - if not, a newProject
is created.With these two changes, all the tests (including the new tests) became green.