I get "Sequence contains no matching element" exception while trying to load recursively assembly that has c++ project dependencies.
The problem reside in TypeFactory class line 180 or so.
typeDefinition.CustomAttributes.Any(att => att.AttributeType.FullName == typeof(UnsafeValueTypeAttribute).FullName)
returns two attributes - UnsafeValueTypeAttribute and NativeCppClassAttribute
typeDefinition FullName looks like .$ArrayType$$$BY0GC@$$CB_W
typeDefinition.Fields has no fields so trying to get them leads to an exception here:
var arrayType = typeDefinition.Fields.First(field => field.Name == "FixedElementField").FieldType;
Stack trace looks like that:
System.InvalidOperationException
Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at ArchUnitNET.Loader.TypeFactory.CreateTypeFromTypeReference(TypeReference typeReference, Boolean isStub) in \ArchUnitNET\Loader\TypeFactory.cs:line 188
at ArchUnitNET.Loader.TypeFactory.<>cDisplayClass7_0.b0(String s) in \ArchUnitNET\Loader\TypeFactory.cs:line 51
at ArchUnitNET.Loader.RegistryUtils.GetFromDictOrCreateAndAdd[T,TK](TK key, Dictionary2 dict, Func2 createFunc) in \ArchUnitNET\Loader\RegistryUtils.cs:line 21
at ArchUnitNET.Loader.TypeRegistry.GetOrCreateTypeFromTypeReference(TypeReference typeReference, Func`2 createFunc) in \ArchUnitNET\Loader\TypeRegistry.cs:line 24
at ArchUnitNET.Loader.TypeFactory.GetOrCreateTypeFromTypeReference(TypeReference typeReference) in \ArchUnitNET\Loader\TypeFactory.cs:line 50
at ArchUnitNET.Loader.ArchBuilder.<>cDisplayClass15_0.b3(TypeDefinition typeDefinition) in \ArchUnitNET\Loader\ArchBuilder.cs:line 84
at ArchUnitNET.Domain.Extensions.EnumerableExtensions.ForEach[T](IEnumerable1 source, Action1[] actions) in \ArchUnitNET\Domain\Extensions\EnumerableExtensions.cs:line 21
at ArchUnitNET.Loader.ArchBuilder.LoadTypesForModule(ModuleDefinition module, String namespaceFilter) in \ArchUnitNET\Loader\ArchBuilder.cs:line 79
at ArchUnitNET.Loader.ArchLoader.LoadModule(String fileName, String nameSpace, Boolean includeDependencies, Boolean recursive, FilterFunc filterFunc) in \ArchUnitNET\Loader\ArchLoader.cs:line 144
at ArchUnitNET.Loader.ArchLoader.LoadAssembliesRecursively(IEnumerable`1 assemblies, FilterFunc filterFunc) in \ArchUnitNET\Loader\ArchLoader.cs:line 205
at Architecture.Tests.ArchUnitExtensions.LoadAssemblyRecursively(ArchLoader loader, String assemblyName)
I get "Sequence contains no matching element" exception while trying to load recursively assembly that has c++ project dependencies. The problem reside in TypeFactory class line 180 or so. typeDefinition.CustomAttributes.Any(att => att.AttributeType.FullName == typeof(UnsafeValueTypeAttribute).FullName) returns two attributes - UnsafeValueTypeAttribute and NativeCppClassAttribute typeDefinition FullName looks like.$ArrayType$$$BY0GC@$$CB_W
typeDefinition.Fields has no fields so trying to get them leads to an exception here: var arrayType = typeDefinition.Fields.First(field => field.Name == "FixedElementField").FieldType;
Stack trace looks like that: System.InvalidOperationException Sequence contains no matching element at System.Linq.ThrowHelper.ThrowNoMatchException() at System.Linq.Enumerable.First[TSource](IEnumerableb0(String s) in \ArchUnitNET\Loader\TypeFactory.cs:line 51
at ArchUnitNET.Loader.RegistryUtils.GetFromDictOrCreateAndAdd[T,TK](TK key, Dictionaryb 3(TypeDefinition typeDefinition) in \ArchUnitNET\Loader\ArchBuilder.cs:line 84
at ArchUnitNET.Domain.Extensions.EnumerableExtensions.ForEach[T](IEnumerable
1 source, Func
2 predicate) at ArchUnitNET.Loader.TypeFactory.CreateTypeFromTypeReference(TypeReference typeReference, Boolean isStub) in \ArchUnitNET\Loader\TypeFactory.cs:line 188 at ArchUnitNET.Loader.TypeFactory.<>cDisplayClass7_0.2 dict, Func
2 createFunc) in \ArchUnitNET\Loader\RegistryUtils.cs:line 21 at ArchUnitNET.Loader.TypeRegistry.GetOrCreateTypeFromTypeReference(TypeReference typeReference, Func`2 createFunc) in \ArchUnitNET\Loader\TypeRegistry.cs:line 24 at ArchUnitNET.Loader.TypeFactory.GetOrCreateTypeFromTypeReference(TypeReference typeReference) in \ArchUnitNET\Loader\TypeFactory.cs:line 50 at ArchUnitNET.Loader.ArchBuilder.<>cDisplayClass15_0.1 source, Action
1[] actions) in \ArchUnitNET\Domain\Extensions\EnumerableExtensions.cs:line 21 at ArchUnitNET.Loader.ArchBuilder.LoadTypesForModule(ModuleDefinition module, String namespaceFilter) in \ArchUnitNET\Loader\ArchBuilder.cs:line 79 at ArchUnitNET.Loader.ArchLoader.LoadModule(String fileName, String nameSpace, Boolean includeDependencies, Boolean recursive, FilterFunc filterFunc) in \ArchUnitNET\Loader\ArchLoader.cs:line 144 at ArchUnitNET.Loader.ArchLoader.LoadAssembliesRecursively(IEnumerable`1 assemblies, FilterFunc filterFunc) in \ArchUnitNET\Loader\ArchLoader.cs:line 205 at Architecture.Tests.ArchUnitExtensions.LoadAssemblyRecursively(ArchLoader loader, String assemblyName)