Skip to content

Commit 86d8aa2

Browse files
author
Jake Ginnivan
committed
Exclude compiler generated types by default
1 parent 8c27b1e commit 86d8aa2

File tree

1 file changed

+10
-2
lines changed
  • TestStack.ConventionTests/ConventionData

1 file changed

+10
-2
lines changed

TestStack.ConventionTests/ConventionData/Types.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Linq;
6+
using System.Runtime.CompilerServices;
67

78
/// <summary>
89
/// This is where we set what our convention is all about.
@@ -20,12 +21,19 @@ public Types(string descriptionOfTypes)
2021

2122
public bool HasData {get { return TypesToVerify.Any(); }}
2223

23-
public static Types InAssemblyOf<T>()
24+
public static Types InAssemblyOf<T>(bool excludeCompilerGeneratedTypes = true)
2425
{
2526
var assembly = typeof(T).Assembly;
27+
var typesToVerify = assembly.GetTypes();
28+
if (excludeCompilerGeneratedTypes)
29+
{
30+
typesToVerify = typesToVerify
31+
.Where(t => !t.GetCustomAttributes(typeof (CompilerGeneratedAttribute), true).Any())
32+
.ToArray();
33+
}
2634
return new Types(assembly.GetName().Name)
2735
{
28-
TypesToVerify = assembly.GetTypes()
36+
TypesToVerify = typesToVerify
2937
};
3038
}
3139

0 commit comments

Comments
 (0)