Skip to content

Commit 4f49e7f

Browse files
Merge branch 'main' into feat/add_MSTestV4_support
2 parents b2f44e1 + aad79ad commit 4f49e7f

75 files changed

Lines changed: 3773 additions & 5845 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yaml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2020
- name: Setup .NET
2121
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
2222
with:
23-
dotnet-version: 9.0.305
23+
dotnet-version: 10.0.100
2424
- name: Install tools
2525
run: dotnet tool restore
2626
- name: Check formatting
@@ -30,11 +30,11 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Checkout
33-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3434
- name: Setup .NET
3535
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
3636
with:
37-
dotnet-version: 9.0.305
37+
dotnet-version: 10.0.100
3838
- name: Run tests
3939
run: dotnet test -c Debug --collect:"XPlat Code Coverage" --settings coverlet.runsettings ArchUnitNETTests/
4040
- name: Upload coverage reports to Codecov
@@ -49,11 +49,11 @@ jobs:
4949
runs-on: ${{ matrix.os }}
5050
steps:
5151
- name: Checkout
52-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
52+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
5353
- name: Setup .NET
5454
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
5555
with:
56-
dotnet-version: 9.0.305
56+
dotnet-version: 10.0.100
5757
- name: Run tests
5858
run: dotnet test -c Debug
5959
publish-docs:
@@ -67,35 +67,35 @@ jobs:
6767
contents: write
6868
steps:
6969
- name: Checkout
70-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
70+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
71+
with:
72+
path: ./current
73+
- name: Checkout gh-pages branch
74+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
75+
with:
76+
ref: gh-pages
77+
path: ./docs
7178
- name: Setup doxygen
7279
run: sudo apt-get install doxygen graphviz
73-
- name: Create temporary directory
80+
- name: Setup environment
7481
run: |
75-
tmpdir=$(mktemp -d -p "$GITHUB_WORKSPACE")
76-
mkdir -p $tmpdir
77-
relative_path=$(realpath --relative-to="$GITHUB_WORKSPACE" "$tmpdir")
78-
echo "Created temporary directory $tmpdir ($relative_path relative to $GITHUB_WORKSPACE)"
79-
echo "DOCS_TEMP_DIR=$relative_path" >> "$GITHUB_ENV"
8082
if [[ "$GITHUB_REF" =~ ^"refs/tags/"[0-9]+.[0-9]+.[0-9]+$ ]]; then
81-
echo "DOCS_TEMP_DIR_SUBPATH=stable" >> "$GITHUB_ENV"
83+
docs_subpath="stable"
8284
else
8385
if [[ "$GITHUB_REF" =~ ^"refs/tags/"[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+$ ]]; then
84-
echo "DOCS_TEMP_DIR_SUBPATH=preview" >> "$GITHUB_ENV"
86+
docs_subpath="preview"
8587
else
86-
echo "DOCS_TEMP_DIR_SUBPATH=latest" >> "$GITHUB_ENV"
88+
docs_subpath="latest"
8789
fi
8890
fi
89-
- name: Checkout gh-pages branch
90-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
91-
with:
92-
ref: gh-pages
93-
path: ${{ env.DOCS_TEMP_DIR }}
91+
echo "DOCS_TEMP_DIR_SUBPATH=$docs_subpath" >> "$GITHUB_ENV"
92+
echo "DOCS_OUTPUT_DIR=$GITHUB_WORKSPACE/docs/$docs_subpath" >> "$GITHUB_ENV"
9493
- name: Generate documentation
95-
working-directory: ${{ env.DOCS_TEMP_DIR }}/${{ env.DOCS_TEMP_DIR_SUBPATH }}
94+
working-directory: ./current/documentation
9695
run: |
97-
rm -rf '*'
98-
doxygen "$GITHUB_WORKSPACE/documentation/Doxyfile"
96+
set -eo pipefail
97+
rm -rf "${{ env.DOCS_OUTPUT_DIR }}"
98+
doxygen
9999
touch .nojekyll
100100
- name: Check release conditions
101101
run: |
@@ -106,7 +106,7 @@ jobs:
106106
fi
107107
- name: Commit and push changes
108108
if: env.CREATE_RELEASE == 'true'
109-
working-directory: ${{ env.DOCS_TEMP_DIR }}
109+
working-directory: ./docs
110110
run: |
111111
git config --global user.name "GitHub Actions"
112112
git config --global user.email "publish-docs@github.com"
@@ -119,6 +119,7 @@ jobs:
119119
fi
120120
- name: Update readthedocs preview
121121
if: env.CREATE_RELEASE == 'true' && env.DOCS_TEMP_DIR_SUBPATH == 'preview'
122+
working-directory: ./docs
122123
run: |
123124
git fetch origin preview
124125
git checkout preview
@@ -135,11 +136,11 @@ jobs:
135136
- run-tests
136137
steps:
137138
- name: Checkout
138-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
139+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
139140
- name: Setup .NET
140141
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
141142
with:
142-
dotnet-version: 9.0.305
143+
dotnet-version: 10.0.100
143144
- name: Build
144145
run: dotnet build -c Release
145146
- name: Pack

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ jobs:
2121
language: ["csharp"]
2222
steps:
2323
- name: Checkout repository
24-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2525
- name: Initialize CodeQL
26-
uses: github/codeql-action/init@303c0aef88fc2fe5ff6d63d3b1596bfd83dfa1f9 # v3.30.4
26+
uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
2727
with:
2828
languages: ${{ matrix.language }}
2929
- name: Autobuild
30-
uses: github/codeql-action/autobuild@303c0aef88fc2fe5ff6d63d3b1596bfd83dfa1f9 # v3.30.4
30+
uses: github/codeql-action/autobuild@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
3131
- name: Perform CodeQL Analysis
32-
uses: github/codeql-action/analyze@303c0aef88fc2fe5ff6d63d3b1596bfd83dfa1f9 # v3.30.4
32+
uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
3333
with:
3434
category: "/language:${{matrix.language}}"

ArchUnitNET.MSTestV2Tests/ArchUnitNET.MSTestV2Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
<Company>TNG Technology Consulting GmbH</Company>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

ArchUnitNET.NUnitTests/ArchUnitNET.NUnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
<Company>TNG Technology Consulting GmbH</Company>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

ArchUnitNET.TUnitTests/ArchUnitNET.TUnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
<Company>TNG Technology Consulting GmbH</Company>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

ArchUnitNET.xUnitTests/ArchUnitNET.xUnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
<Company>TNG Technology Consulting GmbH</Company>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

ArchUnitNET.xUnitV3Tests/ArchUnitNET.xUnitV3Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
<Company>TNG Technology Consulting GmbH</Company>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

ArchUnitNET/Domain/Extensions/AttributeExtensions.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34

45
namespace ArchUnitNET.Domain.Extensions
@@ -26,5 +27,28 @@ public static bool OnlyHasAttributesMatching(this IHasAttributes a, string patte
2627
return a.Attributes.IsNullOrEmpty()
2728
|| a.Attributes.All(attribute => attribute.FullNameMatches(pattern));
2829
}
30+
31+
internal static IEnumerable<object> GetAllAttributeArgumentValues(
32+
this AttributeInstance instance
33+
) =>
34+
instance
35+
.AttributeArguments.Select(arg => arg.Value)
36+
.Select(value =>
37+
value is ITypeInstance<IType> typeInstance ? typeInstance.Type : value
38+
);
39+
40+
internal static IEnumerable<(string, object)> GetAllNamedAttributeArgumentTuples(
41+
this AttributeInstance instance
42+
) =>
43+
instance
44+
.AttributeArguments.OfType<AttributeNamedArgument>()
45+
.Select(arg =>
46+
(
47+
arg.Name,
48+
arg.Value is ITypeInstance<IType> typeInstance
49+
? typeInstance.Type
50+
: arg.Value
51+
)
52+
);
2953
}
3054
}

