postsharp / Metalama

Metalama is a Roslyn-based meta-programming framework. Use this repo to report bugs or ask questions.
164 stars 4 forks source link

Metalama Explodes after upgrading from 2024.1.21 to 2024.2.12-preview, Architecture from 2024.0.7 to 2024.2.12-preview and after referencing Contracts for the first time #323

Open XtroTheArctic opened 5 days ago

XtroTheArctic commented 5 days ago

Hello.

Recently, I decided to start using the parameter validation aspects from Contracts package instead of implementing them by myself in my Atesh.Metalama library because the other problems I had with Contracts package were supposedly resolved (This one: https://github.com/postsharp/Metalama.Patterns/issues/13) (And the other one I discussed directly with @gfraiteur on Slack: https://github.com/postsharp/Metalama.Patterns/pull/134)

After doing this switch, I started getting many errors from Metalama.

Here is my setup:

  1. I have a library called Atesh.Metalama. This is my root library which is referenced (via NuGet) by other libraries directly or indirectly. https://bitbucket.org/XtroTheArctic/atesh.metalama/src/develop/ https://www.nuget.org/packages/Atesh.Metalama

  2. Another library of mine is Atesh. This references Atesh.Metalama and this one introduces an extra aspect along with many other features. If Atesh.Metalama didn't exist, this would be my root library which I reference (via NuGet) from everywhere else. https://bitbucket.org/XtroTheArctic/atesh/src/develop/ https://www.nuget.org/packages/Atesh

  3. The next library is called UnityLibraries. Actually, this is a collection of many assemblies and they are used in my Unity game projects. These are the consumers of my root libraries Atesh.Metalama and Atesh. I use the parameter validation aspects heavily in these ones. And these are the projects that I get many errors from Metalama after updating to a new version and starting to use the Metalama Contracts package. Exact solution location in the repo: https://bitbucket.org/XtroTheArctic/unitycommons-commons/src/develop/Atesh/.Source/UnityLibraries.sln

What I changed to cause the errors:

A. To start using the parameter validation aspects in Metalama Contracts package, I updated the VS Metalama Extension first.

B. In Atesh.Metalama project, I updated Metalama.Framework package from 2024.1.21 to 2024.2.12-preview and I installed Metalama.Patterns.Contracts package 2024.2.12-preview. I deleted my custom parameter validation aspects. Then I implemented InequalityStrictnessFabric.cs as suggested by Gael. Atesh.Metalama can be built fine so I published it to NuGet as a preview package.

C. In Atesh project, I updated my Atesh.Metalama package to the new preview version and changed nothing else. This too can be built fine so I published it to NuGet as a preview package.

D. In UnityLibraries, (please see feature/MetalamaUpdate branch to see these changes) I updated my Atesh.Metalama and Atesh packages to the new preview versions. In some projects, I updated Metalama.Extensions.Architecture from 2024.0.7 to 2024.2.12-preview too.

E. Then, In UnityLibraries, I replaced the "using" namespaces from Atesh.Metalama to Metalama.Patterns.Contracts. The parameter validation aspects are named exactly the same so I didn't need to replace them in my many code files.

Errors and problems:

After making these changes, VS started to show many Metalama related errors. I also started to get Windows notifications about Metalama errors. Please see the screenshots below.

When I try to build the projects individually one by one, for most of them, VS says "built success" but 4 of them fails: Atesh.Unity.Test Atesh.ComponentModel.Test Atesh.WindowsAndWidgets.Editor Atesh.WindowsAndWidgets.Test

As always, I can give you access to my Git repos (some are private and some are public) so you can repro the problem on your side. Gael and @addabis have access already.

Please CLONE via SSH.

image image image image image

And many more errors like these...

It started to show these notifications too: image

svick commented 4 days ago

Thanks for the report.

The "item with the same name has already been added" issue looks like one that we fixed in 2024.2.13-rc, so that shouldn't happen anymore.

As for the "path cannot be null" one, can you give me access to your repos (Daniel is currently on vacation)? Thanks.

XtroTheArctic commented 4 days ago

I added your gmail email and sent an invitation. If you prefer to use your postsharp email, please let me know what it is.

Thank you for looking into the problem.