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

Upgrading from Metalama 2024.0.12 to 2024.1.12 breaks transformed code #286

Closed MEmanuelsson closed 2 months ago

MEmanuelsson commented 2 months ago

We tried to upgrade to the latest version of Metalama (2024.1.12) this morning but all of a sudden some classes affected by Metalama aspects wasn't compiling anymore.

Following the suggested path in the exception message (The most likely cause of the compilation failure is a bug in Metalama. Please report the issue to the Metalama support team. To facilitate troubleshooting, build the project with the option '-p:MetalamaDebugTransformedCode=True', inspect the transformed files in 'obj/Debug/.../metalama'and report the relevant files or snippets.) we see that a couple of constants in the transformed file not look right anymore.

This code in the class:

private const int DistanceToBranchInKilometer = 50;
private const int DistanceRetryCount = 4;
private const string LatLngFilter = "latLng";

looks like this in the file found under /obj/Debug/...metalama:

private const int DistanceToBranchInKilometer ;
private const int DistanceRetryCount ;
private const string LatLngFilter ;

Reverted back to 2024.0.12 for now, looking forward to a solution to this issue. /Martin

svick commented 2 months ago

Thanks for the report.

This happens when you have a type with a primary constructor and you do something that makes Metalama transform it into a regular constructor (e.g. using AddInitializer). So this gives you an alternative workaround (continuing to use 2024.0 is of course reasonable as well).

We will work on fixing this, and will let you know here when that's done (likely this week).

prochan2 commented 2 months ago

This bug has been fixed in Metalama 2024.1.13 and 2024.2.2-preview.