private static Solution AddDefaultTestSolution(
            TestWorkspace workspace,
            string[] markedSources
        )
        {
            var solution = workspace.CurrentSolution;

            var project = solution
                .AddProject("proj", "proj", LanguageNames.CSharp)
                .WithMetadataReferences(
                    TargetFrameworkUtil.GetReferences(TargetFramework.Standard)
                );

            solution = project.Solution;

            for (var i = 0; i < markedSources.Length; i++)
            {
                var name = $"test{i + 1}.cs";
                var text = SourceText.From(
                    ActiveStatementsDescription.ClearTags(markedSources[i]),
                    Encoding.UTF8
                );
                var id = DocumentId.CreateNewId(project.Id, name);
                solution = solution.AddDocument(
                    id,
                    name,
                    text,
                    filePath: Path.Combine(TempRoot.Root, name)
                );
            }

            workspace.ChangeSolution(solution);
            return solution;
        }
            public Validator(
                string[] markedSource,
                ImmutableArray <ActiveStatementDebugInfo> activeStatements,
                ImmutableDictionary <ActiveMethodId, ImmutableArray <NonRemappableRegion> > nonRemappableRegions = null,
                Func <Solution, Solution> adjustSolution     = null,
                CommittedSolution.DocumentState initialState = CommittedSolution.DocumentState.MatchesBuildOutput,
                bool openDocuments = false)
            {
                Workspace = TestWorkspace.CreateCSharp(ActiveStatementsDescription.ClearTags(markedSource), composition: s_composition, openDocuments: openDocuments);

                if (adjustSolution != null)
                {
                    Workspace.ChangeSolution(adjustSolution(Workspace.CurrentSolution));
                }

                var solution = Workspace.CurrentSolution;

                var mockDebuggeModuleProvider      = new Mock <IDebuggeeModuleMetadataProvider>(MockBehavior.Strict);
                var mockCompilationOutputsProvider = new Func <Project, CompilationOutputs>(_ => new MockCompilationOutputs(Guid.NewGuid()));

                var debuggingSession = new DebuggingSession(solution, mockCompilationOutputsProvider);

                if (initialState != CommittedSolution.DocumentState.None)
                {
                    EditAndContinueWorkspaceServiceTests.SetDocumentsState(debuggingSession, solution, initialState);
                }

                debuggingSession.Test_SetNonRemappableRegions(nonRemappableRegions ?? ImmutableDictionary <ActiveMethodId, ImmutableArray <NonRemappableRegion> > .Empty);

                var telemetry = new EditSessionTelemetry();

                EditSession = new EditSession(debuggingSession, telemetry, cancellationToken => Task.FromResult(activeStatements), mockDebuggeModuleProvider.Object);
            }
            public Validator(
                string[] markedSource,
                ImmutableArray <ActiveStatementDebugInfo> activeStatements,
                ImmutableDictionary <ActiveMethodId, ImmutableArray <NonRemappableRegion> > nonRemappableRegions = null,
                Func <Solution, Solution> adjustSolution     = null,
                CommittedSolution.DocumentState initialState = CommittedSolution.DocumentState.MatchesBuildOutput)
            {
                var exportProviderFactory = ExportProviderCache.GetOrCreateExportProviderFactory(
                    TestExportProvider.MinimumCatalogWithCSharpAndVisualBasic.WithPart(typeof(CSharpEditAndContinueAnalyzer)).WithPart(typeof(DummyLanguageService)));

                var exportProvider = exportProviderFactory.CreateExportProvider();

                Workspace = TestWorkspace.CreateCSharp(ActiveStatementsDescription.ClearTags(markedSource), exportProvider: exportProvider, openDocuments: true);

                if (adjustSolution != null)
                {
                    Workspace.ChangeSolution(adjustSolution(Workspace.CurrentSolution));
                }

                var mockDebuggeModuleProvider      = new Mock <IDebuggeeModuleMetadataProvider>();
                var mockCompilationOutputsProvider = new Func <Project, CompilationOutputs>(_ => new MockCompilationOutputs(Guid.NewGuid()));

                var debuggingSession = new DebuggingSession(Workspace, mockDebuggeModuleProvider.Object, mockCompilationOutputsProvider);

                if (initialState != CommittedSolution.DocumentState.None)
                {
                    EditAndContinueWorkspaceServiceTests.SetDocumentsState(debuggingSession, Workspace.CurrentSolution, initialState);
                }

                debuggingSession.Test_SetNonRemappableRegions(nonRemappableRegions ?? ImmutableDictionary <ActiveMethodId, ImmutableArray <NonRemappableRegion> > .Empty);

                var telemetry = new EditSessionTelemetry();

                EditSession = new EditSession(debuggingSession, telemetry, cancellationToken => Task.FromResult(activeStatements));
            }
Пример #4
0
            public Validator(
                string[] markedSource,
                ImmutableArray <ManagedActiveStatementDebugInfo> activeStatements,
                ImmutableDictionary <ManagedMethodId, ImmutableArray <NonRemappableRegion> > nonRemappableRegions = null,
                Func <Solution, Solution> adjustSolution     = null,
                CommittedSolution.DocumentState initialState = CommittedSolution.DocumentState.MatchesBuildOutput,
                bool openDocuments = false)
            {
                Workspace = TestWorkspace.CreateCSharp(ActiveStatementsDescription.ClearTags(markedSource), composition: s_composition, openDocuments: openDocuments);

                if (adjustSolution != null)
                {
                    Workspace.ChangeSolution(adjustSolution(Workspace.CurrentSolution));
                }

                var solution = Workspace.CurrentSolution;

                var mockDebuggerService = new MockManagedEditAndContinueDebuggerService()
                {
                    GetActiveStatementsImpl = () => activeStatements
                };

                var mockCompilationOutputsProvider = new Func <Project, CompilationOutputs>(_ => new MockCompilationOutputs(Guid.NewGuid()));

                var debuggingSession = new DebuggingSession(solution, mockCompilationOutputsProvider, SpecializedCollections.EmptyEnumerable <KeyValuePair <DocumentId, CommittedSolution.DocumentState> >());

                if (initialState != CommittedSolution.DocumentState.None)
                {
                    EditAndContinueWorkspaceServiceTests.SetDocumentsState(debuggingSession, solution, initialState);
                }

                debuggingSession.Test_SetNonRemappableRegions(nonRemappableRegions ?? ImmutableDictionary <ManagedMethodId, ImmutableArray <NonRemappableRegion> > .Empty);

                var telemetry = new EditSessionTelemetry();

                EditSession = new EditSession(debuggingSession, telemetry, mockDebuggerService);
            }