public static void ProcessAssemblies(ScannerConfiguration configuration) { foreach (var instrumentationSet in configuration.InstrumentationSets) { // load the instrumentation.xml and create InstrumentationModel var instrumentationModel = ReadInstrumentationFile(instrumentationSet); // nuget assemblies var downloadedNugetInfoList = GetNugetAssemblies(instrumentationSet, instrumentationModel.UniqueAssemblies); foreach (var downloadedNugetInfo in downloadedNugetInfoList) { foreach (var intrumentedDllFileLocation in downloadedNugetInfo.InstrumentedDllFileLocations) { // Builds a model from the files Console.WriteLine($"Starting scan of '{intrumentedDllFileLocation}'"); var assemblyAnalyzer = new AssemblyAnalyzer(); var assemblyAnalysis = assemblyAnalyzer.RunAssemblyAnalysis(intrumentedDllFileLocation); var instrumentationValidator = new InstrumentationValidator(assemblyAnalysis); // just some debugging writes Console.WriteLine($"Found {assemblyAnalysis.ClassesCount} classes"); Console.WriteLine("Scan complete"); var targetFramework = Path.GetFileName(Path.GetDirectoryName(intrumentedDllFileLocation)); // run the validation var report = instrumentationValidator.CheckInstrumentation(instrumentationModel, instrumentationSet.Name, targetFramework, downloadedNugetInfo.PackageVersion, downloadedNugetInfo.PackageName); _instrumentationReports.Add(report); } } } }
public static void Main(string[] args) { if (args.Length != 1 || string.IsNullOrWhiteSpace(args[0])) { Console.WriteLine("ERROR Missing arguement: Must supply path to configuration file."); return; } var filePath = args[0]; if (!File.Exists(filePath)) { Console.WriteLine("ERROR File not found: Provide path was incorrect or file missing."); return; } var deserializer = new DeserializerBuilder() .WithNamingConvention(HyphenatedNamingConvention.Instance) .Build(); var configuration = deserializer.Deserialize <ScannerConfiguration>(File.ReadAllText(filePath)); // now that we have a config, we need to handle checking more than one xml or dll // temp to allow other testing var fileNames = configuration.InstrumentationSets[0].LocalAssemblies.ToArray(); // Builds a model from the files Console.WriteLine($"Starting scan of '{string.Join(',', fileNames)}'"); var assemblyAnalyzer = new AssemblyAnalyzer(); var assemblyAnalysis = assemblyAnalyzer.RunAssemblyAnalysis(fileNames); // just some debugging writes Console.WriteLine($"Found {assemblyAnalysis.ClassesCount} classes"); Console.WriteLine("Scan complete"); // build a searcher to check the inst file. var instrumentationValidator = new InstrumentationValidator(assemblyAnalysis); //var report = instrumentationValidator.CheckInstrumentation() //PrintReport(); }
public static void ProcessAssemblies(ScannerConfiguration configuration) { foreach (var instrumentationSet in configuration.InstrumentationSets) { // TODO: deal with duplicate assembly names // load the instrumentation.xml and create InstrumentationModel var instrumentationModel = ReadInstrumentationFile(instrumentationSet); List <string> dllFileLocations = new List <string>(); // nuget assemblies var nugetDllFileLocations = GetNugetAssemblies(instrumentationSet, instrumentationModel.UniqueAssemblies); if (nugetDllFileLocations != null) { dllFileLocations.AddRange(nugetDllFileLocations); } // local assemblies var localDllFileLocations = GetLocalAssemblies(instrumentationSet); if (localDllFileLocations != null) { dllFileLocations.AddRange(localDllFileLocations); } var dllFileNames = dllFileLocations.ToArray(); // Builds a model from the files Console.WriteLine($"Starting scan of '{string.Join(',', dllFileNames)}'"); var assemblyAnalyzer = new AssemblyAnalyzer(); var assemblyAnalysis = assemblyAnalyzer.RunAssemblyAnalysis(dllFileNames); var instrumentationValidator = new InstrumentationValidator(assemblyAnalysis); // just some debugging writes Console.WriteLine($"Found {assemblyAnalysis.ClassesCount} classes"); Console.WriteLine("Scan complete"); // run the validation var report = instrumentationValidator.CheckInstrumentation(instrumentationModel, instrumentationSet.Name); _instrumentationReports.Add(report); } }