protected override TestAnalysisContext CreateContext( TestAnalyzeOptions options, IAnalysisLogger logger, RuntimeConditions runtimeErrors, PropertiesDictionary policy = null, string filePath = null) { TestAnalysisContext context = base.CreateContext(options, logger, runtimeErrors, policy, filePath); if (context.Policy == null) { context.Policy = new PropertiesDictionary(); context.Policy.SetProperty(TestRule.Behaviors, options.TestRuleBehaviors.AccessibleWithinContextOnly()); } TestRuleBehaviors behaviors = context.Policy.GetProperty(TestRule.Behaviors); context.IsValidAnalysisTarget = !behaviors.HasFlag(TestRuleBehaviors.RegardAnalysisTargetAsInvalid); context.TargetLoadException = behaviors.HasFlag(TestRuleBehaviors.RegardAnalysisTargetAsCorrupted) ? new InvalidOperationException() : null; context.Options = options; return(context); }
public TestRule() { if (s_testRuleBehaviors.HasFlag(TestRuleBehaviors.RaiseExceptionInvokingConstructor)) { throw new InvalidOperationException(nameof(TestRuleBehaviors.RaiseExceptionInvokingConstructor)); } }