Closed MilleBo closed 9 months ago
Does it actually crash if they're different? The ProjectInfo
requires an assembly name so we have to give it one, but I'm not sure what it's used for besides that.
To a large extent I don't think it matters in this case - that code is creating a ProjectInfo
instance for Roslyn to use while generating the workspace. The expectation (at least my intent) was that this workspace was primarily for analysis purposes, not compiling back to disk. To be honest, I'm not sure you even could use it to reliably compile a project - the main Buildalyzer does that via shelling out to MSBuild to avoid all the little gotchas (and there are a lot).
It doesn't crash but later on if you do a commit/emit from a project in the created adhocworkspace it will complain about references.
But yeah it depends a lot on the goal and if this project is mostly for analyze then it doesn't really matter. But I have actually had a lot of success with compiling the projects back to disk (where MsBuildWorkspace would fail) so even if this isn't your intent it actually work pretty nice 👍
In
AnalyzerResultExtensions.cs
at row 107 you set assembly name to the project file name. I guess this is true for 99% of the cases but I have found solutions where they have a project name and then a different assembly name (not sure if they just forgot to change or if it's intended).Maybe you should take the extra mile to actually check the assembly name just to be safe? Right now you will get a lot of conflicts later on because dependencies expect a certain name but we call it something else.