Esempio n. 1
0
        public void Setup()
        {
            var analyzerAssemblyPath = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "Microsoft.CodeAnalysis.CSharp.Features.dll"
                );

            _options = new Options(
                analyzerPath: analyzerAssemblyPath,
                solutionPath: _solutionPath,
                analyzerIds: ImmutableHashSet.Create(AnalyzerName),
                refactoringNodes: ImmutableHashSet <string> .Empty,
                runConcurrent: true,
                reportSuppressedDiagnostics: true,
                applyChanges: false,
                useAll: false,
                iterations: 1,
                usePersistentStorage: false,
                fullSolutionAnalysis: false,
                incrementalAnalyzerNames: ImmutableArray <string> .Empty
                );

            _workspace = AnalyzerRunnerHelper.CreateWorkspace();
            _diagnosticAnalyzerRunner = new DiagnosticAnalyzerRunner(_workspace, _options);

            _ =
                _workspace.OpenSolutionAsync(
                    _solutionPath,
                    progress: null,
                    CancellationToken.None
                    ).Result;
        }
Esempio n. 2
0
        public void Setup()
        {
            _workspace = AnalyzerRunnerHelper.CreateWorkspace();
            if (_workspace == null)
            {
                throw new ArgumentException("Couldn't create workspace");
            }

            _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options
                                                                              .WithChangedOption(StorageOptions.Database, StorageDatabase.SQLite)));

            Console.WriteLine("Opening roslyn.  Attach to: " + Process.GetCurrentProcess().Id);

            var start = DateTime.Now;

            _ = _workspace.OpenSolutionAsync(_solutionPath, progress: null, CancellationToken.None).Result;
            Console.WriteLine("Finished opening roslyn: " + (DateTime.Now - start));

            // Force a storage instance to be created.  This makes it simple to go examine it prior to any operations we
            // perform, including seeing how big the initial string table is.
            var storageService = _workspace.Services.GetService <IPersistentStorageService>();

            if (storageService == null)
            {
                throw new ArgumentException("Couldn't get storage service");
            }

            using var storage = storageService.GetStorageAsync(_workspace.CurrentSolution, CancellationToken.None).AsTask().GetAwaiter().GetResult();
        }