postsharp / Metalama

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

Metalama fails: Failed to compare two elements in the array #328

Closed XtroTheArctic closed 4 months ago

XtroTheArctic commented 4 months ago

Earlier I mentioned this problem in another ticket because I have been getting multiple problems or errors and I was overwhelmed. https://github.com/postsharp/Metalama/issues/323

The main issue of the other ticket appears to be fixed (on my end) but I'm still getting spam of Metalama error notifications via Windows notification system. You can read the earlier ticket to understand my project/package structure.

Today, I updated Metalama references from 2024.2.12-preview to 2024.2.14-rc in my root Atesh.Metalama library and I published it as a package.

When I update my Atesh.Metalama package in my Atesh project, I get this error below and the build fails.

Open-source Repo: git@bitbucket.org:XtroTheArctic/atesh.git Branch: feature/MetalamaUpgrade

Error message:

Metalama Version: 2024.2.14-rc Runtime: .NET Framework 4.8.4645.0 Processor Architecture: X64 OS Description: Microsoft Windows 10.0.22000 OS Architecture: X64 Exception type: System.InvalidOperationException Exception message: Failed to compare two elements in the array. ===== Exception ===== System.InvalidOperationException: Failed to compare two elements in the array. ---> Metalama.Framework.Engine.AssertionFailedException: Nodes 'Metalama.Patterns.Contracts.StrictlyPositiveAttribute:Build' and 'Metalama.Patterns.Contracts.StrictlyPositiveAttribute:Build' are not sorted. at Metalama.Framework.Engine.AspectOrdering.AspectLayerSorter.<>c__DisplayClass1_0.b10(Int32 i, Int32 j) at System.Collections.Generic.ArraySortHelper1.PickPivotAndPartition(T[] keys, Int32 lo, Int32 hi, IComparer1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(T[] keys, Int32 lo, Int32 hi, Int32 depthLimit, IComparer1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(T[] keys, Int32 lo, Int32 hi, Int32 depthLimit, IComparer1 comparer) at System.Collections.Generic.ArraySortHelper1.IntrospectiveSort(T[] keys, Int32 left, Int32 length, IComparer1 comparer) at System.Collections.Generic.GenericArraySortHelper1.Sort(T[] keys, Int32 index, Int32 length, IComparer1 comparer) --- End of inner exception stack trace --- at System.Collections.Generic.GenericArraySortHelper1.Sort(T[] keys, Int32 index, Int32 length, IComparer1 comparer) at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer1 comparer) at Metalama.Framework.Engine.AspectOrdering.AspectLayerSorter.TrySort(IReadOnlyCollection1 aspectClasses, IReadOnlyList1 relationships, IDiagnosticAdder diagnosticAdder, ImmutableArray1& sortedAspectLayers) at Metalama.Framework.Engine.Pipeline.AspectPipeline.TryInitialize(IDiagnosticAdder diagnosticAdder, Compilation compilation, ProjectLicenseInfo projectLicenseInfo, IReadOnlyList`1 compileTimeTreesHint, CancellationToken cancellationToken, AspectPipelineConfiguration& configuration) at Metalama.Framework.Engine.Pipeline.CompileTime.CompileTimeAspectPipeline.d3.MoveNext()

svick commented 4 months ago

Thanks for the report. I believe I understand what the problem is and a fix should be included in the next release of Metalama.

prochan2 commented 4 months ago

Hello, this bug has been fixed in Metalama 2024.1.24 and 2024.2.15-rc. Does the fix resolve your issue?

XtroTheArctic commented 4 months ago

This looks to be fixed. Thank you very much!