@@ -12,6 +12,11 @@ namespace LibGit2Sharp.Tests
12
12
{
13
13
public class MetaFixture
14
14
{
15
+ private static readonly HashSet < Type > explicitOnlyInterfaces = new HashSet < Type >
16
+ {
17
+ typeof ( IBelongToARepository ) ,
18
+ } ;
19
+
15
20
[ Fact ]
16
21
public void PublicTestMethodsAreFactsOrTheories ( )
17
22
{
@@ -114,7 +119,7 @@ public void LibGit2SharpPublicInterfacesCoverAllPublicMembers()
114
119
var methodsMissingFromInterfaces =
115
120
from t in Assembly . GetAssembly ( typeof ( IRepository ) ) . GetExportedTypes ( )
116
121
where ! t . IsInterface
117
- where t . GetInterfaces ( ) . Any ( i => i . IsPublic && i . Namespace == typeof ( IRepository ) . Namespace )
122
+ where t . GetInterfaces ( ) . Any ( i => i . IsPublic && i . Namespace == typeof ( IRepository ) . Namespace && ! explicitOnlyInterfaces . Contains ( i ) )
118
123
let interfaceTargetMethods = from i in t . GetInterfaces ( )
119
124
from im in t . GetInterfaceMap ( i ) . TargetMethods
120
125
select im
@@ -126,6 +131,24 @@ from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | Bindin
126
131
methodsMissingFromInterfaces . ToArray ( ) ) ) ;
127
132
}
128
133
134
+ [ Fact ]
135
+ public void LibGit2SharpExplicitOnlyInterfacesAreIndeedExplicitOnly ( )
136
+ {
137
+ var methodsMissingFromInterfaces =
138
+ from t in Assembly . GetAssembly ( typeof ( IRepository ) ) . GetExportedTypes ( )
139
+ where t . GetInterfaces ( ) . Any ( explicitOnlyInterfaces . Contains )
140
+ let interfaceTargetMethods = from i in t . GetInterfaces ( )
141
+ where explicitOnlyInterfaces . Contains ( i )
142
+ from im in t . GetInterfaceMap ( i ) . TargetMethods
143
+ select im
144
+ from tm in t . GetMethods ( BindingFlags . DeclaredOnly | BindingFlags . Public | BindingFlags . Instance )
145
+ where interfaceTargetMethods . Contains ( tm )
146
+ select t . Name + " has public method " + tm . Name + " which should be explicitly implemented." ;
147
+
148
+ Assert . Equal ( "" , string . Join ( Environment . NewLine ,
149
+ methodsMissingFromInterfaces . ToArray ( ) ) ) ;
150
+ }
151
+
129
152
[ Fact ]
130
153
public void EnumsWithFlagsHaveMutuallyExclusiveValues ( )
131
154
{
0 commit comments