예제 #1
0
        static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Please, enter the solution's path");
                Console.WriteLine("Usage: CheckReadOnlyDAL <SolutionPath>");
                return(1);
            }

            Console.WriteLine("Retrieving list of projects to scan ...");

            TargetFilesFetcher getTargetFiles = new TargetFilesFetcher();

            Dictionary <string, List <string> > projToFilesDict = getTargetFiles.getProjToSrcFilesDict(args[0]);

            getTargetFiles = null;

            Console.WriteLine("{0} projects found", projToFilesDict.Count);

            //---------------------------------------------------------------------------------------
            int            threadCount    = 0;
            int            N              = projToFilesDict.Count;
            CountdownEvent countDownEvent = new CountdownEvent(N);

            var myEnum2 = projToFilesDict.Keys.GetEnumerator();

            if (!myEnum2.MoveNext())
            {
                return(0);
            }

            for (int i = 0; i < N;)
            {
                string key = myEnum2.Current;

                Console.WriteLine("Scanning project <{0}> ...", key);

                List <string> srcFnList = projToFilesDict[key];

                CodeAnalyser codeAnaliser = new CodeAnalyser(key, srcFnList);

                if (ThreadPool.QueueUserWorkItem((Object threadContext) =>
                {
                    CodeAnalyser localCodeAnalyer = (CodeAnalyser)threadContext;
                    localCodeAnalyer.Analyze();
                    Interlocked.Decrement(ref threadCount);
                    countDownEvent.Signal();
                }, codeAnaliser))
                {
                    i++;
                    myEnum2.MoveNext();
                    Interlocked.Increment(ref threadCount);
                }
            }

            countDownEvent.Wait();
            //---------------------------------------------------------------------------------------

            return(0);
        }
예제 #2
0
        public CodeAnalyser(string projectFileName, List <string> targetSrcFilesList)
        {
            _projectFileName              = projectFileName;
            _targetSrcFilesList           = targetSrcFilesList;
            _targetSrcFilesListEnumerator = _targetSrcFilesList.GetEnumerator();

            _workspace = MSBuildWorkspace.Create();

            _solution = _workspace.CurrentSolution;

            if (_solution == null)
            {
                throw new Exception("Invalid CurrentSolution property");
            }

            _project = _workspace.OpenProjectAsync(_projectFileName).Result;

            _compilation = _project.GetCompilationAsync().Result;

            _targetFilesFetcher = new TargetFilesFetcher();

            _sqlAnalyser = new SqlAnalyser();
        }
예제 #3
0
            public ContainsReadOnlyCallChecker(TargetFilesFetcher parent)
            {
                this.parent = parent;

                localRx = new Regex(parent._pattern);
            }