private bool IsInvalidCall(MethodNode callingMethod, MethodNode calledMethod) { var aggregateOfCalledMethod = this.aggregateForMethod.GetOrDefault(calledMethod); var aggregateOfCallingMethod = this.aggregateForMethod.GetOrDefault(callingMethod); return PatternMatch.For<Tuple<AggregateNode, AggregateNode>, bool>() .When(x => x.Item1 == x.Item2).Return(_ => false) .When(x => x.Item1 == null && x.Item2 == null).Return(_ => false) .When(x => x.Item1 != null && x.Item2 == null).Return(_ => false) .When(x => x.Item1 == null && x.Item2 != null).Return(t => calledMethod.GetContainer() != aggregateOfCalledMethod) .Default(_ => true) .Match(Tuple.Create(aggregateOfCallingMethod, aggregateOfCalledMethod)); }
public SequencePoint[] GetSequencePointsForMethod(MethodNode method) { var dispenser = new MetaDataDispenser(); var assemblyFile = method.Method.DeclaringType.Assembly.Location; object importer; ((IMetaDataDispenser)dispenser).OpenScope(assemblyFile, 0, ImporterIid, out importer); ISymbolReader reader; var searchPath = Path.GetDirectoryName(assemblyFile); if (binder.TryGetReaderForFile(importer, assemblyFile, searchPath, out reader) == LoadSymbolsResult.Success) { var methodReader = reader.GetMethod(new SymbolToken(method.Method.MetadataToken)); return methodReader.GetSequencePoints(); } else { return new[] {SequencePoint.Empty}; } }
public ImmutableTypeSetsPropertyOutsideOfConstructorViolation(TypeNode violatingType, MethodNode violatingMethod) { this.Node = violatingType; this.ViolatingMethod = violatingMethod; }
public bool IsApplyEventMethod(MethodNode node) { var parameters = node.Method.GetParameters(); return !node.Method.IsStatic && node.Method.Name == "On" && parameters.Length == 1 && typeof (DomainEvent).IsAssignableFrom(parameters[0].ParameterType); }
public Type GetEventAppliedByMethod(MethodNode node) { return node.Method.GetParameters()[0].ParameterType; }
private SourceLocation? FindSourceLocation(Instruction instruction, MethodNode methodNode) { var sequencePoints = this.symbols.GetSequencePointsForMethod(methodNode); return sequencePoints.NearestSequencePoint(instruction).Location; }
public DoNotCallEntityMethodsFromOutsideOfAggregateViolation(MethodNode callingNode, MethodNode calledMethod) { this.Node = callingNode; this.CalledMethod = calledMethod; }
public ApplyEventMethod(MethodNode node, Type appliedEventType) : base(node.Method) { this.AppliedEventType = appliedEventType; }