未验证 提交 085990f1 编写于 作者: S Shen Chen 提交者: GitHub

Remove the workspace IVT of SourceBasedTestDiscovery and LiveUnitTesting (#38466)

* Add solution crawler wrapper types

* Add Experimentation wrapper

* Add UnitTestingPinnedSolutionInfoWrapper

* Add KeepAliveSessionWrapper

* Add PersistentStorageLocationService wrapper

* Add UnitTestingWorkspaceTaskSchedule wrapper

* Add extension wrapper

* Change Workspace wrapper to an extension class

* Add more wrapper types

* Rename and remove files

* Add immutable array extensions

* remove lut ivt

* Remove the dependency on ServicehubBase

* Remove all the dependency for LUT

* Rename and remove unused wrappers

* Add comments

* Rename wrappers and accessors

* More renaming
上级 985124af
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal interface IUnitTestingSolutionCrawlerServiceAccessor : IWorkspaceService
{
void Reanalyze(Workspace workspace, IUnitTestingIncrementalAnalyzerImplementation analyzer, IEnumerable<ProjectId> projectIds = null, IEnumerable<DocumentId> documentIds = null, bool highPriority = false);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting
{
internal sealed class UnitTestingSolutionCrawlerServiceAccessor : IUnitTestingSolutionCrawlerServiceAccessor
{
private readonly ISolutionCrawlerService _implementation;
[Obsolete(MefConstruction.FactoryMethodMessage, error: true)]
public UnitTestingSolutionCrawlerServiceAccessor(ISolutionCrawlerService implementation)
=> _implementation = implementation;
public void Reanalyze(Workspace workspace, IUnitTestingIncrementalAnalyzerImplementation analyzer, IEnumerable<ProjectId> projectIds = null, IEnumerable<DocumentId> documentIds = null, bool highPriority = false)
=> _implementation.Reanalyze(workspace, new UnitTestingIncrementalAnalyzer(analyzer), projectIds, documentIds, highPriority);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Composition;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting
{
[ExportWorkspaceServiceFactory(typeof(IUnitTestingSolutionCrawlerServiceAccessor))]
[Shared]
internal sealed class UnitTestingSolutionCrawlerServiceAccessorFactory : IWorkspaceServiceFactory
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public UnitTestingSolutionCrawlerServiceAccessorFactory() { }
[Obsolete(MefConstruction.FactoryMethodMessage, error: true)]
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
var implementation = workspaceServices.GetRequiredService<ISolutionCrawlerService>();
return new UnitTestingSolutionCrawlerServiceAccessor(implementation);
}
}
}
......@@ -42,8 +42,8 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Xaml" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Workspaces" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Features" />
<InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Options;
using Microsoft.VisualStudio.LanguageServices.Remote;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingRemoteHostOptionsAccessor
{
public static Option<bool> OOP64Bit => RemoteHostOptions.OOP64Bit;
}
}
......@@ -87,8 +87,8 @@
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.VisualStudio.TestWindow.CodeLens" Key="$(UnitTestingKey)" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CodeLens" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Implementation" />
......
......@@ -80,7 +80,7 @@
<Compile Include="..\..\..\Tools\Source\RunTests\ProcDumpUtil.cs" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.VisualStudio.LiveUnitTesting.IntegrationTests" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.LiveUnitTesting.IntegrationTests" Partner="UnitTesting" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Setup" />
</ItemGroup>
</Project>
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal interface IUnitTestingExperimentationServiceAccessor : IWorkspaceService
{
bool IsExperimentEnabled(string experimentName);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal interface IUnitTestingIncrementalAnalyzerImplementation
{
Task NewSolutionSnapshotAsync(Solution solution, CancellationToken cancellationToken);
Task DocumentOpenAsync(Document document, CancellationToken cancellationToken);
Task DocumentCloseAsync(Document document, CancellationToken cancellationToken);
Task DocumentResetAsync(Document document, CancellationToken cancellationToken);
Task AnalyzeSyntaxAsync(Document document, UnitTestingInvocationReasonsWrapper reasons, CancellationToken cancellationToken);
Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, UnitTestingInvocationReasonsWrapper reasons, CancellationToken cancellationToken);
Task AnalyzeProjectAsync(Project project, bool semanticsChanged, UnitTestingInvocationReasonsWrapper reasons, CancellationToken cancellationToken);
void RemoveDocument(DocumentId documentId);
void RemoveProject(ProjectId projectId);
bool NeedsReanalysisOnOptionChanged(object sender, UnitTestingOptionChangedEventArgsWrapper e);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal interface IUnitTestingIncrementalAnalyzerProviderImplementation
{
IUnitTestingIncrementalAnalyzerImplementation CreateIncrementalAnalyzer(Workspace workspace);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal interface IUnitTestingSolutionCrawlerRegistrationServiceAccessor : IWorkspaceService
{
void AddAnalyzerProvider(IUnitTestingIncrementalAnalyzerProviderImplementation provider, UnitTestingIncrementalAnalyzerProviderMetadataWrapper metadata);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingChecksumWrapper
{
private Checksum UnderlyingObject { get; }
public UnitTestingChecksumWrapper(Checksum underlyingObject)
=> UnderlyingObject = underlyingObject ?? throw new ArgumentNullException(nameof(underlyingObject));
public bool IsEqualTo(UnitTestingChecksumWrapper other)
=> other.UnderlyingObject == UnderlyingObject;
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using System.Text;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingEncodedStringTextAccessor
{
public static SourceText Create(Stream stream, Encoding defaultEncoding)
=> EncodedStringText.Create(stream, defaultEncoding);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingExceptionUtilitesHelpers
{
public static Exception Unreachable => ExceptionUtilities.Unreachable;
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.ErrorReporting;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingFatalErrorAccessor
{
public static bool ReportWithoutCrash(Exception e)
=> FatalError.ReportWithoutCrash(e);
public static bool ReportWithoutCrashUnlessCanceled(Exception e)
=> FatalError.ReportWithoutCrashUnlessCanceled(e);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingImmutableArrayExtensions
{
public static ImmutableArray<byte> ToImmutable(this MemoryStream stream)
=> ImmutableArrayExtensions.ToImmutable(stream);
public static bool SetEquals<T>(this ImmutableArray<T> array1, ImmutableArray<T> array2, IEqualityComparer<T> comparer)
=> ImmutableArrayExtensions.SetEquals(array1, array2, comparer);
public static ImmutableArray<T> AsImmutable<T>(this IEnumerable<T> items)
=> ImmutableArrayExtensions.AsImmutable(items);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingIncrementalAnalyzerProviderMetadataWrapper
{
public UnitTestingIncrementalAnalyzerProviderMetadataWrapper(
string name,
bool highPriorityForActiveFile,
params string[] workspaceKinds)
=> UnderlyingObject = new IncrementalAnalyzerProviderMetadata(name, highPriorityForActiveFile, workspaceKinds);
internal UnitTestingIncrementalAnalyzerProviderMetadataWrapper(IncrementalAnalyzerProviderMetadata underlyingObject)
=> UnderlyingObject = underlyingObject ?? throw new ArgumentNullException(nameof(underlyingObject));
internal IncrementalAnalyzerProviderMetadata UnderlyingObject { get; }
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingInvocationReasonsWrapper
{
public static readonly UnitTestingInvocationReasonsWrapper SemanticChanged = new UnitTestingInvocationReasonsWrapper(InvocationReasons.SemanticChanged);
public static readonly UnitTestingInvocationReasonsWrapper Reanalyze = new UnitTestingInvocationReasonsWrapper(InvocationReasons.Reanalyze);
public static readonly UnitTestingInvocationReasonsWrapper ProjectConfigurationChanged = new UnitTestingInvocationReasonsWrapper(InvocationReasons.ProjectConfigurationChanged);
public static readonly UnitTestingInvocationReasonsWrapper SyntaxChanged = new UnitTestingInvocationReasonsWrapper(InvocationReasons.SyntaxChanged);
internal InvocationReasons UnderlyingObject { get; }
internal UnitTestingInvocationReasonsWrapper(InvocationReasons underlyingObject)
=> UnderlyingObject = underlyingObject;
public UnitTestingInvocationReasonsWrapper(string reason) : this(new InvocationReasons(reason)) { }
public bool Contains(string reason)
=> UnderlyingObject.Contains(reason);
public UnitTestingInvocationReasonsWrapper With(string reason)
=> new UnitTestingInvocationReasonsWrapper(UnderlyingObject.With(reason));
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Remote;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingKeepAliveSessionWrapper
{
internal UnitTestingKeepAliveSessionWrapper(KeepAliveSession underlyingObject)
=> UnderlyingObject = underlyingObject ?? throw new ArgumentNullException(nameof(underlyingObject));
internal KeepAliveSession UnderlyingObject { get; }
public Task<T> TryInvokeAsync<T>(string targetName, Solution solution, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
=> UnderlyingObject.TryInvokeAsync<T>(targetName, solution, arguments, cancellationToken);
public Task<bool> TryInvokeAsync(string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
=> UnderlyingObject.TryInvokeAsync(targetName, arguments, cancellationToken);
public Task<bool> TryInvokeAsync(string targetName, Solution solution, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
=> UnderlyingObject.TryInvokeAsync(targetName, solution, arguments, cancellationToken);
public Task<T> TryInvokeAsync<T>(string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
=> UnderlyingObject.TryInvokeAsync<T>(targetName, arguments, cancellationToken);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingOptionChangedEventArgsWrapper
{
internal OptionChangedEventArgs UnderlyingObject { get; }
public UnitTestingOptionChangedEventArgsWrapper(OptionChangedEventArgs underlyingObject)
=> UnderlyingObject = underlyingObject ?? throw new ArgumentNullException(nameof(underlyingObject));
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingPredefinedInvocationReasonsAccessor
{
public const string Reanalyze = PredefinedInvocationReasons.Reanalyze;
public const string SemanticChanged = PredefinedInvocationReasons.SemanticChanged;
public const string SyntaxChanged = PredefinedInvocationReasons.SyntaxChanged;
public const string ProjectConfigurationChanged = PredefinedInvocationReasons.ProjectConfigurationChanged;
public const string DocumentAdded = PredefinedInvocationReasons.DocumentAdded;
public const string DocumentOpened = PredefinedInvocationReasons.DocumentOpened;
public const string DocumentRemoved = PredefinedInvocationReasons.DocumentRemoved;
public const string DocumentClosed = PredefinedInvocationReasons.DocumentClosed;
public const string HighPriority = PredefinedInvocationReasons.HighPriority;
public const string ProjectParseOptionsChanged = PredefinedInvocationReasons.ProjectParseOptionsChanged;
public const string SolutionRemoved = PredefinedInvocationReasons.SolutionRemoved;
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingProjectExtensions
{
public static string GetDebugName(this ProjectId projectId)
=> projectId.DebugName;
public static Task<bool> HasSuccessfullyLoadedAsync(this Project project, CancellationToken cancellationToken)
=> project.HasSuccessfullyLoadedAsync(cancellationToken);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Remote;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingRemoteHostClientWrapper
{
internal UnitTestingRemoteHostClientWrapper(RemoteHostClient underlyingObject)
=> UnderlyingObject = underlyingObject ?? throw new ArgumentNullException(nameof(underlyingObject));
internal RemoteHostClient UnderlyingObject { get; }
public async Task<UnitTestingKeepAliveSessionWrapper> TryCreateUnitTestingKeepAliveSessionWrapperAsync(string serviceName, CancellationToken cancellationToken)
{
var keepAliveSession = await UnderlyingObject.TryCreateKeepAliveSessionAsync(serviceName, cancellationToken).ConfigureAwait(false);
return new UnitTestingKeepAliveSessionWrapper(keepAliveSession);
}
public async Task<UnitTestingSessionWithSolutionWrapper> TryCreateUnitingSessionWithSolutionWrapperAsync(string serviceName, Solution solution, CancellationToken cancellationToken)
{
var session = await UnderlyingObject.TryCreateSessionAsync(serviceName, solution, cancellationToken).ConfigureAwait(false);
return new UnitTestingSessionWithSolutionWrapper(session);
}
public event EventHandler<bool> StatusChanged
{
add => UnderlyingObject.StatusChanged += value;
remove => UnderlyingObject.StatusChanged -= value;
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Remote;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingSessionWithSolutionWrapper : IDisposable
{
internal SessionWithSolution UnderlyingObject { get; }
public UnitTestingSessionWithSolutionWrapper(SessionWithSolution underlyingObject)
=> UnderlyingObject = underlyingObject;
public Task InvokeAsync(string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
=> UnderlyingObject?.InvokeAsync(targetName, arguments, cancellationToken) ?? Task.CompletedTask;
public Task<T> InvokeAsync<T>(string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
=> UnderlyingObject?.InvokeAsync<T>(targetName, arguments, cancellationToken);
public void Dispose()
=> UnderlyingObject?.Dispose();
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingSolutionExtensions
{
public static int GetWorkspaceVersion(this Solution solution)
=> solution.WorkspaceVersion;
public static UnitTestingSolutionStateWrapper GetState(this Solution solution)
=> new UnitTestingSolutionStateWrapper(solution.State);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingSolutionStateWrapper
{
internal SolutionState UnderlyingObject { get; }
public UnitTestingSolutionStateWrapper(SolutionState underlyingObject)
=> UnderlyingObject = underlyingObject ?? throw new ArgumentNullException(nameof(underlyingObject));
public async Task<UnitTestingChecksumWrapper> GetChecksumAsync(CancellationToken cancellationToken)
{
var checksum = await UnderlyingObject.GetChecksumAsync(cancellationToken).ConfigureAwait(false);
return new UnitTestingChecksumWrapper(checksum);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingSymbolExtensions
{
public static UnitTestingSymbolKeyWrapper GetSymbolKey(this ISymbol symbol, CancellationToken cancellationToken)
=> new UnitTestingSymbolKeyWrapper(SymbolKeyExtensions.GetSymbolKey(symbol, cancellationToken));
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal struct UnitTestingSymbolKeyWrapper
{
internal SymbolKey UnderlyingObject { get; }
public UnitTestingSymbolKeyWrapper(SymbolKey underlyingObject)
=> UnderlyingObject = underlyingObject;
public override string ToString()
=> UnderlyingObject.ToString();
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Experiments;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingWellKnownExperimentNamesAccessor
{
public const string RoslynOOP64bit = WellKnownExperimentNames.RoslynOOP64bit;
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Remote;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingWorkspaceExtensions
{
public async static Task<UnitTestingRemoteHostClientWrapper> TryGetUnitTestingRemoteHostClientWrapperAsync(this Workspace workspace, CancellationToken cancellationToken)
{
var remoteHostClient = await workspace.TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
return new UnitTestingRemoteHostClientWrapper(remoteHostClient);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.Host.Mef;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting
{
internal sealed class UnitTestingExperimentationServiceAccessor : IUnitTestingExperimentationServiceAccessor
{
private readonly IExperimentationService _experimentationService;
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public UnitTestingExperimentationServiceAccessor(IExperimentationService experimentationService)
=> _experimentationService = experimentationService;
public bool IsExperimentEnabled(string experimentName)
=> _experimentationService.IsExperimentEnabled(experimentName);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Composition;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting
{
[ExportWorkspaceServiceFactory(typeof(IUnitTestingExperimentationServiceAccessor))]
[Shared]
internal class UnitTestingExperimentationServiceAccessorFactory : IWorkspaceServiceFactory
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public UnitTestingExperimentationServiceAccessorFactory() { }
[Obsolete(MefConstruction.FactoryMethodMessage, error: true)]
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
var experimentationService = workspaceServices.GetRequiredService<IExperimentationService>();
return new UnitTestingExperimentationServiceAccessor(experimentationService);
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting
{
internal class UnitTestingIncrementalAnalyzer : IIncrementalAnalyzer
{
private readonly IUnitTestingIncrementalAnalyzerImplementation _implementation;
public UnitTestingIncrementalAnalyzer(IUnitTestingIncrementalAnalyzerImplementation implementation)
=> _implementation = implementation;
public Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
=> _implementation.AnalyzeDocumentAsync(document, bodyOpt, new UnitTestingInvocationReasonsWrapper(reasons), cancellationToken);
public Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
=> _implementation.AnalyzeProjectAsync(project, semanticsChanged, new UnitTestingInvocationReasonsWrapper(reasons), cancellationToken);
public Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
=> _implementation.AnalyzeSyntaxAsync(document, new UnitTestingInvocationReasonsWrapper(reasons), cancellationToken);
public Task DocumentCloseAsync(Document document, CancellationToken cancellationToken)
=> _implementation.DocumentCloseAsync(document, cancellationToken);
public Task DocumentOpenAsync(Document document, CancellationToken cancellationToken)
=> _implementation.DocumentOpenAsync(document, cancellationToken);
public Task DocumentResetAsync(Document document, CancellationToken cancellationToken)
=> _implementation.DocumentResetAsync(document, cancellationToken);
public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs e)
=> _implementation.NeedsReanalysisOnOptionChanged(sender, new UnitTestingOptionChangedEventArgsWrapper(e));
public Task NewSolutionSnapshotAsync(Solution solution, CancellationToken cancellationToken)
=> _implementation.NewSolutionSnapshotAsync(solution, cancellationToken);
public void RemoveDocument(DocumentId documentId)
=> _implementation.RemoveDocument(documentId);
public void RemoveProject(ProjectId projectId)
=> _implementation.RemoveProject(projectId);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting
{
internal class UnitTestingIncrementalAnalyzerProvider : IIncrementalAnalyzerProvider
{
private readonly IUnitTestingIncrementalAnalyzerProviderImplementation _incrementalAnalyzerProvider;
public UnitTestingIncrementalAnalyzerProvider(IUnitTestingIncrementalAnalyzerProviderImplementation incrementalAnalyzerProvider)
=> _incrementalAnalyzerProvider = incrementalAnalyzerProvider;
public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace)
=> new UnitTestingIncrementalAnalyzer(_incrementalAnalyzerProvider.CreateIncrementalAnalyzer(workspace));
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting
{
internal sealed class UnitTestingSolutionCrawlerRegistrationServiceAccessor
: IUnitTestingSolutionCrawlerRegistrationServiceAccessor
{
private readonly ISolutionCrawlerRegistrationService _implementation;
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public UnitTestingSolutionCrawlerRegistrationServiceAccessor(ISolutionCrawlerRegistrationService implementation)
=> _implementation = implementation;
public void AddAnalyzerProvider(IUnitTestingIncrementalAnalyzerProviderImplementation provider, UnitTestingIncrementalAnalyzerProviderMetadataWrapper metadata)
=> _implementation.AddAnalyzerProvider(new UnitTestingIncrementalAnalyzerProvider(provider), metadata.UnderlyingObject);
public void Register(Workspace workspace)
=> _implementation.Register(workspace);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Composition;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting
{
[ExportWorkspaceServiceFactory(typeof(IUnitTestingSolutionCrawlerRegistrationServiceAccessor))]
[Shared]
internal sealed class UnitTestingSolutionCrawlerRegistrationServiceAccessorFactory : IWorkspaceServiceFactory
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public UnitTestingSolutionCrawlerRegistrationServiceAccessorFactory() { }
[Obsolete(MefConstruction.FactoryMethodMessage, error: true)]
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
var implementation = workspaceServices.GetRequiredService<ISolutionCrawlerRegistrationService>();
return new UnitTestingSolutionCrawlerRegistrationServiceAccessor(implementation);
}
}
}
......@@ -247,18 +247,18 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Debugger" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.UnitTesting" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Features" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.UnitTests" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator.UnitTests" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Test.Utilities" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager.UnitTests" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator.UnitTests" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Test.Utilities" Partner="UnitTesting" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer.Protocol" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Razor.ServiceHub" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Workspaces" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.UnitTests" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.UnitTests" Partner="UnitTesting" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Features" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.Remote;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingAssetStorageWrappper
{
public static UnitTestingAssetStorageWrappper Instance { get; } = new UnitTestingAssetStorageWrappper(AssetStorage.Default);
internal AssetStorage UnderlyingObject { get; }
internal UnitTestingAssetStorageWrappper(AssetStorage underlyingObject)
=> UnderlyingObject = underlyingObject ?? throw new ArgumentNullException(nameof(underlyingObject));
public void UpdateLastActivityTime()
=> UnderlyingObject.UpdateLastActivityTime();
}
}
......@@ -43,8 +43,8 @@
<InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.Razor.ServiceHub" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Execution;
using Microsoft.CodeAnalysis.Remote;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingPinnedSolutionInfoWrapper
{
/// <summary>
/// Because PinnedSolutionInfo is internal, and it is directly passed into the callee in
/// <see cref="KeepAliveSession.TryInvokeAsync{T}(string, Solution, System.Collections.Generic.IReadOnlyList{object}, System.Threading.CancellationToken)"/>
/// the type of <param name="underlyingObject"/> has to be object. Its runtime type is <see cref="JObject"/>.
/// </summary>
public UnitTestingPinnedSolutionInfoWrapper(object underlyingObject)
{
var reader = ((JObject)underlyingObject).CreateReader();
var serializer = JsonSerializer.Create(new JsonSerializerSettings() { Converters = new[] { AggregateJsonConverter.Instance } });
UnderlyingObject = serializer.Deserialize<PinnedSolutionInfo>(reader);
}
internal PinnedSolutionInfo UnderlyingObject { get; }
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Remote;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal readonly struct UnitTestingRoslynServicesWrapper
{
internal RoslynServices UnderlyingObject { get; }
public UnitTestingRoslynServicesWrapper(UnitTestingPinnedSolutionInfoWrapper pinnedSolutionInfoWrapper, UnitTestingAssetStorageWrappper assetStorageWrappper)
=> UnderlyingObject = new RoslynServices(pinnedSolutionInfoWrapper.UnderlyingObject.ScopeId, assetStorageWrappper.UnderlyingObject, RoslynServices.HostServices);
public Task<Solution> GetSolutionAsync(UnitTestingPinnedSolutionInfoWrapper pinnedSolutionInfoWrapper, CancellationToken cancellationToken)
=> UnderlyingObject.SolutionService.GetSolutionAsync(pinnedSolutionInfoWrapper.UnderlyingObject.SolutionChecksum, cancellationToken);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Microsoft.CodeAnalysis.Remote;
using StreamJsonRpc;
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal static class UnitTestingStreamExtensions
{
public static JsonRpc UnitTesting_CreateStreamJsonRpc(
this Stream stream,
object target,
TraceSource logger,
IEnumerable<AggregateJsonConverter> jsonConverters = null)
=> stream.CreateStreamJsonRpc(target, logger, jsonConverters);
}
}
......@@ -51,8 +51,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" WorkItem="https://github.com/dotnet/roslyn/issues/35078" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.BuildManager" Partner="UnitTesting" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册