phmonte / Buildalyzer

A utility to perform design-time builds of .NET projects without having to think too hard about it.
MIT License
593 stars 94 forks source link

No SourceFiles and References for .NET 5 VB project #149

Closed Sergey-Vlasov closed 2 years ago

Sergey-Vlasov commented 3 years ago

With .NET 5 RC2 installed.

dotnet new console -lang VB

using System;
using Buildalyzer;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            IProjectAnalyzer analyzer = (new AnalyzerManager()).GetProject(@"c:\x\x.vbproj");
            IAnalyzerResults results = analyzer.Build();
            IAnalyzerResult result = results.First();

            Console.WriteLine($"SourceFiles {result.SourceFiles.Count()}");
            Console.WriteLine($"References {result.References.Count()}");
        }
    }
}

Actual output is:

SourceFiles 0
References 0

Expected output: several SourceFiles and References.

govert commented 3 years ago

@daveaglick Would you be willing to look at a PR that adds VB support, in the same style as #146 ?

daveaglick commented 3 years ago

Yes, definitely - as with F# support I won't really be able to support it myself, but I'm happy to bring it in and add a disclaimer or follow-up in issues to that effect.

dukedagmor commented 3 years ago

I suspect adding VB to be easier then F# since the compiler is the same. I don't know but would expect the following: 1 - VB uses TaskCommandLineEventArgs 2 - that would make the output format the same so you could use existing ProcessCscCommandLine

You could to look into the possibility of using the _cscCommandLineArguments and maybe rename it to _roslynCommandLineArguments

We would need a test version to confirm this, and a lot of MSBuild Structured Log Viewer 😂 My tip to anyone trying this: print all BuildMessageEventArgs in src/Buildalyzer/Logging/EventProcessor.cs a lot of data go's thru here and maybe the sourcefiles and references are already there, they just don't come from Csc or Fsc.

I wish you good luck!

daveaglick commented 2 years ago

I think this is resolved in #207 courtesy of @cslong - at a minimum an AnalyzerResult is now created for Visual Basic projects (and tested via unit test). I'll close this issue since it's working as far as I can tell, but please open a new one if it looks like there are still problems with VB support (though my ability to help will be limited since I don't know the first thing about VB or VB projects).