Closed slang25 closed 3 years ago
To counteract the guilt I'd feel bumping this PR, I bought you a coffee 😆
Lol. Was already planning to take a look at the open Buildalyzer PRs this weekend, but the beverage is appreciated!
😄 it's the least I could do.
I think I may not need this anymore, what I need is basically this: https://github.com/aws/codelyzer/blob/acd3c02c4b41aa0a14393fcf0ae6f4f145212f97/src/Analysis/Codelyzer.Analysis.Build/WorkspaceBuilderHelper.cs#L74-L113
but I want it to happen out of the box. When I use this PR alone, doesn't give the right results from a clean build, because I've not built the projects in the right order.
Tell me more about
When I use this PR alone, doesn't give the right results from a clean build, because I've not built the projects in the right order.
Is the idea that sometimes analyzerResult.Manager.GetProject(x)
won't have the project yet and so we need an extra flow where if the project hasn't already been added to the workspace, and the manager hasn't yet built it, we should go off and build it and then add it?
That seems totally doable, though I think you're right that we'd want to put that behind a flag (probably combined with the behavior in this PR - something like bool buildMissingReferences
.
I guess the part I'm not quite understanding is:
GetReferencedAnalyzerProjects()
now adds the project file to the manager (after this PR) if it wasn't already thereProjectAnalyzer.AddToWorkspace()
AddToWorkspace()
we call return analyzer.Build().FirstOrDefault().AddToWorkspace(workspace, addProjectReferences);
which seems like it should do what you're thinking and build any projects that weren't already built.So my disconnect is why that doesn't work as expected to build projects you're missing once this PR is merged.
I think I get it...is the problem that we don't pick up on transitive references? I.e. if I'm adding project A to the workspace and if references project B, I'll add and build B. But if B also references C, I'll never add and build C to the workspace.
I'm going to bring this discussion back to the original issue...
Fixes #159
This change adds to the functionality when you set
addProjectReferences
totrue
. At the moment it will follow all references where you have already added the project to the solution, but if you want to create an ad-hoc solution with a csproj as the entry point, I think you'll want this behaviour to automatically add references projects to the solution.Just to be clear, the code change code (in
GetReferencedAnalyzerProjects
) is only called whenaddProjectReferences
istrue
.