Skip to content

Instantly share code, notes, and snippets.

@rdingwall
Created December 29, 2011 13:24
Show Gist options
  • Save rdingwall/1534102 to your computer and use it in GitHub Desktop.
Save rdingwall/1534102 to your computer and use it in GitHub Desktop.
Find types with static ctors (.cctor)
[TestFixture]
public class FindStaticCtors
{
[Test]
public void Foo()
{
var typesWithCctors = new[]
{
Assembly.GetAssembly(typeof(xyz)),
Assembly.GetExecutingAssembly(),
Assembly.GetAssembly(typeof(abc))
}.SelectMany(a => a.GetTypes())
.Where(t => t.GetConstructors(BindingFlags.Static).Any())
.Select(t => t.Name);
typesWithCctors.ShouldBeEmpty();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment