Giter Site home page Giter Site logo

Comments (7)

josephwoodward avatar josephwoodward commented on August 13, 2024

Is this not because you're loading a single project? (var analyzer = manager.GetProject(initialPath);) @daveaglick can hopefully shed some more light on this, I've always assumed it'll only load a single project that way but I could be wrong.

What if you were to pass the solution directory when constructing your AnalyzerManager?

from buildalyzer.

daveaglick avatar daveaglick commented on August 13, 2024

Yep, @josephwoodward is correct - Buildalyzer doesn't know about solutions (yet). It'll automatically wire up referenced projects when you use the workspaces extension like this:

AnalyzerManager manager = new AnalyzerManager();
ProjectAnalyzer analyzer1 = manager.GetProject(@"C:\MyCode\MyProject.csproj");
ProjectAnalyzer analyzer2 = manager.GetProject(@"C:\MyOtherCode\MyOtherProject.csproj");
AdhocWorkspace workspace = new AdhocWorkspace();
analyzer1.AddToWorkspace(workspace);
analyzer2.AddToWorkspace(workspace);

In that case, your workspace.CurrentSolution will have projects for both MyProject.csproj and MyOtherProject.csproj and they'll have the correct project references within the Roslyn workspace for each other (but not for any projects that haven't already been loaded by the manager!).

TL;DR: You've got to load each project into the AnalyzerManager and add them each to the Roslyn workspace. There's also an extension you can use on the manager: AdhocWorkspace workspace = manager.GetWorkspace() that'll load all the projects you've created from the manager into the Roslyn workspace but you've still got to create the projects from the manager first.

I eventually plan to support parsing and loading whole solutions, just haven't gotten there yet.

from buildalyzer.

josephwoodward avatar josephwoodward commented on August 13, 2024

Question for you @daveaglick,

If my Project A references ProjectB and ProjectC, would loading ProjectA via manager.GetProject(); also implicitly load ProjectB and C, or would I also need to do that?

from buildalyzer.

daveaglick avatar daveaglick commented on August 13, 2024

@josephwoodward Not right now, no. It would only load ProjectA. In fact, the main Buildalyzer library doesn't do anything at all with project references. It's only the Buildalyzer.Workspaces extension that even considers them (and even then, only to wire them up if you manually add them to the workspace).

I've got a couple thoughts here:

  • Add an optional bool property named something like LoadProjectReferences to AnalyzerManager that automatically loads referenced projects into the manager when a ProjectAnalyzer goes past the Load() stage.
  • Add a similar argument to the extension methods in the Workspaces extension to do the same - load referenced projects into the manager and then also populate then in the workspace.
  • Add support for loading entire solutions in the AnalyzerManager.

from buildalyzer.

josephwoodward avatar josephwoodward commented on August 13, 2024

Sounds like a good idea, happy to take this one on at some point.

from buildalyzer.

kentcb avatar kentcb commented on August 13, 2024

Buildalyzer doesn't know about solutions

Ah, bummer. Yeah, loading the solution itself was actually the first thing I tried since that's how my existing Roslyn-only code was working.

I will close this issue then, and open another to track solution loading, since that is seemingly what I'll need to progress. My tool can't really know about all projects to load in advance, since it is intended to work against any solution.

from buildalyzer.

daveaglick avatar daveaglick commented on August 13, 2024

👍

Please do open a feature request issue for loading solution files - hope to get that in pretty soon (feel free to grab it @josephwoodward if you need another PR for Hacktoberfest 😄)

from buildalyzer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.