public void Library() { AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(Assembly.GetExecutingAssembly().Location); // this (unit test) assembly is a library (dll) and has no entry point Assert.AreEqual(RuleResult.DoesNotApply, runner.CheckAssembly(assembly)); }
/// <summary> /// Runs the rule, depending on its type. /// </summary> private RuleResult RunRule(TMetadataToken token) { if (token == null) { throw new ArgumentNullException("token"); } MethodDefinition md = (token as MethodDefinition); if (md != null) { if (FireEvents) { runner.OnAssembly(md.DeclaringType.Module.Assembly); runner.OnType(md.DeclaringType); runner.OnMethod(md); } return(runner.CheckMethod(token as MethodDefinition)); } TypeDefinition td = (token as TypeDefinition); if (td != null) { if (FireEvents) { runner.OnAssembly(md.DeclaringType.Module.Assembly); runner.OnType(md.DeclaringType); } return(runner.CheckType(td)); } AssemblyDefinition ad = (token as AssemblyDefinition); if (ad != null) { if (FireEvents) { runner.OnAssembly(td.Module.Assembly); } return(runner.CheckAssembly(ad)); } throw new NotImplementedException(token.GetType().ToString()); }
public void TestNoEntryPoint() { Assert.AreEqual(RuleResult.DoesNotApply, runner.CheckAssembly(assembly)); }
public void TestGoodIntMainAssembly() { Assert.AreEqual(RuleResult.Success, runner.CheckAssembly(GetAssemblyAndInject <GoodIntMainClass> ())); }