Buildalyzer icon indicating copy to clipboard operation
Buildalyzer copied to clipboard

Bug: Additional files not regonized

Open Corniel opened this issue 1 year ago • 5 comments

As mentioned in #243, I noticed that in some projects additional files (and other properties as well I guess, but that was not what I was investigating) are not recognized.

I've added created this PR, that adds a replay where the additional files are not available in the AnalyzerResult.

  1. I noticed (so far) that EventProcessor.MessageRaised(object sender, BuildMessageEventArgs e) is triggered only for v6.0.
  2. For the (existing) test that succeeds, only one TFM is detected, for this failing test, both v6.0 and v5.0 are added. The latter lacks the additional files, but is used to build anyway.
  3. If change the targets to only build .NET 5.0, or for .NET 8.0 and .NET 6.0 combined, everything works just fine.

I'll update mine findings here.

For some background, I use Buildalyzer to test Roslyn Analyzers that check for issues in .NET project files, such as MS Build project files, and RESX files. Access to the additional files is the perquisite for those tests to work. See: dotnet-project-file-analyzers

Corniel avatar Jan 28 '24 10:01 Corniel

@phmonte with a nice [DebuggerDisplay] attribute, I was able to finally find what is going wrong: for the .NET 5.0 target, nothing is compiled: No source files, no additional files. Would you be so kind to also have a look?

Corniel avatar Jul 31 '24 22:07 Corniel

I think I found the problem, you can see it in my commit. But, some tests broke and I still don't think it's the best solution.

phmonte avatar Sep 07 '24 00:09 phmonte

I've been working on a new way of tracing/logging, that also is really in draft mode, but I think it looks promising. I've created another (draft) pr for that: #286

Corniel avatar Sep 07 '24 08:09 Corniel

Perfect, I made a small change to the test project, keeping only 1 TargetFrameworks field and removing the TargetFramework, looking at the documentation here .

I believe the additional files worked and the test passed.

I noticed that the MessageRaised event is called according to the number of TargetFramework(s), when placing the 2 fields, it considered only the first one, as it says in the documentation

phmonte avatar Sep 08 '24 04:09 phmonte

@phmonte It defined wrong on purpose. ;) It is part of a test for .NET project file analyzers. I was suspecting that it might not work because of this. Sorry, I should have specified that.

Corniel avatar Sep 08 '24 07:09 Corniel