示例#1
0
 /// <summary>
 /// Checks the methods of each machine and report warnings if
 /// any method is directly accessed by anything else than the
 /// P# runtime.
 /// </summary>
 /// <param name="machines">StateMachines</param>
 private void CheckMethods(ISet <StateMachine> machines)
 {
     foreach (var machine in machines)
     {
         foreach (var method in machine.Declaration.ChildNodes().OfType <MethodDeclarationSyntax>())
         {
             if (method.Modifiers.Any(SyntaxKind.PublicKeyword))
             {
                 TraceInfo trace = new TraceInfo();
                 trace.AddErrorTrace(method.Identifier);
                 AnalysisErrorReporter.ReportWarning(trace, "Method '{0}' of machine '{1}' " +
                                                     "is declared as 'public'.", method.Identifier.ValueText,
                                                     machine.Name);
             }
             else if (method.Modifiers.Any(SyntaxKind.InternalKeyword))
             {
                 TraceInfo trace = new TraceInfo();
                 trace.AddErrorTrace(method.Identifier);
                 AnalysisErrorReporter.ReportWarning(trace, "Method '{0}' of machine '{1}' " +
                                                     "is declared as 'internal'.", method.Identifier.ValueText,
                                                     machine.Name);
             }
         }
     }
 }
 /// <summary>
 /// Reports calling a virtual method with unknown overrider,
 /// thus cannot be further analysed.
 /// </summary>
 /// <param name="log">Log</param>
 internal static void ReportUnknownVirtualCall(Log log)
 {
     if (log.State == null)
     {
         AnalysisErrorReporter.ReportWarning(log,
                                             "Method '{0}' of machine '{1}' calls a virtual method that " +
                                             "cannot be further analysed.",
                                             log.Method, log.Machine);
     }
     else
     {
         AnalysisErrorReporter.ReportWarning(log,
                                             "Method '{0}' in state '{1}' of machine '{2}' calls a virtual " +
                                             "method that cannot be further analysed.",
                                             log.Method, log.State, log.Machine);
     }
 }
 /// <summary>
 /// Reports calling a method with unavailable source code,
 /// thus cannot be further analysed.
 /// </summary>
 /// <param name="log">Log</param>
 internal static void ReportUnknownInvocation(Log log)
 {
     if (log.State == null)
     {
         AnalysisErrorReporter.ReportWarning(log,
                                             "Method '{0}' of machine '{1}' calls a method with unavailable " +
                                             "source code, which might be a source of errors.",
                                             log.Method, log.Machine);
     }
     else
     {
         AnalysisErrorReporter.ReportWarning(log,
                                             "Method '{0}' in state '{1}' of machine '{2}' calls a method " +
                                             "with unavailable source code, which might be a source of errors.",
                                             log.Method, log.State, log.Machine);
     }
 }
示例#4
0
 /// <summary>
 /// Checks the fields of each machine and report warnings if
 /// any field is not private or protected.
 /// </summary>
 /// <param name="machines">StateMachines</param>
 private void CheckFields(ISet <StateMachine> machines)
 {
     foreach (var machine in machines)
     {
         foreach (var field in machine.Declaration.ChildNodes().OfType <FieldDeclarationSyntax>())
         {
             if (field.Modifiers.Any(SyntaxKind.PublicKeyword))
             {
                 TraceInfo trace = new TraceInfo();
                 trace.AddErrorTrace(field);
                 AnalysisErrorReporter.ReportWarning(trace, "Field '{0}' of machine '{1}' is " +
                                                     "declared as 'public'.", field.Declaration.ToString(), machine.Name);
             }
             else if (field.Modifiers.Any(SyntaxKind.InternalKeyword))
             {
                 TraceInfo trace = new TraceInfo();
                 trace.AddErrorTrace(field);
                 AnalysisErrorReporter.ReportWarning(trace, "Field '{0}' of machine '{1}' is " +
                                                     "declared as 'internal'.", field.Declaration.ToString(), machine.Name);
             }
         }
     }
 }