Skip to content

Commit 9eae0f7

Browse files
Merge pull request #396 from TNG/389-missing-method-implementinterfacematching
Add ImplementAny Fluent Syntax
2 parents 929d0cb + 5b6e74d commit 9eae0f7

24 files changed

Lines changed: 2026 additions & 58 deletions

.csharpierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
ArchUnitNETTests/Fluent/Syntax/Elements/ObjectSyntaxElementsTests.cs
1+
ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs
2+
ArchUnitNETTests/Fluent/Syntax/Elements/ObjectSyntaxElementsTests.cs

ArchUnit.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchUnitNET.TUnit", "ArchUn
4444
EndProject
4545
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchUnitNET.TUnitTests", "ArchUnitNET.TUnitTests\ArchUnitNET.TUnitTests.csproj", "{C54143CE-3256-4313-B991-0706705EEA1D}"
4646
EndProject
47+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceAssembly", "TestAssemblies\InterfaceAssembly\InterfaceAssembly.csproj", "{076E223C-32D3-4672-8B00-925CDBC1383E}"
48+
EndProject
4749
Global
4850
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4951
Debug|Any CPU = Debug|Any CPU
@@ -130,6 +132,10 @@ Global
130132
{C54143CE-3256-4313-B991-0706705EEA1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
131133
{C54143CE-3256-4313-B991-0706705EEA1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
132134
{C54143CE-3256-4313-B991-0706705EEA1D}.Release|Any CPU.Build.0 = Release|Any CPU
135+
{076E223C-32D3-4672-8B00-925CDBC1383E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
136+
{076E223C-32D3-4672-8B00-925CDBC1383E}.Debug|Any CPU.Build.0 = Debug|Any CPU
137+
{076E223C-32D3-4672-8B00-925CDBC1383E}.Release|Any CPU.ActiveCfg = Release|Any CPU
138+
{076E223C-32D3-4672-8B00-925CDBC1383E}.Release|Any CPU.Build.0 = Release|Any CPU
133139
EndGlobalSection
134140
GlobalSection(SolutionProperties) = preSolution
135141
HideSolutionNode = FALSE
@@ -141,5 +147,6 @@ Global
141147
{0243F2D4-AC89-4561-A936-D647B6BB821F} = {B1191F18-91CB-4387-B775-A5EB64D3AC30}
142148
{5A24529B-1794-4080-ADCC-77440BA0A0B3} = {B1191F18-91CB-4387-B775-A5EB64D3AC30}
143149
{E6CB8C69-25F5-4C94-8EA3-D56E444EB46B} = {B1191F18-91CB-4387-B775-A5EB64D3AC30}
150+
{076E223C-32D3-4672-8B00-925CDBC1383E} = {B1191F18-91CB-4387-B775-A5EB64D3AC30}
144151
EndGlobalSection
145152
EndGlobal

ArchUnit.sln.DotSettings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String>
44
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String>
55
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String>
6-
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue"></s:String>
6+
77
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
88
<s:String x:Key="/Default/CustomTools/CustomToolsData/@EntryValue"></s:String>
9+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECodeCleanup_002EFileHeader_002EFileHeaderSettingsMigrate/@EntryIndexedValue">True</s:Boolean>
910
<s:Boolean x:Key="/Default/UserDictionary/Words/=archrule/@EntryIndexedValue">True</s:Boolean>
1011
<s:Boolean x:Key="/Default/UserDictionary/Words/=intf/@EntryIndexedValue">True</s:Boolean>
1112
<s:Boolean x:Key="/Default/UserDictionary/Words/=lambda/@EntryIndexedValue">True</s:Boolean>

ArchUnitNET/Fluent/Conditions/RelationCondition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ string failDescription
2828

2929
public ICondition<TRuleType> GetCondition(IEnumerable<TRelatedType> objects)
3030
{
31-
return _relation(new ListObjectProvider<TRelatedType>(objects.ToList()));
31+
return _relation(new ObjectProvider<TRelatedType>(objects.ToList()));
3232
}
3333

3434
private bool Equals(RelationCondition<TRuleType, TRelatedType> other)
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44

55
namespace ArchUnitNET.Fluent
66
{
7-
public class ListObjectProvider<T> : ISizedObjectProvider<T>
7+
public class ObjectProvider<T> : ISizedObjectProvider<T>
88
where T : ICanBeAnalyzed
99
{
10-
private readonly IEnumerable<T> _objects;
10+
private readonly List<T> _objects;
1111

12-
public ListObjectProvider(List<T> objects)
12+
public ObjectProvider()
13+
: this(new List<T>()) { }
14+
15+
public ObjectProvider(IEnumerable<T> objects)
1316
{
14-
_objects = objects;
15-
Description = string.Join(" or ", objects.Select(obj => $"\"{obj.FullName}\""));
17+
_objects = objects.ToList();
18+
Description = string.Join(" or ", _objects.Select(obj => $"\"{obj.FullName}\""));
1619
}
1720

1821
public string Description { get; }
@@ -24,7 +27,7 @@ public IEnumerable<T> GetObjects(Architecture architecture)
2427
return _objects;
2528
}
2629

27-
private bool Equals(ListObjectProvider<T> other)
30+
private bool Equals(ObjectProvider<T> other)
2831
{
2932
return string.Equals(Description, other.Description);
3033
}
@@ -41,7 +44,7 @@ public override bool Equals(object obj)
4144
return true;
4245
}
4346

44-
return obj.GetType() == GetType() && Equals((ListObjectProvider<T>)obj);
47+
return obj.GetType() == GetType() && Equals((ObjectProvider<T>)obj);
4548
}
4649

4750
public override int GetHashCode()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using ArchUnitNET.Domain;
2+
3+
namespace ArchUnitNET.Fluent.Syntax
4+
{
5+
public static class DescriptionHelpers
6+
{
7+
public static string SelectDescription<T>(
8+
string emptyDescription,
9+
string singleDescription,
10+
string multipleDescription,
11+
IObjectProvider<T> objectProvider
12+
)
13+
{
14+
if (!(objectProvider is ISizedObjectProvider<T> sizedObjectProvider))
15+
{
16+
return $"{multipleDescription} {objectProvider.Description}";
17+
}
18+
19+
switch (sizedObjectProvider.Count)
20+
{
21+
case 0:
22+
return emptyDescription;
23+
case 1:
24+
return $"{singleDescription} {objectProvider.Description}";
25+
}
26+
return $"{multipleDescription} {objectProvider.Description}";
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)