Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ArchUnit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchUnitNET.TUnitTests", "A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceAssembly", "TestAssemblies\InterfaceAssembly\InterfaceAssembly.csproj", "{076E223C-32D3-4672-8B00-925CDBC1383E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilteredDirectoryAssemblyAttributeAssembly", "TestAssemblies\FilteredDirectoryAssemblyAttributeAssembly\FilteredDirectoryAssemblyAttributeAssembly.csproj", "{AA695589-8CCC-4474-9A7F-01A6376C375A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilteredDirectoryUnavailableTypesAssembly", "TestAssemblies\FilteredDirectoryUnavailableTypesAssembly\FilteredDirectoryUnavailableTypesAssembly.csproj", "{AA695589-8CCC-4474-9A7F-01A6376C375A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
7 changes: 5 additions & 2 deletions ArchUnitNET/Loader/MonoCecilAttributeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ TypeFactory typeFactory
attributeTypeReference
);
var attribute = attributeType.Type as Attribute;
if (attributeType.Type is UnavailableType unavailableType)
if (
attribute == null
&& (attributeType.Type is UnavailableType || attributeType.Type is Class)
)
{
attribute = new Attribute(unavailableType, null, null);
attribute = new Attribute(attributeType.Type, null, null);
}
if (attribute == null)
{
Expand Down
2 changes: 1 addition & 1 deletion ArchUnitNETTests/Loader/ArchLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void UnavailableTypeTest()
System.IO.SearchOption.AllDirectories
)
.Build();
Assert.Single(architecture.Types);
Assert.Equal(3, architecture.Types.Count());
var loggerType = architecture.ReferencedTypes.WhereFullNameIs("Serilog.ILogger");
Assert.NotNull(loggerType);
Assert.True(loggerType is UnavailableType);
Expand Down

This file was deleted.

8 changes: 7 additions & 1 deletion TestAssemblies/FilteredDirectoryLoaderTestAssembly/Class1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FilteredDirectoryUnavailableTypesAssembly;
using Serilog;

[assembly: FilteredDirectoryAssemblyAttributeAssembly.AssemblyAttribute]
[assembly: Assembly]

namespace FilteredDirectoryLoaderTestAssembly;

Expand All @@ -13,3 +14,8 @@ public Class1()
this.logger = new LoggerConfiguration().CreateLogger();
}
}

public class DerivedAttribute : BaseAttribute { }

[Derived]
public class ClassWithDerivedAttribute { }
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FilteredDirectoryAssemblyAttributeAssembly\FilteredDirectoryAssemblyAttributeAssembly.csproj">
<ProjectReference Include="..\FilteredDirectoryUnavailableTypesAssembly\FilteredDirectoryUnavailableTypesAssembly.csproj">
<!-- Do not copy the referenced assembly to the output directory -->
<!-- in order to test handling of unavailable types as attribute assemblies -->
<Private>False</Private>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<RootNamespace>FilteredDirectoryUnavailableTypesAssembly</RootNamespace>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace FilteredDirectoryUnavailableTypesAssembly;

[AttributeUsage(AttributeTargets.Assembly)]
public class AssemblyAttribute : Attribute { }

[AttributeUsage(AttributeTargets.All)]
public class BaseAttribute : Attribute { }
Loading