示例#1
0
        public void Run()
        {
            IProject project;

            if (!ProjectAnalysisUtils.TryChooseProject(out project))
            {
                return;
            }
            Debug.Assert(project != null);

            IReadOnlyList <IAbsoluteFilePath>       applicationAssemblies, thirdPartyAssemblies;
            IReadOnlyList <IAssemblyResolvingError> applicationAssembliesError, thirdPartyAssembliesError;

            project.CodeToAnalyze.Resolve(out applicationAssemblies, out thirdPartyAssemblies, out applicationAssembliesError, out thirdPartyAssembliesError);


            //--------------------------------------------------------------------------------------------
            ShowConsoleNewCheck(ExtensionMethods.ToEnumerable("Show eventual assembly resolving errors"));
            ShowEventualAssemblyResolvingErrors(applicationAssemblies.Count, applicationAssembliesError);



            //--------------------------------------------------------------------------------------------
            // Make sure there are enought application assemblies resolved
            if (applicationAssemblies.Count < 3)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Only " + applicationAssemblies.Count + " application assembly are resolved, this is not enought to try detect versionning issue.");
                return;
            }
            var dotNetManager = new NDependServicesProvider().DotNetManager;
            var applicationAssembliesInfos = applicationAssemblies.Select(dotNetManager.GetAssemblyInfo);
            var thirdPartyAssembliesInfos  = thirdPartyAssemblies.Select(dotNetManager.GetAssemblyInfo);



            //--------------------------------------------------------------------------------------------
            ShowConsoleNewCheck(new[] { "Try get the application version", "and check assemblies without the application version" });
            CoherencyChecker.Go(applicationAssembliesInfos,
                                assemblyInfo => assemblyInfo.Version,
                                "application version");



            //--------------------------------------------------------------------------------------------
            ShowConsoleNewCheck(ExtensionMethods.ToEnumerable("Check that assemblies references have the same version than assemblies resolved"));
            AssembliesReferencesVersionningChecker.Go(applicationAssembliesInfos, thirdPartyAssembliesInfos);


            //--------------------------------------------------------------------------------------------
            ShowConsoleNewCheck(new[] { "Try get the common target runtime version", "and check assemblies with a different target runtime version" });
            CoherencyChecker.Go(applicationAssembliesInfos,
                                assemblyInfo => assemblyInfo.TargetRuntime,
                                "target runtime version");



            //--------------------------------------------------------------------------------------------
            ShowConsoleNewCheck(ExtensionMethods.ToEnumerable("Check that all application assemblies are strong named or not"));
            CoherencyChecker.Go(applicationAssembliesInfos,
                                assemblyInfo => assemblyInfo.IsStrongNamed,
                                "is strong named");


            //--------------------------------------------------------------------------------------------
            ShowConsoleNewCheck(new[] { "Check that all application assemblies share ", "a common target platform target (AnyCPU, x86, x64, Itanium)" });
            CoherencyChecker.Go(applicationAssembliesInfos,
                                assemblyInfo => assemblyInfo.PlatformTarget,
                                "platform target");


            //--------------------------------------------------------------------------------------------
            ShowConsoleNewCheck(new[] { "Make sure all application assemblies", "PDB file available or not available" });
            CoherencyChecker.Go(applicationAssembliesInfos,
                                assemblyInfo => assemblyInfo.PDBAvailable,
                                "PDB file available");
        }