ArchUnitNET/Domain/Extensions/EnumerableExtensions.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,45 @@ public static string FormatDescription<T>(
4242
return $"{multipleDescription} {string.Join(" and ", list.Select(elementDescription))}";
4343
}
4444
}
45+
46+
internal static IEnumerable<object> ResolveAttributeArguments(
47+
this IEnumerable<object> objects,
48+
Architecture architecture
49+
)
50+
{
51+
return objects.Select(obj =>
52+
obj is Type type ? architecture.GetITypeOfType(type) : obj
53+
);
54+
}
55+
56+
internal static IEnumerable<(string, object)> ResolveNamedAttributeArgumentTuples(
57+
this IEnumerable<(string, object)> namedArguments,
58+
Architecture architecture
59+
)
60+
{
61+
return namedArguments.Select(arg =>
62+
(arg.Item1, arg.Item2 is Type type ? architecture.GetITypeOfType(type) : arg.Item2)
63+
);
64+
}
65+
66+
/// <summary>
67+
/// Creates a lookup function for the given collection of elements.
68+
/// For smaller collections, it uses the Contains method of the collection directly.
69+
/// For larger collections, it creates a HashSet for O(1) average time complexity lookups.
70+
/// </summary>
71+
///
72+
/// <typeparam name="T">The type of elements in the collection.</typeparam>
73+
///
74+
/// <param name="elements">The collection of elements to create a lookup function for.</param>
75+
///
76+
/// <returns>A function that checks if an element is in the collection.</returns>
77+
public static Func<T, bool> CreateLookupFn<T>(ICollection<T> elements)
78+
{
79+
if (elements.Count < 20)
80+
{
81+
return elements.Contains;
82+
}
83+
return new HashSet<T>(elements).Contains;
84+
}
4585
}
4686
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
4+
namespace ArchUnitNET.Domain.Extensions
5+
{
6+
internal static class ICanBeAnalyzedExtensions
7+
{
8+
internal static IEnumerable<object> GetAllAttributeArgumentValues(
9+
this ICanBeAnalyzed obj,
10+
Attribute attribute = null
11+
)
12+
{
13+
var attributeInstances =
14+
attribute == null
15+
? obj.AttributeInstances
16+
: obj.AttributeInstances.Where(instance => instance.Type.Equals(attribute));
17+
return attributeInstances
18+
.SelectMany(instance => instance.AttributeArguments.Select(arg => arg.Value))
19+
.Select(value =>
20+
value is ITypeInstance<IType> typeInstance ? typeInstance.Type : value
21+
);
22+
}
23+
24+
internal static IEnumerable<(string, object)> GetAllNamedAttributeArgumentTuples(
25+
this ICanBeAnalyzed obj,
26+
Attribute attribute = null
27+
)
28+
{
29+
var attributeInstances =
30+
attribute == null
31+
? obj.AttributeInstances
32+
: obj.AttributeInstances.Where(instance => instance.Type.Equals(attribute));
33+
return attributeInstances.SelectMany(instance =>
34+
instance
35+
.AttributeArguments.OfType<AttributeNamedArgument>()
36+
.Select(arg =>
37+
(
38+
arg.Name,
39+
arg.Value is ITypeInstance<IType> typeInstance
40+
? typeInstance.Type
41+
: arg.Value
42+
)
43+
)
44+
);
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)