void TestSagaDefinition <TSagaType>(ModuleDefinition moduleToUse = null) { #pragma warning disable IDE0079 // Remove unnecessary suppression #pragma warning disable IDE0054 //False positive moduleToUse = moduleToUse ?? module; #pragma warning restore IDE0054 //False positive #pragma warning restore IDE0079 // Remove unnecessary suppression var dataType = moduleToUse.GetTypeDefinition <TSagaType>(); var instructions = InstructionAnalyzer.GetConfigureHowToFindSagaInstructions(dataType); var results = new SagaInspectionResults { HasUnmanagedCalls = InstructionAnalyzer.CallsUnmanagedMethods(instructions), HasUnexpectedCalls = InstructionAnalyzer.CallsUnexpectedMethods(instructions), HasBranchingLogic = InstructionAnalyzer.ContainsBranchingLogic(instructions) }; try { SagaDefinitionReader.TryGetSagaDefinition(dataType, out results.SagaDefinition); } catch (Exception x) { results.Exception = x.Message; } Approver.Verify(results); }
private void TestSagaDefinition <TSagaType>(ModuleDefinition moduleToUse = null) { moduleToUse = moduleToUse ?? module; var dataType = moduleToUse.GetTypeDefinition <TSagaType>(); var instructions = InstructionAnalyzer.GetConfigureHowToFindSagaInstructions(dataType); var results = new SagaInspectionResults { HasUnmanagedCalls = InstructionAnalyzer.CallsUnmanagedMethods(instructions), HasUnexpectedCalls = InstructionAnalyzer.CallsUnexpectedMethods(instructions), HasBranchingLogic = InstructionAnalyzer.ContainsBranchingLogic(instructions) }; try { SagaDefinitionReader.TryGetSagaDefinition(dataType, out results.SagaDefinition); } catch (Exception x) { results.Exception = x.Message; } Approver.Verify(results); }
public override bool VisitMnemonic_body(Mnemonic_bodyContext context) { //命令語は命令語で解析 if (!InstructionAnalyzer.TryAnalyze(context.instruction(), out var instInfo)) { return(false); } //オペランドはオペランドで解析 var opeInfoList = context.operand() .Select(ope => (success: OperandAnalyzer.TryAnalyze(_env, ope, out var info), info)) .Where(x => x.success) .Select(x => x.info) .ToArray(); if (opeInfoList.Length != context.operand().Length) { return(false); } //両方解析できたら命令語実行 instInfo.Execute(_env, opeInfoList); return(true); }
private IEnumerable <int> FindErrors(int startTime, int endTime, int armIndex, List <Instruction> instructions) { var errors = FindErrors().ToList(); if (errors.Any()) { sm_log.Warn(Invariant($"{errors.Count()} instructions for arm {armIndex} between time {startTime} and {endTime} are incorrect. Waiting a little while before checking again...")); ThreadUtils.SleepOrAbort(100 + m_renderDelay); errors = FindErrors().ToList(); if (errors.Any()) { sm_log.Warn(Invariant($"{errors.Count()} instructions for arm {armIndex} between time {startTime} and {endTime} are still incorrect.")); } } return(errors); IEnumerable <int> FindErrors() { var rect = m_grid.GetCellScreenBounds(new Bounds(new Vector2(startTime, armIndex), new Vector2(endTime, armIndex))); using (var capture = new ScreenCapture(rect)) { var analyzer = new InstructionAnalyzer(capture); for (int timeIndex = startTime; timeIndex <= endTime; timeIndex++) { var instruction = instructions[timeIndex]; if (instruction.IsRenderable()) { var location = m_grid.GetCellLocation(new Vector2(timeIndex, armIndex)).Subtract(rect.Location); if (!analyzer.IsMatch(location, instructions[timeIndex])) { yield return(timeIndex); } } } } } }
static string GetCoreSagaCorrelationId(TypeDefinition type, TypeDefinition sagaDataType) { var instructions = InstructionAnalyzer.GetConfigureHowToFindSagaInstructions(type); if (InstructionAnalyzer.ContainsBranchingLogic(instructions)) { throw new ErrorsException("Looping & branching statements are not allowed in a ConfigureHowToFindSaga method."); } if (InstructionAnalyzer.CallsUnmanagedMethods(instructions)) { throw new ErrorsException("Calling unmanaged code is not allowed in a ConfigureHowToFindSaga method."); } if (InstructionAnalyzer.CallsUnexpectedMethods(instructions)) { throw new ErrorsException("Unable to determine Saga correlation property because an unexpected method call was detected in the ConfigureHowToFindSaga method."); } var correlationId = InstructionAnalyzer.GetCorrelationId(instructions, sagaDataType.FullName); return(correlationId); }