8000 Ensure no public type lies under Core namespace · GiTechLab/libgit2sharp@3a3c93c · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a3c93c

Browse files
committed
Ensure no public type lies under Core namespace
1 parent ade0998 commit 3a3c93c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

LibGit2Sharp.Tests/MetaFixture.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,5 +267,37 @@ public void GetEnumeratorMethodsInLibGit2SharpMustBeVirtualForTestability()
267267
Assert.True(false, Environment.NewLine + sb.ToString());
268268
}
269269
}
270+
271+
[Fact]
272+
public void NoPublicTypesUnderLibGit2SharpCoreNamespace()
273+
{
274+
const string coreNamespace = "LibGit2Sharp.Core";
275+
276+
var types = Assembly.GetAssembly(typeof(IRepository))
277+
.GetExportedTypes()
278+
.Where(t => t.FullName.StartsWith(coreNamespace + "."))
279+
280+
// Ugly hack to circumvent a Mono bug
281+
// cf. https://bugzilla.xamarin.com/show_bug.cgi?id=27010
282+
.Where(t => !t.FullName.Contains("+"))
283+
284+
#if LEAKS_IDENTIFYING
285+
.Where(t => t != typeof(LibGit2Sharp.Core.LeaksContainer))
286+
#endif
287+
.ToList();
288+
289+
if (types.Any())
290+
{
291+
var sb = new StringBuilder();
292+
293+
foreach (var type in types)
294+
{
295+
sb.AppendFormat("Public type '{0}' under the '{1}' namespace.{2}",
296+
type.FullName, coreNamespace, Environment.NewLine);
297+
}
298+
299+
Assert.True(false, Environment.NewLine + sb.ToString());
300+
}
301+
}
270302
}
271303
}

0 commit comments

Comments
 (0)
0