Skip to content

"Sequence contains no matching element" when building the Architecture #280

@Optano-Dev

Description

@Optano-Dev

Problem Description
In AddMethodDependencies.HandleIterator(), the first found instruction with new object op code is an ArgumentNullException. The TypeDefinition of the declaring type does not have a method named "MoveNext", which causes an InvalidOperationException since First() does not find a matching method definition.

Possible Cause
Usage of JetBrains.Annotations.NotNullAttribute in the method associated with the method body.

Possible Fix (?)
Find the first instruction with new object op code which at the same time is not an exception.

Stack Trace

System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at ArchUnitNET.Loader.LoadTasks.AddMethodDependencies.HandleIterator(MethodDefinition& methodDefinition, MethodBody& methodBody, List`1 bodyTypes, ICollection`1 visitedMethodReferences)
   at ArchUnitNET.Loader.LoadTasks.AddMethodDependencies.CreateMethodBodyDependencies(MethodDefinition methodDefinition, MethodMember methodMember)+MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at ArchUnitNET.Loader.LoadTasks.AddMethodDependencies.<>c.<Execute>b__4_3(ValueTuple`2 tuple)
   at ArchUnitNET.Domain.Extensions.EnumerableExtensions.ForEach[T](IEnumerable`1 source, Action`1[] actions)
   at ArchUnitNET.Loader.LoadTasks.AddMethodDependencies.Execute()
   at ArchUnitNET.Loader.LoadTaskRegistry.<ExecuteTasks>b__1_1(Type taskKey)
   at ArchUnitNET.Domain.Extensions.EnumerableExtensions.ForEach[T](IEnumerable`1 source, Action`1[] actions)
   at ArchUnitNET.Loader.LoadTaskRegistry.ExecuteTasks(List`1 taskOrder)
   at ArchUnitNET.Loader.ArchBuilder.UpdateTypeDefinitions()
   at ArchUnitNET.Loader.ArchBuilder.Build()
   at ArchUnitNET.Loader.ArchLoader.Build()

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions