コード例 #1
0
ファイル: Options.cs プロジェクト: asvishnyakov/CodeContracts
    public static void PrintUsageAndExit()
    {
      GeneralOptions defaultOptions = new GeneralOptions();

      Console.WriteLine("usage: <general-option>* <assembly>+");
      Console.WriteLine("\nwhere <general-option> is one of");
      defaultOptions.PrintOptions("");
      Console.WriteLine("\nwhere derived options are of");
      defaultOptions.PrintDerivedOptions("");
      Console.WriteLine("\nTo clear a list, use -<option>=");
      Environment.Exit(-1);
    }
コード例 #2
0
ファイル: Options.cs プロジェクト: asvishnyakov/CodeContracts
    public static GeneralOptions ParseCommandLineArguments(string[] args, Dictionary<string, IMethodAnalysis> analyzers, Dictionary<string, IClassAnalysis> classanalyzers)
    {
      Contract.Requires(args != null);
      Contract.Requires(analyzers != null);
      Contract.Requires(classanalyzers != null);

      Contract.Ensures(Contract.Result<GeneralOptions>() != null);

      var options = new GeneralOptions(analyzers, classanalyzers);
      options.Parse(args);
      
#if DEBUG && false
      Console.WriteLine("[Slicer @ {0}] Slice TimeStamp: {1}", DateTime.Now, DateTime.FromBinary(options.sliceTime));
#endif
      
      return options;
    }
コード例 #3
0
        public MaskingOutput(IOutputFullResults <Method, Assembly> output, GeneralOptions options,
                             IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
            : base(output)
        {
            Contract.Requires(output != null);
            Contract.Requires(options != null);
            Contract.Requires(mdDecoder != null);

            this.options                 = options;
            this.mdDecoder               = mdDecoder;
            this.currMethod              = default(Method);
            this.methodmask              = null;
            this.assemblymask            = null;
            this.swallowedCount          = new SwallowedBuckets();
            this.suppressWarningsManager = new SuppressWarningsManager <Method>();
            this.errorsWereEmitted       = false;
        }
コード例 #4
0
 public XmlBaseLineComparer(IOutputFullResults <Method, Assembly> output, GeneralOptions options, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder,
                            CacheManager <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, ExternalExpression <APC, SymbolicValue>, SymbolicValue> cacheManager, string xmlBaseLineFile)
     : base(output, options, mdDecoder)
 {
     this.cacheManager = cacheManager;
     try
     {
         this.baseLineRoot = XElement.Load(xmlBaseLineFile);
         // gets pool of *all* expected outcomes (currently, does not distinguish by method)
         expectedAssemblyOutcomes = BaseLineOutcomes.GetOutcomes(this.GetAssemblyRoots(), this.options.baseLineStrategy);
     }
     catch (System.Xml.XmlException)
     {
         output.WriteLine("Error: baseline file {0} is corrupted", xmlBaseLineFile);
         Environment.Exit(-1);
     }
     this.swallowedCounter = new SwallowedBuckets();
 }
コード例 #5
0
ファイル: Options.cs プロジェクト: asvishnyakov/CodeContracts
 public static GeneralOptions ParseCommandLineArguments(string[] args)
 {
   GeneralOptions options = new GeneralOptions();
   options.Parse(args);
   return options;
 }
コード例 #6
0
 public XmlBaseLine(IOutputFullResults <Method, Assembly> output, GeneralOptions options, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
 {
     this.output    = output;
     this.options   = options;
     this.mdDecoder = mdDecoder;
 }
コード例 #7
0
 private Environment(GeneralOptions options, CCI2Slicer codeWriter, CciMetadataDecoder metadataDecoder, CciContractDecoder contractDecoder, Dictionary <string, IMethodAnalysis> methodAnalyzers, Dictionary <string, IClassAnalysis> classAnalyzers)
     : base(options, metadataDecoder, contractDecoder, methodAnalyzers, classAnalyzers)
 {
     this.codeWriter = codeWriter;
 }
コード例 #8
0
        private static List <Tuple <int, string> > ExtractPathsAndUpdateThePackageInfo(ref AnalysisPackageInfo packageInfo)
        {
            Contract.Requires(packageInfo.ExpandedClousotOptions != null);
            Contract.Ensures(packageInfo.AssembliesToAnalyze != null);
            Contract.Ensures(packageInfo.ExpandedClousotOptions == Contract.OldValue(packageInfo.ExpandedClousotOptions));

            var result = new List <Tuple <int, string> >();
            var assembliesToAnalyse    = new List <string>();
            var expandedClousotOptions = packageInfo.ExpandedClousotOptions;

            // Very stuping parsing algorithm, to be improved?

            // Step 0: get the clousot options that contain paths
            var clousotOptionsForPaths = GeneralOptions.GetClousotOptionsWithPaths().ToArray(); // Use ToArray to speed up the look ups

            // Step 1: go all over the clousot options to find those fields, or the dirs we are interested in
            for (var i = 0; i < expandedClousotOptions.Length; i++)
            {
                var option = expandedClousotOptions[i];

                var pathsInTheOptions = GetPaths(option);

                // Step 1a : Is the current option a path?
                if (pathsInTheOptions.Count == 1)
                {
                    // PrintPaths(pathsInTheOptions, "Found an assembly to analyze:");
                    AddIntoResult(result, i, pathsInTheOptions);
                    // Executed only once because of the test above
                    foreach (var match in pathsInTheOptions)
                    {
                        assembliesToAnalyse.Add(match.ToString());
                    }
                }
                // Step 1b : search inside the option
                else
                {
                    option = option.Substring(1); // Remove the first char
                    var tryFind = clousotOptionsForPaths.Where(t => option.StartsWith(t));
                    // Found a match
                    if (tryFind.Any())
                    {
                        foreach (var candidatePath in option.Split(';'))
                        {
                            var matches = GetPaths(candidatePath);
                            // PrintPaths(matches, "Found path(s) for option in position " + i);
                            AddIntoResult(result, i, matches);
                        }
                    }
                }
            }

            // Step 2: create the normalized command line
            var clonedCommandLine = packageInfo.ExpandedClousotOptions.Clone() as string[];

            Contract.Assume(clonedCommandLine != null);
            foreach (var pair in result)
            {
                string unc;
                if (FileSystemAbstractions.TryGetUniversalName(Path.GetFullPath(pair.Item2), out unc))
                {
                    clonedCommandLine[pair.Item1] = clonedCommandLine[pair.Item1].Replace(pair.Item2, unc);
                }
                else
                {
                    clonedCommandLine = null;
                    break;
                }
            }

            packageInfo.AssembliesToAnalyze = assembliesToAnalyse.ToArray();
            packageInfo.ExpandedClousotOptionsNormalized = clonedCommandLine;

            return(result);
        }
コード例 #9
0
ファイル: Main.cs プロジェクト: asvishnyakov/CodeContracts
    private NewCCI2Driver(string[] args, ISimpleLineWriter output)
    {
      /* TODO: argsForWorker
       * We currently keep all the arguments except the general arguments
       * But we should also remove arguments like -select, -namespaceSelect, -typenameSelect, -memberNameSelect -analyzeFrom, -analyzeTo (or translate them)
       */

      this.options = FilteringGeneralOptions.ParseCommandLineArguments(args, this.methodAnalyzers, this.classAnalyzers, out this.argsForWorker);

      this.output = output;
    }