提交 e9304b36 编写于 作者: J John Hamby

Merge pull request #11089 from vslsnap/merge-master-into-future20160505-150019

Merge master into future
SHELL = /usr/bin/env bash
OS_NAME = $(shell uname -s)
NUGET_PACKAGE_NAME = nuget.future.70
BUILD_CONFIGURATION = Debug
BINARIES_PATH = $(shell pwd)/Binaries
TOOLSET_PATH = $(BINARIES_PATH)/toolset
RESTORE_SEMAPHORE_PATH = $(TOOLSET_PATH)/restore.semaphore
BOOTSTRAP_PATH = $(BINARIES_PATH)/Bootstrap
BUILD_LOG_PATH =
XUNIT_VERSION = 2.1.0
HOME_DIR = $(shell cd ~ && pwd)
MSBUILD_ADDITIONALARGS := /v:m /fl /fileloggerparameters:Verbosity=normal /p:Configuration=$(BUILD_CONFIGURATION)
......
......@@ -372,10 +372,10 @@
<None Include="PerfTests\CSharpPerfGoldilocksTyping.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\CSharpPerfGoldilocksTypingDiagnostics.xml">
<None Include="PerfTests\CSharpPerfGoldilocksTypingFullSolutionDiagnostics.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\CSharpPerfGoldilocksTypingDiagnosticsMultipliedDelay.xml">
<None Include="PerfTests\CSharpPerfGoldilocksTypingFullSolutionDiagnosticsMultipliedDelay.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\CSharpPerfNavigateTo.xml" />
......@@ -482,28 +482,24 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<None Include="PerfTests\CSharpPerfGoldilocksTypingAnalyzers.xml">
<None Include="PerfTests\CSharpPerfGoldilocksTypingFullSolutionDiagnosticsThirdPartyAnalyzers.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</None>
<None Include="PerfTests\CSharpPerfDiagnosticInsideMethodBody.xml">
<None Include="PerfTests\CSharpPerfFullSolutionDiagnostics.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\CSharpPerfDiagnosticTopLevel.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\CSharpPerfGoldilocksTypingAnalyzersWithErrorHub.xml">
<SubType>Designer</SubType>
<None Include="PerfTests\CSharpPerfLightBulb.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\CSharpPerfDiagnosticTopLevelWithErrorHub.xml">
<None Include="PerfTests\CSharpPerfFullSolutionDiagnosticsThirdPartyAnalyzers.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\CSharpPerfLightBulb.xml">
<None Include="PerfTests\CSharpPerfBuildWithThirdPartyAnalyzers.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</None>
<Content Include="PerfTests\Sources\CSharpPgoTypingInput.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
......
......@@ -9,14 +9,17 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.CodeFixes.AddImport;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.SymbolSearch;
using Moq;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.AddUsing
{
using FixProviderData = Tuple<IPackageInstallerService, IPackageSearchService>;
using FixProviderData = Tuple<IPackageInstallerService, ISymbolSearchService>;
public partial class AddUsingTests
{
......@@ -27,6 +30,15 @@ public class NuGet : AddUsingTests
private static readonly ImmutableArray<PackageSource> NugetPackageSources =
ImmutableArray.Create(new PackageSource(NugetOrgSource, "http://nuget.org/"));
protected override async Task<TestWorkspace> CreateWorkspaceFromFileAsync(string definition, ParseOptions parseOptions, CompilationOptions compilationOptions)
{
var workspace = await base.CreateWorkspaceFromFileAsync(definition, parseOptions, compilationOptions);
workspace.Options = workspace.Options
.WithChangedOption(AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp, true)
.WithChangedOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp, true);
return workspace;
}
internal override Tuple<DiagnosticAnalyzer, CodeFixProvider> CreateDiagnosticProviderAndFixer(
Workspace workspace, object fixProviderData)
{
......@@ -50,7 +62,7 @@ public async Task TestSearchPackageSingleName()
installerServiceMock.SetupGet(i => i.IsEnabled).Returns(true);
installerServiceMock.SetupGet(i => i.PackageSources).Returns(NugetPackageSources);
var packageServiceMock = new Mock<IPackageSearchService>();
var packageServiceMock = new Mock<ISymbolSearchService>();
packageServiceMock.Setup(s => s.FindPackagesWithType(
NugetOrgSource, "NuGetType", 0, It.IsAny<CancellationToken>()))
.Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace")));
......@@ -79,7 +91,7 @@ public async Task TestSearchPackageMultipleNames()
installerServiceMock.SetupGet(i => i.IsEnabled).Returns(true);
installerServiceMock.SetupGet(i => i.PackageSources).Returns(NugetPackageSources);
var packageServiceMock = new Mock<IPackageSearchService>();
var packageServiceMock = new Mock<ISymbolSearchService>();
packageServiceMock.Setup(s => s.FindPackagesWithType(
NugetOrgSource, "NuGetType", 0, It.IsAny<CancellationToken>()))
.Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2")));
......@@ -110,7 +122,7 @@ public async Task TestMissingIfPackageAlreadyInstalled()
installerServiceMock.Setup(s => s.IsInstalled(It.IsAny<Workspace>(), It.IsAny<ProjectId>(), "NuGetPackage"))
.Returns(true);
var packageServiceMock = new Mock<IPackageSearchService>();
var packageServiceMock = new Mock<ISymbolSearchService>();
packageServiceMock.Setup(s => s.FindPackagesWithType(
NugetOrgSource, "NuGetType", 0, It.IsAny<CancellationToken>()))
.Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2")));
......@@ -134,7 +146,7 @@ public async Task TestOptionsOffered()
installerServiceMock.Setup(s => s.GetInstalledVersions("NuGetPackage"))
.Returns(new[] { "1.0", "2.0" });
var packageServiceMock = new Mock<IPackageSearchService>();
var packageServiceMock = new Mock<ISymbolSearchService>();
packageServiceMock.Setup(s => s.FindPackagesWithType(
NugetOrgSource, "NuGetType", 0, It.IsAny<CancellationToken>()))
.Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2")));
......@@ -180,7 +192,7 @@ public async Task TestInstallGetsCalledNoVersion()
installerServiceMock.Setup(s => s.TryInstallPackage(
It.IsAny<Workspace>(), It.IsAny<DocumentId>(), It.IsAny<string>(), "NuGetPackage", /*versionOpt*/ null, It.IsAny<CancellationToken>()));
var packageServiceMock = new Mock<IPackageSearchService>();
var packageServiceMock = new Mock<ISymbolSearchService>();
packageServiceMock.Setup(s => s.FindPackagesWithType(
NugetOrgSource, "NuGetType", 0, It.IsAny<CancellationToken>()))
.Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace")));
......@@ -212,7 +224,7 @@ public async Task TestInstallGetsCalledWithVersion()
installerServiceMock.Setup(s => s.TryInstallPackage(
It.IsAny<Workspace>(), It.IsAny<DocumentId>(), It.IsAny<string>(), "NuGetPackage", "1.0", It.IsAny<CancellationToken>()));
var packageServiceMock = new Mock<IPackageSearchService>();
var packageServiceMock = new Mock<ISymbolSearchService>();
packageServiceMock.Setup(s => s.FindPackagesWithType(NugetOrgSource, "NuGetType", 0, It.IsAny<CancellationToken>()))
.Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace")));
......
<?xml version="1.0" encoding="utf-8" ?>
<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">
<InitTest>
<StartTarget DontResetOptions="true" />
<EnableClosedFileDiagnostic Enabled="true" Language="C#"/>
<PerfEnableEtwDiagnosticLogger/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-CSharp.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true" />
<!-- Disable built-in IDE analyzers -->
<DisableAnalyzers Analyzers = "Microsoft.CodeAnalysis.Features.dll;Microsoft.CodeAnalysis.CSharp.Features.dll;Microsoft.CodeAnalysis.VisualBasic.Features.dll;Microsoft.CodeAnalysis.EditorFeatures.dll;Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll;Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll"
RulesetFile ="Tools\Targets\Roslyn.ruleset"/>
<!-- Add 3rd party C# StyleCop analyzers -->
<AddAnalyzersToSolution CSharpAnalyzers="References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll"/>
<!-- Save all the project file modifications, so that we can trigger build with analyzers -->
<ExecuteCommand Command="File.SaveAll" />
</InitTest>
<ScenarioList>
<Scenario Name="Solution Build" Description="Build solution with analyzers">
<ForceGC />
<CleanSolution/>
<MeasureTimeStart ScenarioGroup="Solution Build" Step="Build" TimeGoal="0.1" MemoryGoal="0.9" />
<Build IgnoreBuildResult="true"/>
<MeasureTimeStop/>
</Scenario>
<Scenario Name="CompilationWithAnalyzers" Description="Get analyzer diagnostics with CompilationWithAnalyzers public API">
<ForceGC />
<MeasureTimeStart ScenarioGroup="CompilationWithAnalyzers" Step="CompilationWithAnalyzers" TimeGoal="0.1" MemoryGoal="0.9" />
<VerifyCompilationWithAnalyzers Count="220659"/>
<MeasureTimeStop/>
</Scenario>
</ScenarioList>
<CleanupTest>
<!-- Revert the ruleset changes -->
<ReplaceRuleset SourceRulesetFile="Tools\Targets\Roslyn_Default.ruleset" DestinationRulesetFile="Tools\Targets\Roslyn.ruleset"/>
<!-- Remove the added analyzers -->
<RemoveAnalyzersFromSolution CSharpAnalyzers="References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll"/>
<!-- Save all the analyzer reference removals from the project files -->
<ExecuteCommand Command="File.SaveAll" />
<CloseTarget />
</CleanupTest>
</TaoTest>
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<!-- This test uses a recording of three real users typing. -->
<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">
<InitTest>
<StartTarget DontResetOptions="true" />
<EnableClosedFileDiagnostic Enabled="true" Language="C#"/>
<PerfEnableEtwDiagnosticLogger/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-CSharp.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<AddAnalyzersToSolution CommonAnalyzers="Microsoft.CodeAnalysis.FxCopAnalyzers.dll"
CSharpAnalyzers="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll"
VisualBasicAnalyzers="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll"/>
<ForceGC/>
</InitTest>
<ScenarioList>
<Scenario Name="CSharp Diagnostic Inside MethodBody" Description="CSharp Diagnostic Inside MethodBody">
<OpenFile FileName="LanguageParser.cs"/>
<!-- Insert Wait to let things cool down. For more accurate timings use WaitForIdleCPU. -->
<!--<Wait Seconds="10"/>-->
<WaitForIdleCPU/>
<ForceGC />
<WaitForIdleCPU/>
<PerfStartEtwListener FunctionIds="Workspace_Document_State_IncrementallyParseSyntaxTree;WorkCoordinator_ProcessDocumentAsync;WorkCoordinator_AsyncWorkItemQueue_LastItem;Diagnostics_SyntaxDiagnostic"/>
<GoToLine LineNumber="189"/>
<Wait Seconds="5" />
<PerfVerifyDiagnostics Text="i" ScenarioGroup="CSharp Diagnostics MethodBody" TimeGoal="0.1" MemoryGoal="0.9" />
<PerfStopEtwListener/>
<!-- <VerifyRoslynModulesLoadedStatus ExpectedStatus="CSharp" /> -->
<!-- <VerifyRoslynModulesLoadedStatus ExpectedStatus="NoBasic" /> -->
</Scenario>
</ScenarioList>
<CleanupScenario>
<CloseFile SaveFile="false"/>
</CleanupScenario>
<CleanupTest>
<CloseTarget />
</CleanupTest>
</TaoTest>
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures background diagnostic analysis performance with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<!-- This test uses a recording of three real users typing. -->
......@@ -12,9 +15,6 @@
<PerfEnableEtwDiagnosticLogger/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-CSharp.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<AddAnalyzersToSolution CommonAnalyzers="Microsoft.CodeAnalysis.FxCopAnalyzers.dll"
CSharpAnalyzers="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll"
VisualBasicAnalyzers="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll"/>
<ForceGC/>
</InitTest>
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures background diagnostic analysis performance with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Third party analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<!-- This test uses a recording of three real users typing. -->
......@@ -11,17 +14,18 @@
<EnableClosedFileDiagnostic Enabled="true" Language="C#"/>
<PerfEnableEtwDiagnosticLogger/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-CSharp.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<AddAnalyzersToSolution CommonAnalyzers="Microsoft.CodeAnalysis.FxCopAnalyzers.dll"
CSharpAnalyzers="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll"
VisualBasicAnalyzers="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll"/>
<Wait Seconds="10" />
<!-- Disable built-in IDE analyzers -->
<DisableAnalyzers Analyzers = "Microsoft.CodeAnalysis.Features.dll;Microsoft.CodeAnalysis.CSharp.Features.dll;Microsoft.CodeAnalysis.VisualBasic.Features.dll;Microsoft.CodeAnalysis.EditorFeatures.dll;Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll;Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll"
RulesetFile ="Tools\Targets\Roslyn.ruleset"/>
<!-- Add 3rd party C# StyleCop analyzers -->
<AddAnalyzersToSolution CSharpAnalyzers="References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll"/>
<ForceGC/>
</InitTest>
<ScenarioList>
<Scenario Name="CSharp Diagnostic Top Level With Error Hub" Description="CSharp Diagnostic Top Level With Error Hub">
<PerfShowErrorList />
<Scenario Name="CSharp Diagnostic Top Level" Description="CSharp Diagnostic Top Level">
<OpenFile FileName="LanguageParser.cs"/>
<!-- Insert Wait to let things cool down. For more accurate timings use WaitForIdleCPU. -->
<!--<Wait Seconds="10"/>-->
......@@ -32,13 +36,12 @@
<GoToLine LineNumber="4775" />
<Wait Seconds="5" />
<PlaceCursor Marker="Name" />
<PerfVerifyDiagnostics Text="i" ScenarioGroup="CSharp Diagnostic Top Level With Error Hub" TimeGoal="0.1" MemoryGoal="0.9" />
<PerfVerifyDiagnostics Text="i" ScenarioGroup="CSharp Diagnostics Top Level" TimeGoal="0.1" MemoryGoal="0.9" />
<PerfStopEtwListener/>
<VerifyRoslynModulesLoadedStatus ExpectedStatus="CSharp" />
<VerifyRoslynModulesLoadedStatus ExpectedStatus="NoBasic" />
</Scenario>
<!--<VerifyRoslynModulesLoadedStatus ExpectedStatus="CSharp" />-->
<!--<VerifyRoslynModulesLoadedStatus ExpectedStatus="NoBasic" />-->
</ScenarioList>
<CleanupScenario>
......@@ -46,6 +49,10 @@
</CleanupScenario>
<CleanupTest>
<!-- Revert the ruleset changes -->
<ReplaceRuleset SourceRulesetFile="Tools\Targets\Roslyn_Default.ruleset" DestinationRulesetFile="Tools\Targets\Roslyn.ruleset"/>
<!-- Remove the added analyzers -->
<RemoveAnalyzersFromSolution CSharpAnalyzers="References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll"/>
<CloseTarget />
</CleanupTest>
</TaoTest>
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures typing responsiveness with: -->
<!-- (a) Full solution analysis turned **OFF**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<!-- This test uses a recording of three real users typing. -->
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<!-- This test uses a recording of three real users typing. -->
<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">
<InitTest>
<StartTarget DontResetOptions="true" />
<EnableClosedFileDiagnostic Enabled="true" Language="C#"/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-CSharp.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<AddAnalyzersToSolution CommonAnalyzers="Microsoft.CodeAnalysis.FxCopAnalyzers.dll"
CSharpAnalyzers="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll"
VisualBasicAnalyzers="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll"/>
<ForceGC/>
</InitTest>
<ScenarioList>
<Scenario Name="Type Responsiveness" Description="Type Responsiveness">
<PerfShowErrorList />
<DelayTracker Action="Start" TestName="Roslyn-CSharp(GoldilocksAnalyzersErrorHub)" OutputPath="$(WorkingDir)" />
<OpenFile FileName="LanguageParser.cs"/>
<!-- Insert Wait to let things cool down. For more accurate timings use WaitForIdleCPU. -->
<!--<Wait Seconds="10"/>-->
<WaitForSolutionCrawler/>
<ForceGC />
<WaitForIdleCPU/>
<GoToLine LineNumber="9524"/>
<PlayBackTyping TypingInputFile="PerfTests\Sources\CSharpGoldilocksInput.txt" />
<DelayTracker Action="Stop" />
<!--<VerifyRoslynModulesLoadedStatus ExpectedStatus="CSharp" />-->
<!--<VerifyRoslynModulesLoadedStatus ExpectedStatus="NoBasic" />-->
</Scenario>
</ScenarioList>
<CleanupScenario>
<CloseFile SaveFile="false"/>
</CleanupScenario>
<CleanupTest>
<CloseTarget />
</CleanupTest>
</TaoTest>
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures typing responsiveness with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<!-- This test uses a recording of three real users typing. -->
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures typing responsiveness with mutiple delays with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<!-- This test uses a recording of three real users typing. -->
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures typing responsiveness with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Third party analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<!-- This test uses a recording of three real users typing. -->
......@@ -11,14 +14,15 @@
<EnableClosedFileDiagnostic Enabled="true" Language="C#"/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-CSharp.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<AddAnalyzersToSolution CommonAnalyzers="Microsoft.CodeAnalysis.FxCopAnalyzers.dll"
CSharpAnalyzers="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll"
VisualBasicAnalyzers="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll"/>
<!-- Disable built-in IDE analyzers -->
<DisableAnalyzers Analyzers = "Microsoft.CodeAnalysis.Features.dll;Microsoft.CodeAnalysis.CSharp.Features.dll;Microsoft.CodeAnalysis.VisualBasic.Features.dll;Microsoft.CodeAnalysis.EditorFeatures.dll;Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll;Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll"
RulesetFile ="Tools\Targets\Roslyn.ruleset"/>
<!-- Add 3rd party C# StyleCop analyzers -->
<AddAnalyzersToSolution CSharpAnalyzers="References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll"/>
<ForceGC/>
</InitTest>
<ScenarioList>
<Scenario Name="Type Responsiveness" Description="Type Responsiveness">
<DelayTracker Action="Start" TestName="Roslyn-CSharp(GoldilocksAnalyzers)" OutputPath="$(WorkingDir)" />
<OpenFile FileName="LanguageParser.cs"/>
......@@ -42,6 +46,10 @@
</CleanupScenario>
<CleanupTest>
<!-- Revert the ruleset changes -->
<ReplaceRuleset SourceRulesetFile="Tools\Targets\Roslyn_Default.ruleset" DestinationRulesetFile="Tools\Targets\Roslyn.ruleset"/>
<!-- Remove the added analyzers -->
<RemoveAnalyzersFromSolution CSharpAnalyzers="References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll;References\Analyzers\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll"/>
<CloseTarget />
</CleanupTest>
</TaoTest>
......@@ -502,10 +502,10 @@
<None Include="PerfTests\BasicPerfGoldilocksTyping.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\BasicPerfGoldilocksTypingDiagnostics.xml">
<None Include="PerfTests\BasicPerfGoldilocksTypingFullSolutionDiagnostics.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\BasicPerfGoldilocksTypingDiagnosticsMultipliedDelay.xml">
<None Include="PerfTests\BasicPerfGoldilocksTypingFullSolutionDiagnosticsMultipliedDelay.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\BasicPerfNavigateTo.xml" />
......@@ -584,14 +584,11 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<None Include="PerfTests\BasicPerfGoldilocksTypingAnalyzers.xml">
<None Include="PerfTests\BasicPerfGoldilocksTypingFullSolutionDiagnosticsThirdPartyAnalyzers.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\BasicPerfDiagnosticInsideMethodBody.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\BasicPerfDiagnosticTopLevel.xml">
<None Include="PerfTests\BasicPerfFullSolutionDiagnostics.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......@@ -599,6 +596,14 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Compile Include="CodeActions\ReplaceMethodWithProperty\ReplaceMethodWithPropertyTests.vb" />
<None Include="PerfTests\BasicPerfFullSolutionDiagnosticsThirdPartyAnalyzers.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="PerfTests\BasicPerfBuildWithThirdPartyAnalyzers.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</None>
<Content Include="PerfTests\Sources\BasicPgoTypingInput.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
......
......@@ -5,11 +5,14 @@ Imports System.Threading
Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Packaging
Imports Microsoft.CodeAnalysis.Shared.Options
Imports Microsoft.CodeAnalysis.SymbolSearch
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.CodeFixes.AddImport
Imports Moq
Imports ProviderData = System.Tuple(Of Microsoft.CodeAnalysis.Packaging.IPackageInstallerService, Microsoft.CodeAnalysis.Packaging.IPackageSearchService)
Imports ProviderData = System.Tuple(Of Microsoft.CodeAnalysis.Packaging.IPackageInstallerService, Microsoft.CodeAnalysis.SymbolSearch.ISymbolSearchService)
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImport
Partial Public Class AddImportTests
......@@ -21,6 +24,14 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp
Private Shared ReadOnly NugetPackageSources As ImmutableArray(Of PackageSource) =
ImmutableArray.Create(New PackageSource(NugetOrgSource, "http://nuget.org"))
Protected Overrides Async Function CreateWorkspaceFromFileAsync(definition As String, parseOptions As ParseOptions, compilationOptions As CompilationOptions) As Task(Of TestWorkspace)
Dim workspace = Await MyBase.CreateWorkspaceFromFileAsync(definition, parseOptions, compilationOptions)
workspace.Options = workspace.Options.
WithChangedOption(AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.VisualBasic, True).
WithChangedOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.VisualBasic, True)
Return workspace
End Function
Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace, fixProviderData As Object) As Tuple(Of DiagnosticAnalyzer, CodeFixProvider)
Dim data = DirectCast(fixProviderData, ProviderData)
Return Tuple.Create(Of DiagnosticAnalyzer, CodeFixProvider)(
......@@ -40,7 +51,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp
installerServiceMock.SetupGet(Function(i) i.IsEnabled).Returns(True)
installerServiceMock.SetupGet(Function(i) i.PackageSources).Returns(NugetPackageSources)
Dim packageServiceMock = New Mock(Of IPackageSearchService)()
Dim packageServiceMock = New Mock(Of ISymbolSearchService)()
packageServiceMock.Setup(Function(s) s.FindPackagesWithType(NugetOrgSource, "NuGetType", 0, It.IsAny(Of CancellationToken)())).
Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace")))
......@@ -65,7 +76,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa
installerServiceMock.SetupGet(Function(i) i.IsEnabled).Returns(True)
installerServiceMock.SetupGet(Function(i) i.PackageSources).Returns(NugetPackageSources)
Dim packageServiceMock = New Mock(Of IPackageSearchService)()
Dim packageServiceMock = New Mock(Of ISymbolSearchService)()
packageServiceMock.Setup(Function(s) s.FindPackagesWithType(NugetOrgSource, "NuGetType", 0, It.IsAny(Of CancellationToken)())).
Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2")))
......@@ -92,7 +103,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa
installerServiceMock.Setup(Function(s) s.IsInstalled(It.IsAny(Of Workspace)(), It.IsAny(Of ProjectId)(), "NuGetPackage")).
Returns(True)
Dim packageServiceMock = New Mock(Of IPackageSearchService)()
Dim packageServiceMock = New Mock(Of ISymbolSearchService)()
packageServiceMock.Setup(Function(s) s.FindPackagesWithType(NugetOrgSource, "NuGetType", 0, It.IsAny(Of CancellationToken)())).
Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2")))
......@@ -114,7 +125,7 @@ fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMoc
installerServiceMock.Setup(Function(s) s.GetInstalledVersions("NuGetPackage")).
Returns({"1.0", "2.0"})
Dim packageServiceMock = New Mock(Of IPackageSearchService)()
Dim packageServiceMock = New Mock(Of ISymbolSearchService)()
packageServiceMock.Setup(Function(s) s.FindPackagesWithType(NugetOrgSource, "NuGetType", 0, It.IsAny(Of CancellationToken)())).
Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2")))
......@@ -155,7 +166,7 @@ fixProviderData:=data)
installerServiceMock.Setup(Function(s) s.TryInstallPackage(
It.IsAny(Of Workspace), It.IsAny(Of DocumentId), It.IsAny(Of String), "NuGetPackage", Nothing, It.IsAny(Of CancellationToken)))
Dim packageServiceMock = New Mock(Of IPackageSearchService)()
Dim packageServiceMock = New Mock(Of ISymbolSearchService)()
packageServiceMock.Setup(Function(s) s.FindPackagesWithType(NugetOrgSource, "NuGetType", 0, It.IsAny(Of CancellationToken)())).
Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace")))
......@@ -183,7 +194,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa
installerServiceMock.Setup(Function(s) s.TryInstallPackage(
It.IsAny(Of Workspace), It.IsAny(Of DocumentId), It.IsAny(Of String), "NuGetPackage", "1.0", It.IsAny(Of CancellationToken)))
Dim packageServiceMock = New Mock(Of IPackageSearchService)()
Dim packageServiceMock = New Mock(Of ISymbolSearchService)()
packageServiceMock.Setup(Function(s) s.FindPackagesWithType(NugetOrgSource, "NuGetType", 0, It.IsAny(Of CancellationToken)())).
Returns(CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace")))
......
<?xml version="1.0" encoding="utf-8" ?>
<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">
<InitTest>
<StartTarget DontResetOptions="true" />
<EnableClosedFileDiagnostic Enabled="true" Language="Visual Basic"/>
<PerfEnableEtwDiagnosticLogger/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-VB.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<!-- Disable built-in IDE analyzers -->
<DisableAnalyzers Analyzers = "Microsoft.CodeAnalysis.Features.dll;Microsoft.CodeAnalysis.CSharp.Features.dll;Microsoft.CodeAnalysis.VisualBasic.Features.dll;Microsoft.CodeAnalysis.EditorFeatures.dll;Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll;Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll"
RulesetFile ="Tools\Targets\Roslyn.ruleset"/>
<!-- Add 3rd party VB FxCop analyzers -->
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.Analyzers.dll;References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.Analyzers.dll;References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.Common.dll;References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.VisualBasic.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.Analyzers.dll;References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.Analyzers.dll;References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.VisualBasic.Analyzers.dll"/>
<!-- Save all the project file modifications, so that we can trigger build with analyzers -->
<ExecuteCommand Command="File.SaveAll" />
</InitTest>
<ScenarioList>
<Scenario Name="Solution Build" Description="Build solution with analyzers">
<ForceGC />
<CleanSolution/>
<MeasureTimeStart ScenarioGroup="Solution Build" Step="Build" TimeGoal="0.1" MemoryGoal="0.9" />
<Build ExpectBuildToFail="true"/>
<MeasureTimeStop/>
</Scenario>
<Scenario Name="CompilationWithAnalyzers" Description="Get analyzer diagnostics with CompilationWithAnalyzers public API">
<ForceGC />
<MeasureTimeStart ScenarioGroup="CompilationWithAnalyzers" Step="CompilationWithAnalyzers" TimeGoal="0.1" MemoryGoal="0.9" />
<VerifyCompilationWithAnalyzers Count="77"/>
<MeasureTimeStop/>
</Scenario>
</ScenarioList>
<CleanupTest>
<!-- Revert the ruleset changes -->
<ReplaceRuleset SourceRulesetFile="Tools\Targets\Roslyn_Default.ruleset" DestinationRulesetFile="Tools\Targets\Roslyn.ruleset"/>
<!-- Remove added analyzers -->
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.Analyzers.dll;References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.Analyzers.dll;References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.Common.dll;References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.VisualBasic.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.Analyzers.dll;References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.Analyzers.dll;References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.VisualBasic.Analyzers.dll"/>
<!-- Save all the analyzer reference removals from the project files -->
<ExecuteCommand Command="File.SaveAll" />
<CloseTarget />
</CleanupTest>
</TaoTest>
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">
<InitTest>
<StartTarget DontResetOptions="true" />
<EnableClosedFileDiagnostic Enabled="true" Language="Visual Basic"/>
<PerfEnableEtwDiagnosticLogger/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-VB.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<AddAnalyzersToSolution CommonAnalyzers="Microsoft.CodeAnalysis.FxCopAnalyzers.dll"
CSharpAnalyzers="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll"
VisualBasicAnalyzers="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll"/>
<ForceGC/>
</InitTest>
<ScenarioList>
<Scenario Name="Basic Diagnostic Inside MethodBody" Description="Basic Diagnostic Inside MethodBody">
<OpenFile FileName="SourceNamedTypeSymbol.vb"/>
<!-- Insert Wait to let things cool down. For more accurate timings use WaitForIdleCPU. -->
<!-- <Wait Seconds="10"/> -->
<WaitForIdleCPU/>
<ForceGC />
<WaitForIdleCPU/>
<PerfStartEtwListener FunctionIds="Workspace_Document_State_IncrementallyParseSyntaxTree;WorkCoordinator_ProcessDocumentAsync;WorkCoordinator_AsyncWorkItemQueue_LastItem;Diagnostics_SyntaxDiagnostic"/>
<GoToLine LineNumber="173"/>
<Wait Seconds="5" />
<PerfVerifyDiagnostics Text="c" ScenarioGroup="VisualBasic Diagnostics MethodBody" TimeGoal="0.1" MemoryGoal="0.9" />
<PerfStopEtwListener/>
<!-- <VerifyRoslynModulesLoadedStatus ExpectedStatus="NoCSharp" /> -->
<!-- <VerifyRoslynModulesLoadedStatus ExpectedStatus="Basic" /> -->
</Scenario>
</ScenarioList>
<CleanupScenario>
<CloseFile SaveFile="false"/>
</CleanupScenario>
<CleanupTest>
<CloseTarget />
</CleanupTest>
</TaoTest>
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures background diagnostic analysis performance with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
......@@ -11,9 +14,6 @@
<PerfEnableEtwDiagnosticLogger/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-VB.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<AddAnalyzersToSolution CommonAnalyzers="Microsoft.CodeAnalysis.FxCopAnalyzers.dll"
CSharpAnalyzers="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll"
VisualBasicAnalyzers="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll"/>
<ForceGC/>
</InitTest>
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures background diagnostic analysis performance with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">
<InitTest>
<StartTarget DontResetOptions="true" />
<EnableClosedFileDiagnostic Enabled="true" Language="Visual Basic"/>
<PerfEnableEtwDiagnosticLogger/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-VB.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<!-- Disable built-in IDE analyzers -->
<DisableAnalyzers Analyzers = "Microsoft.CodeAnalysis.Features.dll;Microsoft.CodeAnalysis.CSharp.Features.dll;Microsoft.CodeAnalysis.VisualBasic.Features.dll;Microsoft.CodeAnalysis.EditorFeatures.dll;Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll;Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll"
RulesetFile ="Tools\Targets\Roslyn.ruleset"/>
<!-- Add 3rd party VB FxCop analyzers -->
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.Analyzers.dll;References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.Analyzers.dll;References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.Common.dll;References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.VisualBasic.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.Analyzers.dll;References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.Analyzers.dll;References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.VisualBasic.Analyzers.dll"/>
<ForceGC/>
</InitTest>
<ScenarioList>
<Scenario Name="Basic Diagnostic Top Level" Description="Basic Diagnostic Top Level">
<OpenFile FileName="SourceNamedTypeSymbol.vb"/>
<!-- Insert Wait to let things cool down. For more accurate timings use WaitForIdleCPU. -->
<!-- <Wait Seconds="10"/> -->
<WaitForIdleCPU/>
<ForceGC />
<WaitForIdleCPU/>
<PerfStartEtwListener FunctionIds="Workspace_Document_State_IncrementallyParseSyntaxTree;WorkCoordinator_ProcessDocumentAsync;WorkCoordinator_AsyncWorkItemQueue_LastItem;Diagnostics_SyntaxDiagnostic"/>
<GoToLine LineNumber="570"/>
<Wait Seconds="5" />
<PlaceCursor Marker="Members" />
<PerfVerifyDiagnostics Text="c" ScenarioGroup="VisualBasic Diagnostics Top Level" TimeGoal="0.1" MemoryGoal="0.9" />
<PerfStopEtwListener/>
<!-- <VerifyRoslynModulesLoadedStatus ExpectedStatus="NoCSharp" /> -->
<!-- <VerifyRoslynModulesLoadedStatus ExpectedStatus="Basic" /> -->
</Scenario>
</ScenarioList>
<CleanupScenario>
<CloseFile SaveFile="false"/>
</CleanupScenario>
<CleanupTest>
<!-- Revert the ruleset changes -->
<ReplaceRuleset SourceRulesetFile="Tools\Targets\Roslyn_Default.ruleset" DestinationRulesetFile="Tools\Targets\Roslyn.ruleset"/>
<!-- Remove added analyzers -->
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.Analyzers.dll;References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.Analyzers.dll;References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.Common.dll;References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.VisualBasic.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.Analyzers.dll;References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.Analyzers.dll;References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.VisualBasic.Analyzers.dll"/>
<CloseTarget />
</CleanupTest>
</TaoTest>
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures typing responsiveness with: -->
<!-- (a) Full solution analysis turned **OFF**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">
<InitTest>
<StartTarget DontResetOptions="true" />
<EnableClosedFileDiagnostic Enabled="true" Language="Visual Basic"/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-VB.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<AddAnalyzersToSolution CommonAnalyzers="Microsoft.CodeAnalysis.FxCopAnalyzers.dll"
CSharpAnalyzers="Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll"
VisualBasicAnalyzers="Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll"/>
<ForceGC/>
</InitTest>
<ScenarioList>
<Scenario Name="Type Responsiveness" Description="Type Responsiveness">
<DelayTracker Action="Start" TestName="Roslyn-VB(GoldilocksAnalyzers)" OutputPath="$(WorkingDir)" />
<OpenFile FileName="SourceNamedTypeSymbol.vb"/>
<!-- Insert Wait to let things cool down. For more accurate timings use WaitForIdleCPU. -->
<!-- <Wait Seconds="10"/> -->
<WaitForSolutionCrawler/>
<ForceGC />
<WaitForIdleCPU/>
<GoToLine LineNumber="5836"/>
<PlayBackTyping TypingInputFile="PerfTests\Sources\BasicGoldilocksInput.txt" />
<DelayTracker Action="Stop"/>
<!--<VerifyRoslynModulesLoadedStatus ExpectedStatus="NoCSharp" />-->
<!--<VerifyRoslynModulesLoadedStatus ExpectedStatus="Basic" />-->
</Scenario>
</ScenarioList>
<CleanupScenario>
<CloseFile SaveFile="false"/>
</CleanupScenario>
<CleanupTest>
<CloseTarget />
</CleanupTest>
</TaoTest>
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures typing responsiveness with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness. It uses the same delay tracker as the DDRIT test. -->
<!-- This test measures typing responsiveness with mutiple delays with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Built-in IDE analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- This test measures typing responsiveness with: -->
<!-- (a) Full solution analysis turned **ON**. -->
<!-- (a) Third party analyzers. -->
<!-- It uses the same delay tracker as the DDRIT test. -->
<!-- This test doesn't produce a regular Tao perf results file. Instead it produce a log and a -->
<!-- results file. -->
<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">
<InitTest>
<StartTarget DontResetOptions="true" />
<EnableClosedFileDiagnostic Enabled="true" Language="Visual Basic"/>
<OpenProject ProjectFile="C:\Roslyn\LegacyTest\RealworldProjects\RoslynSolutions\Roslyn-VB.sln" DeleteSuoFileBeforeOpening="true" DeleteIDECacheBeforeOpening="true"/>
<Wait Seconds="60" />
<!-- Disable built-in IDE analyzers -->
<DisableAnalyzers Analyzers = "Microsoft.CodeAnalysis.Features.dll;Microsoft.CodeAnalysis.CSharp.Features.dll;Microsoft.CodeAnalysis.VisualBasic.Features.dll;Microsoft.CodeAnalysis.EditorFeatures.dll;Microsoft.CodeAnalysis.CSharp.EditorFeatures.dll;Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.dll"
RulesetFile ="Tools\Targets\Roslyn.ruleset"/>
<!-- Add 3rd party VB FxCop analyzers -->
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.Analyzers.dll;References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.Analyzers.dll;References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.Common.dll;References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.VisualBasic.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.Analyzers.dll;References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.VisualBasic.Analyzers.dll"/>
<AddAnalyzersToSolution VisualBasicAnalyzers="References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.Analyzers.dll;References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.VisualBasic.Analyzers.dll"/>
<ForceGC/>
</InitTest>
<ScenarioList>
<Scenario Name="Type Responsiveness" Description="Type Responsiveness">
<DelayTracker Action="Start" TestName="Roslyn-VB(GoldilocksAnalyzers)" OutputPath="$(WorkingDir)" />
<OpenFile FileName="SourceNamedTypeSymbol.vb"/>
<!-- Insert Wait to let things cool down. For more accurate timings use WaitForIdleCPU. -->
<!-- <Wait Seconds="10"/> -->
<WaitForSolutionCrawler/>
<ForceGC />
<WaitForIdleCPU/>
<GoToLine LineNumber="5836"/>
<PlayBackTyping TypingInputFile="PerfTests\Sources\BasicGoldilocksInput.txt" />
<DelayTracker Action="Stop"/>
<!--<VerifyRoslynModulesLoadedStatus ExpectedStatus="NoCSharp" />-->
<!--<VerifyRoslynModulesLoadedStatus ExpectedStatus="Basic" />-->
</Scenario>
</ScenarioList>
<CleanupScenario>
<CloseFile SaveFile="false"/>
</CleanupScenario>
<CleanupTest>
<!-- Revert the ruleset changes -->
<ReplaceRuleset SourceRulesetFile="Tools\Targets\Roslyn_Default.ruleset" DestinationRulesetFile="Tools\Targets\Roslyn.ruleset"/>
<!-- Remove added analyzers -->
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.Analyzers.dll;References\Analyzers\Desktop.Analyzers.1.1.0\analyzers\dotnet\vb\Desktop.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.Analyzers.dll;References\Analyzers\System.Runtime.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.Common.dll;References\Analyzers\Microsoft.AnalyzerPowerPack.1.0.1\analyzers\dotnet\vb\Microsoft.AnalyzerPowerPack.VisualBasic.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.Analyzers.dll;References\Analyzers\System.Runtime.InteropServices.Analyzers.1.0.1\analyzers\dotnet\vb\System.Runtime.InteropServices.VisualBasic.Analyzers.dll"/>
<RemoveAnalyzersFromSolution VisualBasicAnalyzers="References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.Analyzers.dll;References\Analyzers\System.Security.Cryptography.Hashing.Algorithms.Analyzers.1.1.0\analyzers\dotnet\vb\System.Security.Cryptography.Hashing.Algorithms.VisualBasic.Analyzers.dll"/>
<CloseTarget />
</CleanupTest>
</TaoTest>
......@@ -19,6 +19,7 @@
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.SymbolSearch;
using Roslyn.Utilities;
using static Microsoft.CodeAnalysis.CSharp.CodeFixes.AddImport.AddImportDiagnosticIds;
......@@ -154,8 +155,8 @@ public CSharpAddImportCodeFixProvider()
/// <summary>For testing purposes only (so that tests can pass in mock values)</summary>
internal CSharpAddImportCodeFixProvider(
IPackageInstallerService installerService,
IPackageSearchService packageSearchService)
: base(installerService, packageSearchService)
ISymbolSearchService symbolSearchService)
: base(installerService, symbolSearchService)
{
}
......
......@@ -8,6 +8,7 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.SymbolSearch;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeFixes.AddImport
......
// 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.Concurrent;
using System.Collections.Generic;
using System.Linq;
......@@ -9,6 +8,8 @@
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.SymbolSearch;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeFixes.AddImport
......@@ -232,32 +233,41 @@ private async Task<IList<SymbolReference>> GetMatchingTypesAsync(SearchScope sea
{
var workspaceServices = _document.Project.Solution.Workspace.Services;
var packageSearchService = _owner._packageSearchService ?? workspaceServices.GetService<IPackageSearchService>();
var referenceAssemblySearchService = _owner._referenceAssemblySearchService ?? workspaceServices.GetService<IReferenceAssemblySearchService>();
var symbolSearchService = _owner._symbolSearchService ?? workspaceServices.GetService<ISymbolSearchService>();
var installerService = _owner._packageInstallerService ?? workspaceServices.GetService<IPackageInstallerService>();
if (referenceAssemblySearchService != null)
var language = _document.Project.Language;
var options = workspaceServices.Workspace.Options;
var searchReferenceAssemblies = options.GetOption(
AddImportOptions.SuggestForTypesInReferenceAssemblies, language);
var searchNugetPackages = options.GetOption(
AddImportOptions.SuggestForTypesInNuGetPackages, language);
if (symbolSearchService != null &&
searchReferenceAssemblies)
{
cancellationToken.ThrowIfCancellationRequested();
await FindReferenceAssemblyTypeReferencesAsync(
referenceAssemblySearchService, allReferences, nameNode, name, arity, isAttributeSearch, cancellationToken).ConfigureAwait(false);
symbolSearchService, allReferences, nameNode, name, arity, isAttributeSearch, cancellationToken).ConfigureAwait(false);
}
if (packageSearchService != null &&
if (symbolSearchService != null &&
searchNugetPackages &&
installerService.IsEnabled)
{
foreach (var packageSource in installerService.PackageSources)
{
cancellationToken.ThrowIfCancellationRequested();
await FindNugetTypeReferencesAsync(
packageSource, packageSearchService, installerService, allReferences,
packageSource, symbolSearchService, installerService, allReferences,
nameNode, name, arity, isAttributeSearch, cancellationToken).ConfigureAwait(false);
}
}
}
private async Task FindReferenceAssemblyTypeReferencesAsync(
IReferenceAssemblySearchService searchService,
ISymbolSearchService searchService,
List<Reference> allReferences,
TSimpleNameSyntax nameNode,
string name,
......@@ -283,7 +293,7 @@ private async Task<IList<SymbolReference>> GetMatchingTypesAsync(SearchScope sea
private async Task FindNugetTypeReferencesAsync(
PackageSource source,
IPackageSearchService searchService,
ISymbolSearchService searchService,
IPackageInstallerService installerService,
List<Reference> allReferences,
TSimpleNameSyntax nameNode,
......
......@@ -14,6 +14,7 @@
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.SymbolSearch;
using Roslyn.Utilities;
using static Roslyn.Utilities.PortableShim;
......@@ -25,18 +26,15 @@ internal abstract partial class AbstractAddImportCodeFixProvider<TSimpleNameSynt
private const int MaxResults = 3;
private readonly IPackageInstallerService _packageInstallerService;
private readonly IPackageSearchService _packageSearchService;
private readonly IReferenceAssemblySearchService _referenceAssemblySearchService;
private readonly ISymbolSearchService _symbolSearchService;
/// <summary>Values for these parameters can be provided (during testing) for mocking purposes.</summary>
protected AbstractAddImportCodeFixProvider(
IPackageInstallerService packageInstallerService = null,
IPackageSearchService packageSearchService = null,
IReferenceAssemblySearchService referenceAssemblySearchService = null)
ISymbolSearchService symbolSearchService = null)
{
_packageInstallerService = packageInstallerService;
_packageSearchService = packageSearchService;
_referenceAssemblySearchService = referenceAssemblySearchService;
_symbolSearchService = symbolSearchService;
}
protected abstract bool CanAddImport(SyntaxNode node, CancellationToken cancellationToken);
......@@ -81,7 +79,8 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
return;
}
var placeSystemNamespaceFirst = document.Project.Solution.Workspace.Options.GetOption(
var options = document.Project.Solution.Workspace.Options;
var placeSystemNamespaceFirst = options.GetOption(
OrganizerOptions.PlaceSystemNamespaceFirst, document.Project.Language);
using (Logger.LogBlock(FunctionId.Refactoring_AddImport, cancellationToken))
......
......@@ -313,8 +313,9 @@
<Compile Include="RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsService.cs" />
<Compile Include="ReplaceMethodWithProperty\ReplaceMethodWithPropertyCodeRefactoringProvider.cs" />
<Compile Include="ReplaceMethodWithProperty\IReplaceMethodWithPropertyService.cs" />
<Compile Include="Shared\Options\AddImportOptionsProvider.cs" />
<Compile Include="Shared\Extensions\ProjectExtensions.cs" />
<Compile Include="Shared\Options\OrganizerOptionsProvider.cs" />
<Compile Include="Shared\Options\AddImportOptions.cs" />
<Compile Include="Shared\Options\RuntimeOptions.cs" />
<Compile Include="Shared\Options\RuntimeOptionsProvider.cs" />
<Compile Include="Shared\Options\ServiceComponentOnOffOptionsProvider.cs" />
......
using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.Shared.Options
{
internal class AddImportOptions
{
public const string FeatureName = "AddImport";
public static PerLanguageOption<bool> SuggestForTypesInReferenceAssemblies =
new PerLanguageOption<bool>(FeatureName, nameof(SuggestForTypesInReferenceAssemblies), defaultValue: false);
public static PerLanguageOption<bool> SuggestForTypesInNuGetPackages =
new PerLanguageOption<bool>(FeatureName, nameof(SuggestForTypesInNuGetPackages), defaultValue: 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 Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Options.Providers;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Options.Providers;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.CodeAnalysis.Shared.Options
{
[ExportOptionProvider, Shared]
internal class OrganizerOptionsProvider : IOptionProvider
internal class AddImportOptionsProvider : IOptionProvider
{
private readonly IEnumerable<IOption> _options = new List<IOption>
{
OrganizerOptions.WarnOnBuildErrors
}.ToImmutableArray();
private readonly IEnumerable<IOption> _options = ImmutableArray.Create<IOption>(
AddImportOptions.SuggestForTypesInReferenceAssemblies,
AddImportOptions.SuggestForTypesInNuGetPackages);
public IEnumerable<IOption> GetOptions()
{
return _options;
}
public IEnumerable<IOption> GetOptions() => _options;
}
}
......@@ -13,13 +13,5 @@ public static PerLanguageOption<bool> PlaceSystemNamespaceFirst
{
get { return Editing.GenerationOptions.PlaceSystemNamespaceFirst; }
}
/// <summary>
/// This option is currently unused by Roslyn, but we might want to implement it in the
/// future. Keeping the option while it's unimplemented allows all upgrade paths to
/// maintain any customized value for this setting, even through versions that have not
/// implemented this feature yet.
/// </summary>
public static readonly PerLanguageOption<bool> WarnOnBuildErrors = new PerLanguageOption<bool>(FeatureName, "WarnOnBuildErrors", defaultValue: true);
}
}
......@@ -13,6 +13,6 @@ internal static class ServiceComponentOnOffOptions
public static readonly Option<bool> DiagnosticProvider = new Option<bool>(OptionName, "Diagnostic Provider", defaultValue: true);
public static readonly Option<bool> PackageSearch = new Option<bool>(OptionName, nameof(PackageSearch), defaultValue: false);
public static readonly Option<bool> SymbolSearch = new Option<bool>(OptionName, nameof(SymbolSearch), defaultValue: true);
}
}
......@@ -14,7 +14,7 @@ internal class ServiceComponentOnOffOptionsProvider : IOptionProvider
{
private readonly IEnumerable<IOption> _options = ImmutableArray.Create(
ServiceComponentOnOffOptions.DiagnosticProvider,
ServiceComponentOnOffOptions.PackageSearch);
ServiceComponentOnOffOptions.SymbolSearch);
public IEnumerable<IOption> GetOptions() => _options;
}
......
......@@ -11,6 +11,7 @@ Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.Packaging
Imports Microsoft.CodeAnalysis.Simplification
Imports Microsoft.CodeAnalysis.SymbolSearch
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.AddImport
......@@ -24,7 +25,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.AddImport
''' <summary>
''' For testing purposes so that tests can pass in mocks for these values.
''' </summary>
Friend Sub New(installerService As IPackageInstallerService, searchService As IPackageSearchService)
Friend Sub New(installerService As IPackageInstallerService,
searchService As ISymbolSearchService)
MyBase.New(installerService, searchService)
End Sub
......
@echo off
@echo off
:: Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
call "%VS140COMNTOOLS%VsDevCmd.bat"
......@@ -9,6 +9,6 @@ pushd %~dp0
csi fetch_build.csx Master %~dp0..\..\..\..\Binaries\Release
:: Start Test Automation from the binaries directory
csi %~dp0..\..\..\..\Binaries\Release\Perf\infra\automation.csx
csi %~dp0..\..\..\..\Binaries\Release\Perf\infra\automation.csx --verbose
popd
\ No newline at end of file
......@@ -6,6 +6,7 @@
#load "./util/runner_util.csx"
// Log()
// StdoutFrom()
// IsVerbose()
#load "./util/tools_util.csx"
using System.Collections.Generic;
......@@ -33,7 +34,7 @@ foreach (var script in GetAllCsxRecursive(testDirectory))
testInstances.AddRange(tests);
}
var traceManager = TraceManagerFactory.GetTraceManager();
var traceManager = TraceManagerFactory.GetTraceManager(IsVerbose());
traceManager.Initialize();
foreach (var test in testInstances)
......
......@@ -19,13 +19,13 @@ public ConsoleAndFileLogger(string file = "log.txt")
public void Flush()
{
File.WriteAllText(_file, _buffer.ToString());
File.AppendAllText(_file, _buffer.ToString());
}
public void Log(string v)
{
Console.WriteLine(v);
_buffer.AppendLine(v);
Console.WriteLine(DateTime.Now + " : " + v);
_buffer.AppendLine(DateTime.Now + " : " + v);
}
}
}
......@@ -4,13 +4,17 @@ namespace Roslyn.Test.Performance.Utilities
{
public class TraceManagerFactory
{
public static ITraceManager GetTraceManager()
public static ITraceManager GetTraceManager(bool isVerbose = false)
{
var cpcFullPath = Path.Combine(TestUtilities.GetCPCDirectoryPath(), "CPC.exe");
var scenarioPath = TestUtilities.GetCPCDirectoryPath();
if (File.Exists(cpcFullPath))
{
return new TraceManager(cpcFullPath, scenarioPath, verbose: true, logger: null);
return new TraceManager(
cpcFullPath,
scenarioPath,
verbose: isVerbose,
logger: isVerbose ? new ConsoleAndFileLogger() : null);
}
else
{
......
......@@ -546,15 +546,6 @@ internal class CSharpVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Organize Usings.
/// </summary>
internal static string Option_OrganizeUsings {
get {
return ResourceManager.GetString("Option_OrganizeUsings", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Outlining.
/// </summary>
......@@ -583,7 +574,7 @@ internal class CSharpVSResources {
}
/// <summary>
/// Looks up a localized string similar to Show preview for _rename tracking.
/// Looks up a localized string similar to Show preview for rename _tracking.
/// </summary>
internal static string Option_RenameTrackingPreview {
get {
......@@ -619,11 +610,29 @@ internal class CSharpVSResources {
}
/// <summary>
/// Looks up a localized string similar to Warn if _build errors exist when organizing usings.
/// Looks up a localized string similar to Suggest usings for types in _NuGet packages.
/// </summary>
internal static string Option_Suggest_usings_for_types_in_NuGet_packages {
get {
return ResourceManager.GetString("Option_Suggest_usings_for_types_in_NuGet_packages", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Suggest usings for types in _reference assemblies.
/// </summary>
internal static string Option_Suggest_usings_for_types_in_reference_assemblies {
get {
return ResourceManager.GetString("Option_Suggest_usings_for_types_in_reference_assemblies", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Using Directives.
/// </summary>
internal static string Option_WarnOnBuildErrors {
internal static string Option_Using_Directives {
get {
return ResourceManager.GetString("Option_WarnOnBuildErrors", resourceCulture);
return ResourceManager.GetString("Option_Using_Directives", resourceCulture);
}
}
......
......@@ -366,8 +366,8 @@
<data name="Option_OptimizeForSolutionSize_Small" xml:space="preserve">
<value>Small</value>
</data>
<data name="Option_OrganizeUsings" xml:space="preserve">
<value>Organize Usings</value>
<data name="Option_Using_Directives" xml:space="preserve">
<value>Using Directives</value>
</data>
<data name="Option_Outlining" xml:space="preserve">
<value>Outlining</value>
......@@ -378,9 +378,6 @@
<data name="Option_PlaceSystemNamespaceFirst" xml:space="preserve">
<value>_Place 'System' directives first when sorting usings</value>
</data>
<data name="Option_WarnOnBuildErrors" xml:space="preserve">
<value>Warn if _build errors exist when organizing usings</value>
</data>
<data name="Option_BringUpOnIdentifier" xml:space="preserve">
<value>_Show completion list after a character is typed</value>
</data>
......@@ -400,7 +397,7 @@
<value>Selection In Completion List</value>
</data>
<data name="Option_RenameTrackingPreview" xml:space="preserve">
<value>Show preview for _rename tracking</value>
<value>Show preview for rename _tracking</value>
</data>
<data name="NewLinesForBracesAccessors" xml:space="preserve">
<value>Place open brace on new line for property, indexer, and event accessors</value>
......@@ -408,6 +405,12 @@
<data name="NewLinesForBracesProperty" xml:space="preserve">
<value>Place open brace on new line for properties, indexers, and events</value>
</data>
<data name="Option_Suggest_usings_for_types_in_reference_assemblies" xml:space="preserve">
<value>Suggest usings for types in _reference assemblies</value>
</data>
<data name="Option_Suggest_usings_for_types_in_NuGet_packages" xml:space="preserve">
<value>Suggest usings for types in _NuGet packages</value>
</data>
<data name="SetTypeInferencePreferences" xml:space="preserve">
<value>Type Inference preferences:</value>
</data>
......
......@@ -11,6 +11,20 @@
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>
<GroupBox x:Uid="UsingDirectivesGroupBox"
Header="{x:Static local:AdvancedOptionPageStrings.Option_Using_Directives}">
<StackPanel>
<CheckBox x:Name="PlaceSystemNamespaceFirst"
x:Uid="SortUsings_PlaceSystemFirst"
Content="{x:Static local:AdvancedOptionPageStrings.Option_PlaceSystemNamespaceFirst}" />
<CheckBox x:Name="SuggestForTypesInReferenceAssemblies"
x:Uid="AddImport_SuggestForTypesInReferenceAssemblies"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Suggest_usings_for_types_in_reference_assemblies}" />
<CheckBox x:Name="SuggestForTypesInNuGetPackages"
x:Uid="AddImport_SuggestForTypesInNuGetPackages"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Suggest_usings_for_types_in_NuGet_packages}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="HighlightingGroupBox"
Header="{x:Static local:AdvancedOptionPageStrings.Option_Highlighting}">
<StackPanel>
......@@ -42,17 +56,6 @@
Content="{x:Static local:AdvancedOptionPageStrings.Option_RenameTrackingPreview}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="OrganizeUsingsGroupBox"
Header="{x:Static local:AdvancedOptionPageStrings.Option_OrganizeUsings}">
<StackPanel>
<CheckBox x:Name="WarnOnBuildErrors"
Visibility="Collapsed"
Content="{x:Static local:AdvancedOptionPageStrings.Option_WarnOnBuildErrors}" />
<CheckBox x:Name="PlaceSystemNamespaceFirst"
x:Uid="SortUsings_PlaceSystemFirst"
Content="{x:Static local:AdvancedOptionPageStrings.Option_PlaceSystemNamespaceFirst}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="ExtractMethodGroupBox"
Header="{x:Static local:AdvancedOptionPageStrings.Option_ExtractMethod}">
<StackPanel>
......
......@@ -16,6 +16,10 @@ public AdvancedOptionPageControl(IServiceProvider serviceProvider) : base(servic
{
InitializeComponent();
BindToOption(PlaceSystemNamespaceFirst, OrganizerOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
BindToOption(SuggestForTypesInReferenceAssemblies, AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp);
BindToOption(SuggestForTypesInNuGetPackages, AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp);
BindToOption(EnterOutliningMode, FeatureOnOffOptions.Outlining, LanguageNames.CSharp);
BindToOption(GenerateXmlDocCommentsForTripleSlash, FeatureOnOffOptions.AutoXmlDocCommentGeneration, LanguageNames.CSharp);
BindToOption(InsertAsteriskAtTheStartOfNewLinesWhenWritingBlockComments, FeatureOnOffOptions.AutoInsertBlockCommentStartString, LanguageNames.CSharp);
......@@ -23,7 +27,6 @@ public AdvancedOptionPageControl(IServiceProvider serviceProvider) : base(servic
BindToOption(EnableHighlightReferences, FeatureOnOffOptions.ReferenceHighlighting, LanguageNames.CSharp);
BindToOption(EnableHighlightKeywords, FeatureOnOffOptions.KeywordHighlighting, LanguageNames.CSharp);
BindToOption(RenameTrackingPreview, FeatureOnOffOptions.RenameTrackingPreview, LanguageNames.CSharp);
BindToOption(PlaceSystemNamespaceFirst, OrganizerOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
BindToOption(DontPutOutOrRefOnStruct, ExtractMethodOptions.DontPutOutOrRefOnStruct, LanguageNames.CSharp);
BindToOption(AllowMovingDeclaration, ExtractMethodOptions.AllowMovingDeclaration, LanguageNames.CSharp);
BindToFullSolutionAnalysisOption(ClosedFileDiagnostics, LanguageNames.CSharp);
......
......@@ -89,11 +89,6 @@ public static string Option_OptimizeForSolutionSize_Small
get { return CSharpVSResources.Option_OptimizeForSolutionSize_Small; }
}
public static string Option_OrganizeUsings
{
get { return CSharpVSResources.Option_OrganizeUsings; }
}
public static string Option_Outlining
{
get { return CSharpVSResources.Option_Outlining; }
......@@ -109,9 +104,13 @@ public static string Option_PlaceSystemNamespaceFirst
get { return CSharpVSResources.Option_PlaceSystemNamespaceFirst; }
}
public static string Option_WarnOnBuildErrors
{
get { return CSharpVSResources.Option_WarnOnBuildErrors; }
}
public static string Option_Using_Directives =>
CSharpVSResources.Option_Using_Directives;
public static string Option_Suggest_usings_for_types_in_reference_assemblies =>
CSharpVSResources.Option_Suggest_usings_for_types_in_reference_assemblies;
public static string Option_Suggest_usings_for_types_in_NuGet_packages =>
CSharpVSResources.Option_Suggest_usings_for_types_in_NuGet_packages;
}
}
......@@ -302,6 +302,18 @@ public int SortUsings_PlaceSystemFirst
set { SetBooleanOption(OrganizerOptions.PlaceSystemNamespaceFirst, value); }
}
public int AddImport_SuggestForTypesInReferenceAssemblies
{
get { return GetBooleanOption(AddImportOptions.SuggestForTypesInReferenceAssemblies); }
set { SetBooleanOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, value); }
}
public int AddImport_SuggestForTypesInNuGetPackages
{
get { return GetBooleanOption(AddImportOptions.SuggestForTypesInNuGetPackages); }
set { SetBooleanOption(AddImportOptions.SuggestForTypesInNuGetPackages, value); }
}
public int Space_AfterBasesColon
{
get { return GetBooleanOption(CSharpFormattingOptions.SpaceAfterColonInBaseTypeDeclaration); }
......@@ -547,12 +559,6 @@ public string Style_UseImplicitTypeForIntrinsicTypes
}
}
public int WarnOnBuildErrors
{
get { return GetBooleanOption(OrganizerOptions.WarnOnBuildErrors); }
set { SetBooleanOption(OrganizerOptions.WarnOnBuildErrors, value); }
}
public int Wrapping_IgnoreSpacesAroundBinaryOperators
{
get
......
......@@ -27,6 +27,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options
[ExportLanguageSpecificOptionSerializer(
LanguageNames.CSharp,
OrganizerOptions.FeatureName,
AddImportOptions.FeatureName,
CompletionOptions.FeatureName,
CSharpCompletionOptions.FeatureName,
CSharpCodeStyleOptions.FeatureName,
......@@ -79,6 +80,7 @@ private bool ShouldIncludeOnOffOption(FieldInfo fieldInfo)
Type[] types = new[]
{
typeof(OrganizerOptions),
typeof(AddImportOptions),
typeof(CSharpCompletionOptions),
typeof(SimplificationOptions),
typeof(CSharpCodeStyleOptions),
......@@ -117,7 +119,8 @@ protected override string GetStorageKeyForOption(IOption option)
protected override bool SupportsOption(IOption option, string languageName)
{
if (option == OrganizerOptions.PlaceSystemNamespaceFirst ||
option == OrganizerOptions.WarnOnBuildErrors ||
option == AddImportOptions.SuggestForTypesInReferenceAssemblies ||
option == AddImportOptions.SuggestForTypesInNuGetPackages ||
option == CSharpCompletionOptions.AddNewLineOnEnterAfterFullyTypedWord ||
option == CSharpCompletionOptions.IncludeSnippets ||
option.Feature == CSharpCodeStyleOptions.FeatureName ||
......
......@@ -16,11 +16,13 @@
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.SolutionCrawler;
using Microsoft.CodeAnalysis.SymbolSearch;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Feedback.Interop;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.Extensions;
using Microsoft.VisualStudio.LanguageServices.Packaging;
using Microsoft.VisualStudio.LanguageServices.SymbolSearch;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
......@@ -55,7 +57,7 @@ internal abstract class VisualStudioWorkspaceImpl : VisualStudioWorkspace
private readonly ForegroundThreadAffinitizedObject _foregroundObject = new ForegroundThreadAffinitizedObject();
private PackageInstallerService _packageInstallerService;
private PackageSearchService _packageSearchService;
private SymbolSearchService _symbolSearchService;
public VisualStudioWorkspaceImpl(
SVsServiceProvider serviceProvider,
......@@ -111,7 +113,7 @@ protected void InitializeStandardVisualStudioWorkspace(SVsServiceProvider servic
this.Services.GetService<IOptionService>();
// Ensure the nuget package services are initialized on the UI thread.
_packageSearchService = this.Services.GetService<IPackageSearchService>() as PackageSearchService;
_symbolSearchService = this.Services.GetService<ISymbolSearchService>() as SymbolSearchService;
_packageInstallerService = (PackageInstallerService)this.Services.GetService<IPackageInstallerService>();
_packageInstallerService.Connect(this);
}
......@@ -1010,7 +1012,7 @@ internal void StopSolutionCrawler()
protected override void Dispose(bool finalize)
{
_packageInstallerService?.Disconnect(this);
_packageSearchService?.Dispose();
_symbolSearchService?.Dispose();
// workspace is going away. unregister this workspace from work coordinator
StopSolutionCrawler();
......
......@@ -80,7 +80,7 @@ internal void Connect(VisualStudioWorkspaceImpl workspace)
this.AssertIsForeground();
var options = workspace.Options;
if (!options.GetOption(ServiceComponentOnOffOptions.PackageSearch))
if (!options.GetOption(ServiceComponentOnOffOptions.SymbolSearch))
{
return;
}
......
......@@ -156,23 +156,23 @@
<Compile Include="Implementation\Workspace\VisualStudioProjectCacheHostServiceFactory.cs" />
<Compile Include="IRoslynTelemetrySetup.cs" />
<Compile Include="Packaging\Interop\SVsRemoteControlService.cs" />
<Compile Include="Packaging\IPackageSearchDatabaseFactoryService.cs" />
<Compile Include="Packaging\IPackageSearchDelayService.cs" />
<Compile Include="Packaging\IPackageSearchIOService.cs" />
<Compile Include="Packaging\IPackageSearchLogService.cs" />
<Compile Include="Packaging\IPackageSearchPatchService.cs" />
<Compile Include="Packaging\IPackageSearchRemoteControlService.cs" />
<Compile Include="SymbolSearch\IDatabaseFactoryService.cs" />
<Compile Include="SymbolSearch\IDelayService.cs" />
<Compile Include="SymbolSearch\IIOService.cs" />
<Compile Include="SymbolSearch\ILogService.cs" />
<Compile Include="SymbolSearch\IPatchService.cs" />
<Compile Include="SymbolSearch\IRemoteControlService.cs" />
<Compile Include="Packaging\PackageInstallerServiceFactory.cs" />
<Compile Include="Packaging\PackageInstallerServiceFactory_UndoRedo.cs" />
<Compile Include="Packaging\PackageSearchService.Update.cs" />
<Compile Include="Packaging\PackageSearchService.cs" />
<Compile Include="Packaging\PackageSearchService.DatabaseFactoryService.cs" />
<Compile Include="Packaging\PackageSearchService.DelayService.cs" />
<Compile Include="Packaging\PackageSearchService.IOService.cs" />
<Compile Include="Packaging\PackageSearchService.LogService.cs" />
<Compile Include="Packaging\PackageSearchService.RemoteControlService.cs" />
<Compile Include="Packaging\PackageSearchServiceFactory.cs" />
<Compile Include="Packaging\Patching\Delta.cs" />
<Compile Include="SymbolSearch\SymbolSearchService.Update.cs" />
<Compile Include="SymbolSearch\SymbolSearchService.cs" />
<Compile Include="SymbolSearch\SymbolSearchService.DatabaseFactoryService.cs" />
<Compile Include="SymbolSearch\SymbolSearchService.DelayService.cs" />
<Compile Include="SymbolSearch\SymbolSearchService.IOService.cs" />
<Compile Include="SymbolSearch\SymbolSearchService.LogService.cs" />
<Compile Include="SymbolSearch\SymbolSearchService.RemoteControlService.cs" />
<Compile Include="SymbolSearch\SymbolSearchServiceFactory.cs" />
<Compile Include="SymbolSearch\Patching\Delta.cs" />
<Compile Include="RoslynPackage.cs" />
<Compile Include="ServicesVSResources.Designer.cs">
<AutoGen>True</AutoGen>
......@@ -742,7 +742,7 @@
<Compile Include="Implementation\ProjectSystem\MetadataReferences\VisualStudioMetadataReferenceManager.Factory.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Packaging\PackageSearchService.PatchService.cs" />
<Compile Include="SymbolSearch\SymbolSearchService.PatchService.cs" />
<None Include="project.json" />
<PublicAPI Include="PublicAPI.Shipped.txt" />
<PublicAPI Include="PublicAPI.Unshipped.txt" />
......
......@@ -2,9 +2,9 @@
using Microsoft.CodeAnalysis.Elfie.Model;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
internal interface IPackageSearchDatabaseFactoryService
internal interface IDatabaseFactoryService
{
AddReferenceDatabase CreateDatabaseFromBytes(byte[] bytes);
}
......
// 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.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
/// <summary>
/// Used so we can mock out how the search service delays work for testing purposes.
/// </summary>
internal interface IPackageSearchDelayService
internal interface IDelayService
{
/// <summary>
/// The time to wait after a successful update (default = 1 day).
......
// 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.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
/// <summary>
/// Used so we can mock out how the search service does IO for testing purposes.
/// </summary>
internal interface IPackageSearchIOService
internal interface IIOService
{
void Create(DirectoryInfo directory);
void Delete(FileInfo file);
......
// 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.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
/// <summary>
/// Used so we can mock out logging in unit tests.
/// </summary>
internal interface IPackageSearchLogService
internal interface ILogService
{
void LogException(Exception e, string text);
void LogInfo(string text);
......
// 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.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
/// <summary>
/// Used so we can mock out patching in unit tests.
/// </summary>
internal interface IPackageSearchPatchService
internal interface IPatchService
{
byte[] ApplyPatch(byte[] databaseBytes, byte[] patchBytes);
}
......
......@@ -5,20 +5,20 @@
using System.Threading.Tasks;
using Microsoft.Internal.VisualStudio.Shell.Interop;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
/// <summary>
/// Used so we can mock out the remote control service in unit tests.
/// </summary>
internal interface IPackageSearchRemoteControlService
internal interface IRemoteControlService
{
IPackageSearchRemoteControlClient CreateClient(string hostId, string serverPath, int pollingMinutes);
IRemoteControlClient CreateClient(string hostId, string serverPath, int pollingMinutes);
}
/// <summary>
/// Used so we can mock out the client in unit tests.
/// </summary>
internal interface IPackageSearchRemoteControlClient : IDisposable
internal interface IRemoteControlClient : IDisposable
{
Task<Stream> ReadFileAsync(__VsRemoteControlBehaviorOnStale behavior);
}
......
......@@ -8,7 +8,7 @@
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.LanguageServices.Packaging.Patching
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch.Patching
{
/// <summary>
/// Wrapper around the msdelta api so we can consume patches produced by the Elfie service.
......
......@@ -3,11 +3,11 @@
using System.IO;
using Microsoft.CodeAnalysis.Elfie.Model;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
internal partial class PackageSearchService
internal partial class SymbolSearchService
{
private class DatabaseFactoryService : IPackageSearchDatabaseFactoryService
private class DatabaseFactoryService : IDatabaseFactoryService
{
public AddReferenceDatabase CreateDatabaseFromBytes(byte[] bytes)
{
......
......@@ -2,11 +2,11 @@
using System;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
internal partial class PackageSearchService
internal partial class SymbolSearchService
{
private class DelayService : IPackageSearchDelayService
private class DelayService : IDelayService
{
public TimeSpan CachePollDelay { get; } = TimeSpan.FromMinutes(1);
public TimeSpan FileWriteDelay { get; } = TimeSpan.FromSeconds(10);
......
......@@ -3,11 +3,11 @@
using System.Collections.Generic;
using System.IO;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
internal partial class PackageSearchService
internal partial class SymbolSearchService
{
private class IOService : IPackageSearchIOService
private class IOService : IIOService
{
public void Create(DirectoryInfo directory) => directory.Create();
......
......@@ -4,11 +4,11 @@
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.VisualStudio.Shell.Interop;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
internal partial class PackageSearchService
internal partial class SymbolSearchService
{
private class LogService : ForegroundThreadAffinitizedObject, IPackageSearchLogService
private class LogService : ForegroundThreadAffinitizedObject, ILogService
{
private readonly IVsActivityLog _activityLog;
......
// 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.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
internal partial class PackageSearchService
internal partial class SymbolSearchService
{
private class PatchService : IPackageSearchPatchService
private class PatchService : IPatchService
{
public byte[] ApplyPatch(byte[] databaseBytes, byte[] patchBytes)
{
......
......@@ -6,11 +6,11 @@
using System.Threading.Tasks;
using Microsoft.Internal.VisualStudio.Shell.Interop;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
internal partial class PackageSearchService
internal partial class SymbolSearchService
{
private class RemoteControlService : IPackageSearchRemoteControlService
private class RemoteControlService : IRemoteControlService
{
private readonly object _remoteControlService;
......@@ -19,7 +19,7 @@ public RemoteControlService(object remoteControlService)
_remoteControlService = remoteControlService;
}
public IPackageSearchRemoteControlClient CreateClient(string hostId, string serverPath, int pollingMinutes)
public IRemoteControlClient CreateClient(string hostId, string serverPath, int pollingMinutes)
{
var serviceType = _remoteControlService.GetType();
var serviceAssembly = serviceType.Assembly;
......@@ -39,7 +39,7 @@ public IPackageSearchRemoteControlClient CreateClient(string hostId, string serv
}
}
private class RemoteControlClient : IPackageSearchRemoteControlClient
private class RemoteControlClient : IRemoteControlClient
{
// Have to keep the vsClient around as it will try to dispose the underlying
// client when it gets GC'ed
......
......@@ -17,8 +17,12 @@
using Microsoft.Internal.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
using static System.FormattableString;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Shared.Options;
using System.Linq;
using System.Collections.Immutable;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
/// <summary>
/// A service which enables searching for packages matching certain criteria.
......@@ -27,7 +31,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Packaging
/// This implementation also spawns a task which will attempt to keep that database up to
/// date by downloading patches on a daily basis.
/// </summary>
internal partial class PackageSearchService
internal partial class SymbolSearchService
{
// Internal for testing purposes.
internal const string ContentAttributeName = "content";
......@@ -49,6 +53,8 @@ internal partial class PackageSearchService
private readonly CancellationTokenSource _cancellationTokenSource;
private readonly CancellationToken _cancellationToken;
private readonly Workspace _workspace;
private readonly ConcurrentDictionary<string, object> _sourceToUpdateSentinel =
new ConcurrentDictionary<string, object>();
......@@ -58,12 +64,12 @@ internal partial class PackageSearchService
// Interfaces that abstract out the external functionality we need. Used so we can easily
// mock behavior during tests.
private readonly IPackageInstallerService _installerService;
private readonly IPackageSearchDelayService _delayService;
private readonly IPackageSearchIOService _ioService;
private readonly IPackageSearchLogService _logService;
private readonly IPackageSearchRemoteControlService _remoteControlService;
private readonly IPackageSearchPatchService _patchService;
private readonly IPackageSearchDatabaseFactoryService _databaseFactoryService;
private readonly IDelayService _delayService;
private readonly IIOService _ioService;
private readonly ILogService _logService;
private readonly IRemoteControlService _remoteControlService;
private readonly IPatchService _patchService;
private readonly IDatabaseFactoryService _databaseFactoryService;
private readonly Func<Exception, bool> _reportAndSwallowException;
public void Dispose()
......@@ -76,12 +82,27 @@ public void Dispose()
private void LogException(Exception e, string text) => _logService.LogException(e, text);
private void OnPackageSourcesChanged(object sender, EventArgs e)
private void OnOptionChanged(object sender, EventArgs e)
{
var options = _workspace.Options;
if (!options.GetOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp) &&
!options.GetOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.VisualBasic) &&
!options.GetOption(AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp) &&
!options.GetOption(AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.VisualBasic))
{
// If we don't have any add-import features that would use these indices, then
// don't bother creating them.
return;
}
// Kick off a database update. Wait a few seconds before starting so we don't
// interfere too much with solution loading.
var sources = _installerService.PackageSources;
foreach (var source in sources)
// Always pull down the nuget.org index. It contains the MS reference assembly index
// inside of it.
var allSources = sources.Concat(new PackageSource(NugetOrgSource, source: null));
foreach (var source in allSources)
{
Task.Delay(TimeSpan.FromSeconds(10)).ContinueWith(_ =>
UpdateSourceInBackgroundAsync(source.Name), TaskScheduler.Default);
......@@ -109,11 +130,11 @@ internal Task UpdateSourceInBackgroundAsync(string source)
private class Updater
{
private readonly PackageSearchService _service;
private readonly SymbolSearchService _service;
private readonly string _source;
private readonly FileInfo _databaseFileInfo;
public Updater(PackageSearchService service, string source)
public Updater(SymbolSearchService service, string source)
{
_service = service;
_source = source;
......@@ -541,7 +562,7 @@ private async Task<XElement> DownloadFileAsync(string serverPath)
}
/// <summary>Returns 'null' if download is not available and caller should keep polling.</summary>
private async Task<XElement> TryDownloadFileAsync(IPackageSearchRemoteControlClient client)
private async Task<XElement> TryDownloadFileAsync(IRemoteControlClient client)
{
_service.LogInfo("Read file from client");
......
......@@ -6,13 +6,15 @@
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Elfie.Model;
using Microsoft.CodeAnalysis.Elfie.Model.Structures;
using Microsoft.CodeAnalysis.Elfie.Model.Tree;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.SymbolSearch;
using Microsoft.Internal.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Settings;
using Microsoft.VisualStudio.Shell.Interop;
......@@ -20,7 +22,7 @@
using static System.FormattableString;
using VSShell = Microsoft.VisualStudio.Shell;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
/// <summary>
/// A service which enables searching for packages matching certain criteria.
......@@ -29,16 +31,19 @@ namespace Microsoft.VisualStudio.LanguageServices.Packaging
/// This implementation also spawns a task which will attempt to keep that database up to
/// date by downloading patches on a daily basis.
/// </summary>
internal partial class PackageSearchService :
internal partial class SymbolSearchService :
ForegroundThreadAffinitizedObject,
IPackageSearchService,
IReferenceAssemblySearchService,
ISymbolSearchService,
IDisposable
{
private ConcurrentDictionary<string, AddReferenceDatabase> _sourceToDatabase = new ConcurrentDictionary<string, AddReferenceDatabase>();
public PackageSearchService(VSShell.SVsServiceProvider serviceProvider, IPackageInstallerService installerService)
: this(installerService,
public SymbolSearchService(
VSShell.SVsServiceProvider serviceProvider,
Workspace workspace,
IPackageInstallerService installerService)
: this(workspace,
installerService,
CreateRemoteControlService(serviceProvider),
new LogService((IVsActivityLog)serviceProvider.GetService(typeof(SVsActivityLog))),
new DelayService(),
......@@ -50,11 +55,14 @@ public PackageSearchService(VSShell.SVsServiceProvider serviceProvider, IPackage
FatalError.ReportWithoutCrash,
new CancellationTokenSource())
{
installerService.PackageSourcesChanged += OnPackageSourcesChanged;
OnPackageSourcesChanged(this, EventArgs.Empty);
installerService.PackageSourcesChanged += OnOptionChanged;
var optionsService = workspace.Services.GetService<IOptionService>();
optionsService.OptionChanged += OnOptionChanged;
OnOptionChanged(this, EventArgs.Empty);
}
private static IPackageSearchRemoteControlService CreateRemoteControlService(VSShell.SVsServiceProvider serviceProvider)
private static IRemoteControlService CreateRemoteControlService(VSShell.SVsServiceProvider serviceProvider)
{
var vsService = serviceProvider.GetService(typeof(SVsRemoteControlService));
if (vsService == null)
......@@ -69,14 +77,15 @@ private static IPackageSearchRemoteControlService CreateRemoteControlService(VSS
/// <summary>
/// For testing purposes only.
/// </summary>
internal PackageSearchService(
internal SymbolSearchService(
Workspace workspace,
IPackageInstallerService installerService,
IPackageSearchRemoteControlService remoteControlService,
IPackageSearchLogService logService,
IPackageSearchDelayService delayService,
IPackageSearchIOService ioService,
IPackageSearchPatchService patchService,
IPackageSearchDatabaseFactoryService databaseFactoryService,
IRemoteControlService remoteControlService,
ILogService logService,
IDelayService delayService,
IIOService ioService,
IPatchService patchService,
IDatabaseFactoryService databaseFactoryService,
string localSettingsDirectory,
Func<Exception, bool> reportAndSwallowException,
CancellationTokenSource cancellationTokenSource)
......@@ -87,6 +96,7 @@ private static IPackageSearchRemoteControlService CreateRemoteControlService(VSS
return;
}
_workspace = workspace;
_installerService = installerService;
_delayService = delayService;
_ioService = ioService;
......
......@@ -8,18 +8,19 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Packaging;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.SymbolSearch;
using Roslyn.Utilities;
using VSShell = Microsoft.VisualStudio.Shell;
namespace Microsoft.VisualStudio.LanguageServices.Packaging
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
[ExportWorkspaceServiceFactory(typeof(IPackageSearchService), WorkspaceKind.Host), Shared]
internal class PackageSearchServiceFactory : IWorkspaceServiceFactory
[ExportWorkspaceServiceFactory(typeof(ISymbolSearchService), WorkspaceKind.Host), Shared]
internal class SymbolSearchServiceFactory : IWorkspaceServiceFactory
{
private readonly VSShell.SVsServiceProvider _serviceProvider;
[ImportingConstructor]
public PackageSearchServiceFactory(
public SymbolSearchServiceFactory(
VSShell.SVsServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
......@@ -28,25 +29,33 @@ internal class PackageSearchServiceFactory : IWorkspaceServiceFactory
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
var options = workspaceServices.Workspace.Options;
if (options.GetOption(ServiceComponentOnOffOptions.PackageSearch))
if (options.GetOption(ServiceComponentOnOffOptions.SymbolSearch))
{
// Only support package search in vs workspace.
if (workspaceServices.Workspace is VisualStudioWorkspace)
{
return new PackageSearchService(_serviceProvider, workspaceServices.GetService<IPackageInstallerService>());
return new SymbolSearchService(
_serviceProvider, workspaceServices.Workspace,
workspaceServices.GetService<IPackageInstallerService>());
}
}
return new NullPackageSearchService();
return new NullSymbolSearchService();
}
private class NullPackageSearchService : IPackageSearchService
private class NullSymbolSearchService : ISymbolSearchService
{
public IEnumerable<PackageWithTypeResult> FindPackagesWithType(
string source, string name, int arity, CancellationToken cancellationToken)
{
return SpecializedCollections.EmptyEnumerable<PackageWithTypeResult>();
}
public IEnumerable<ReferenceAssemblyWithTypeResult> FindReferenceAssembliesWithType(
string name, int arity, CancellationToken cancellationToken)
{
return SpecializedCollections.EmptyEnumerable<ReferenceAssemblyWithTypeResult>();
}
}
}
}
......@@ -307,8 +307,8 @@
<Compile Include="Help\HelpTests.vb" />
<Compile Include="LanguageBlockTests.vb" />
<Compile Include="MockComponentModel.vb" />
<Compile Include="SymbolSearch\SymbolSearchServiceTests.vb" />
<Compile Include="Options\Style\NamingPreferences\NamingRuleDialogViewModelTests.vb" />
<Compile Include="Packaging\PackageSearchServiceTests.vb" />
<Compile Include="Utilities\VsNavInfoHelpers.vb" />
<Compile Include="VsNavInfo\VsNavInfoTests.vb" />
<Compile Include="ObjectBrowser\AbstractObjectBrowserTests.vb" />
......
......@@ -226,6 +226,15 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Import Directives.
'''</summary>
Friend Shared ReadOnly Property Option_Import_Directives() As String
Get
Return ResourceManager.GetString("Option_Import_Directives", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to _Navigate to Object Browser for symbols defined in metadata.
'''</summary>
......@@ -290,7 +299,16 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic
End Property
'''<summary>
''' Looks up a localized string similar to Show preview for _rename tracking.
''' Looks up a localized string similar to _Place &apos;System&apos; directives first when sorting imports.
'''</summary>
Friend Shared ReadOnly Property Option_PlaceSystemNamespaceFirst() As String
Get
Return ResourceManager.GetString("Option_PlaceSystemNamespaceFirst", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Show preview for rename _tracking.
'''</summary>
Friend Shared ReadOnly Property Option_RenameTrackingPreview() As String
Get
......@@ -298,6 +316,24 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Suggest imports for types in _NuGet packages.
'''</summary>
Friend Shared ReadOnly Property Option_Suggest_imports_for_types_in_NuGet_packages() As String
Get
Return ResourceManager.GetString("Option_Suggest_imports_for_types_in_NuGet_packages", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Suggest imports for types in _reference assemblies.
'''</summary>
Friend Shared ReadOnly Property Option_Suggest_imports_for_types_in_reference_assemblies() As String
Get
Return ResourceManager.GetString("Option_Suggest_imports_for_types_in_reference_assemblies", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Prefer intrinsic predefined type keyword when declaring locals, parameters and members.
'''</summary>
......
......@@ -193,7 +193,7 @@
<value>Performance</value>
</data>
<data name="Option_RenameTrackingPreview" xml:space="preserve">
<value>Show preview for _rename tracking</value>
<value>Show preview for rename _tracking</value>
</data>
<data name="Option_NavigateToObjectBrowser" xml:space="preserve">
<value>_Navigate to Object Browser for symbols defined in metadata</value>
......@@ -201,6 +201,18 @@
<data name="Option_GoToDefinition" xml:space="preserve">
<value>Go to Definition</value>
</data>
<data name="Option_Import_Directives" xml:space="preserve">
<value>Import Directives</value>
</data>
<data name="Option_Suggest_imports_for_types_in_NuGet_packages" xml:space="preserve">
<value>Suggest imports for types in _NuGet packages</value>
</data>
<data name="Option_Suggest_imports_for_types_in_reference_assemblies" xml:space="preserve">
<value>Suggest imports for types in _reference assemblies</value>
</data>
<data name="Option_PlaceSystemNamespaceFirst" xml:space="preserve">
<value>_Place 'System' directives first when sorting imports</value>
</data>
<data name="QualifyEventAccessWithMe" xml:space="preserve">
<value>Qualify event access with 'Me'</value>
</data>
......
......@@ -11,6 +11,21 @@
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>
<GroupBox x:Uid="ImportDirectivesGroupBox"
Header="{x:Static local:AdvancedOptionPageStrings.Option_Import_Directives}">
<StackPanel>
<CheckBox x:Name="PlaceSystemNamespaceFirst"
x:Uid="SortImports_PlaceSystemFirst"
Content="{x:Static local:AdvancedOptionPageStrings.Option_PlaceSystemNamespaceFirst}" />
<CheckBox x:Name="SuggestForTypesInReferenceAssemblies"
x:Uid="AddImport_SuggestForTypesInReferenceAssemblies"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Suggest_imports_for_types_in_reference_assemblies}" />
<CheckBox x:Name="SuggestForTypesInNuGetPackages"
x:Uid="AddImport_SuggestForTypesInNuGetPackages"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Suggest_imports_for_types_in_NuGet_packages}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="HighlightingGroupBox"
Header="{x:Static local:AdvancedOptionPageStrings.Option_Highlighting}">
<StackPanel>
......
......@@ -13,6 +13,10 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
InitializeComponent()
BindToOption(PlaceSystemNamespaceFirst, OrganizerOptions.PlaceSystemNamespaceFirst, LanguageNames.VisualBasic)
BindToOption(SuggestForTypesInReferenceAssemblies, AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.VisualBasic)
BindToOption(SuggestForTypesInNuGetPackages, AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.VisualBasic)
BindToOption(EnableEndConstruct, FeatureOnOffOptions.EndConstruct, LanguageNames.VisualBasic)
BindToOption(EnableOutlining, FeatureOnOffOptions.Outlining, LanguageNames.VisualBasic)
BindToOption(EnableLineCommit, FeatureOnOffOptions.PrettyListing, LanguageNames.VisualBasic)
......
......@@ -141,5 +141,28 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
End Get
End Property
Public ReadOnly Property Option_Import_Directives As String
Get
Return BasicVSResources.Option_Import_Directives
End Get
End Property
Public ReadOnly Property Option_PlaceSystemNamespaceFirst As String
Get
Return BasicVSResources.Option_PlaceSystemNamespaceFirst
End Get
End Property
Public ReadOnly Property Option_Suggest_imports_for_types_in_reference_assemblies As String
Get
Return BasicVSResources.Option_Suggest_imports_for_types_in_reference_assemblies
End Get
End Property
Public ReadOnly Property Option_Suggest_imports_for_types_in_NuGet_packages As String
Get
Return BasicVSResources.Option_Suggest_imports_for_types_in_NuGet_packages
End Get
End Property
End Module
End Namespace
End Namespace
\ No newline at end of file
......@@ -193,6 +193,33 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
End Set
End Property
Public Property Option_PlaceSystemNamespaceFirst As Boolean
Get
Return GetBooleanOption(OrganizerOptions.PlaceSystemNamespaceFirst)
End Get
Set(value As Boolean)
SetBooleanOption(OrganizerOptions.PlaceSystemNamespaceFirst, value)
End Set
End Property
Public Property Option_Suggest_imports_for_types_in_reference_assemblies As Boolean
Get
Return GetBooleanOption(AddImportOptions.SuggestForTypesInReferenceAssemblies)
End Get
Set(value As Boolean)
SetBooleanOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, value)
End Set
End Property
Public Property Option_Suggest_imports_for_types_in_NuGet_packages As Boolean
Get
Return GetBooleanOption(AddImportOptions.SuggestForTypesInNuGetPackages)
End Get
Set(value As Boolean)
SetBooleanOption(AddImportOptions.SuggestForTypesInNuGetPackages, value)
End Set
End Property
Private Function GetBooleanOption(key As [Option](Of Boolean)) As Boolean
Return _optionService.GetOption(key)
End Function
......
......@@ -8,9 +8,16 @@ Imports Microsoft.VisualStudio.Shell
Imports Microsoft.VisualStudio.LanguageServices.Implementation.Options
Imports Microsoft.CodeAnalysis.Options
Imports System.Composition
Imports Microsoft.CodeAnalysis.Shared.Options
Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
<ExportLanguageSpecificOptionSerializer(LanguageNames.VisualBasic, FormattingOptions.TabFeatureName, BraceCompletionOptions.FeatureName, CompletionOptions.FeatureName, SignatureHelpOptions.FeatureName, NavigationBarOptions.FeatureName), [Shared]>
<ExportLanguageSpecificOptionSerializer(
LanguageNames.VisualBasic,
FormattingOptions.TabFeatureName,
BraceCompletionOptions.FeatureName,
CompletionOptions.FeatureName,
SignatureHelpOptions.FeatureName,
NavigationBarOptions.FeatureName), [Shared]>
Friend NotInheritable Class VisualBasicLanguageSettingsSerializer
Inherits AbstractLanguageSettingsSerializer
......
......@@ -17,6 +17,7 @@ Imports Microsoft.VisualStudio.Shell
Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
<ExportLanguageSpecificOptionSerializer(
LanguageNames.VisualBasic,
AddImportOptions.FeatureName,
SimplificationOptions.PerLanguageFeatureName,
ExtractMethodOptions.FeatureName,
FeatureOnOffOptions.OptionName,
......@@ -46,6 +47,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
New KeyValuePair(Of String, IOption)(SettingStorageRoot + "AutoRequiredMemberInsert", FeatureOnOffOptions.AutomaticInsertionOfAbstractOrInterfaceMembers)})
Dim Types As Type() = {
GetType(AddImportOptions),
GetType(FormattingOptions),
GetType(ExtractMethodOptions),
GetType(SimplificationOptions),
......@@ -85,6 +87,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
End If
Return [option].Feature = FormattingOptions.InternalTabFeatureName Or
[option].Feature = AddImportOptions.FeatureName Or
[option].Feature = ExtractMethodOptions.FeatureName Or
[option].Feature = SimplificationOptions.PerLanguageFeatureName Or
[option].Feature = ServiceFeatureOnOffOptions.OptionName Or
......
using System.Collections.Generic;
using System.Threading;
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.Packaging
{
internal interface IReferenceAssemblySearchService : IWorkspaceService
{
/// <summary>
/// Searches for reference assemblies that contain a type with the provided name and arity.
/// Note: Implementations are free to return the results they feel best for the
/// given data. Specifically, they can do exact or fuzzy matching on the name.
/// They can use or ignore the arity depending on their capabilities.
///
/// Implementations should return results in order from best to worst (from their
/// perspective).
/// </summary>
IEnumerable<ReferenceAssemblyWithTypeResult> FindReferenceAssembliesWithType(
string name, int arity, CancellationToken cancellationToken);
}
internal class ReferenceAssemblyWithTypeResult
{
public readonly IReadOnlyList<string> ContainingNamespaceNames;
public readonly string AssemblyName;
public readonly string TypeName;
public ReferenceAssemblyWithTypeResult(
string assemblyName,
string typeName,
IReadOnlyList<string> containingNamespaceNames)
{
AssemblyName = assemblyName;
TypeName = typeName;
ContainingNamespaceNames = containingNamespaceNames;
}
}
}
......@@ -4,9 +4,9 @@
using System.Threading;
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.Packaging
namespace Microsoft.CodeAnalysis.SymbolSearch
{
internal interface IPackageSearchService : IWorkspaceService
internal interface ISymbolSearchService : IWorkspaceService
{
/// <summary>
/// Searches for packages that contain a type with the provided name and arity.
......@@ -19,6 +19,18 @@ internal interface IPackageSearchService : IWorkspaceService
/// </summary>
IEnumerable<PackageWithTypeResult> FindPackagesWithType(
string source, string name, int arity, CancellationToken cancellationToken);
/// <summary>
/// Searches for reference assemblies that contain a type with the provided name and arity.
/// Note: Implementations are free to return the results they feel best for the
/// given data. Specifically, they can do exact or fuzzy matching on the name.
/// They can use or ignore the arity depending on their capabilities.
///
/// Implementations should return results in order from best to worst (from their
/// perspective).
/// </summary>
IEnumerable<ReferenceAssemblyWithTypeResult> FindReferenceAssembliesWithType(
string name, int arity, CancellationToken cancellationToken);
}
internal class PackageWithTypeResult
......@@ -40,4 +52,21 @@ internal class PackageWithTypeResult
ContainingNamespaceNames = containingNamespaceNames;
}
}
internal class ReferenceAssemblyWithTypeResult
{
public readonly IReadOnlyList<string> ContainingNamespaceNames;
public readonly string AssemblyName;
public readonly string TypeName;
public ReferenceAssemblyWithTypeResult(
string assemblyName,
string typeName,
IReadOnlyList<string> containingNamespaceNames)
{
AssemblyName = assemblyName;
TypeName = typeName;
ContainingNamespaceNames = containingNamespaceNames;
}
}
}
......@@ -4,8 +4,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading;
using Microsoft.CodeAnalysis;
using static System.Math;
namespace Roslyn.Utilities
{
......@@ -110,7 +110,11 @@ public int GetEditDistance(string target, int threshold = int.MaxValue)
}
private const int MaxMatrixPoolDimension = 64;
private static readonly SimplePool<int[,]> s_matrixPool = new SimplePool<int[,]>(() => InitializeMatrix(new int[64, 64]));
private static readonly ThreadLocal<int[,]> t_matrixPool =
new ThreadLocal<int[,]>(() => InitializeMatrix(new int[MaxMatrixPoolDimension, MaxMatrixPoolDimension]));
private static ThreadLocal<Dictionary<char, int>> t_dictionaryPool =
new ThreadLocal<Dictionary<char, int>>(() => new Dictionary<char, int>());
private static int[,] GetMatrix(int width, int height)
{
......@@ -119,15 +123,7 @@ public int GetEditDistance(string target, int threshold = int.MaxValue)
return InitializeMatrix(new int[width, height]);
}
return s_matrixPool.Allocate();
}
private static void ReleaseMatrix(int[,] matrix)
{
if (matrix.GetLength(0) <= MaxMatrixPoolDimension && matrix.GetLength(1) <= MaxMatrixPoolDimension)
{
s_matrixPool.Free(matrix);
}
return t_matrixPool.Value;
}
private static int[,] InitializeMatrix(int[,] matrix)
......@@ -182,8 +178,6 @@ public static int GetEditDistance(ArraySlice<char> source, ArraySlice<char> targ
: GetEditDistanceWorker(target, source, threshold);
}
private static SimplePool<Dictionary<char, int>> s_dictionaryPool = new SimplePool<Dictionary<char, int>>(() => new Dictionary<char, int>());
private static int GetEditDistanceWorker(ArraySlice<char> source, ArraySlice<char> target, int threshold)
{
// Note: sourceLength will always be smaller or equal to targetLength.
......@@ -497,74 +491,68 @@ private static int GetEditDistanceWorker(ArraySlice<char> source, ArraySlice<cha
Debug.Assert(offset >= 0);
var matrix = GetMatrix(sourceLength + 2, targetLength + 2);
var characterToLastSeenIndex_inSource = s_dictionaryPool.AllocateAndClear();
try
var characterToLastSeenIndex_inSource = t_dictionaryPool.Value;
characterToLastSeenIndex_inSource.Clear();
for (int i = 1; i <= sourceLength; i++)
{
for (int i = 1; i <= sourceLength; i++)
var lastMatchIndex_inTarget = 0;
var sourceChar = source[i - 1];
// Determinethe portion of the column we actually want to examine.
var jStart = Math.Max(1, i - offset);
var jEnd = Math.Min(targetLength, i + minimumEditCount + offset);
// If we're examining only a subportion of the column, then we need to make sure
// that the values outside that range are set to Infinity. That way we don't
// consider them when we look through edit paths from above (for this column) or
// from the left (for the next column).
if (jStart > 1)
{
var lastMatchIndex_inTarget = 0;
var sourceChar = source[i - 1];
// Determinethe portion of the column we actually want to examine.
var jStart = Math.Max(1, i - offset);
var jEnd = Math.Min(targetLength, i + minimumEditCount + offset);
// If we're examining only a subportion of the column, then we need to make sure
// that the values outside that range are set to Infinity. That way we don't
// consider them when we look through edit paths from above (for this column) or
// from the left (for the next column).
if (jStart > 1)
{
matrix[i + 1, jStart] = Infinity;
}
matrix[i + 1, jStart] = Infinity;
}
if (jEnd < targetLength)
{
matrix[i + 1, jEnd + 2] = Infinity;
}
if (jEnd < targetLength)
{
matrix[i + 1, jEnd + 2] = Infinity;
}
for (int j = jStart; j <= jEnd; j++)
{
var targetChar = target[j - 1];
var i1 = GetValue(characterToLastSeenIndex_inSource, targetChar);
var j1 = lastMatchIndex_inTarget;
var matched = sourceChar == targetChar;
if (matched)
{
lastMatchIndex_inTarget = j;
}
matrix[i + 1, j + 1] = Min(
matrix[i, j] + (matched ? 0 : 1),
matrix[i + 1, j] + 1,
matrix[i, j + 1] + 1,
matrix[i1, j1] + (i - i1 - 1) + 1 + (j - j1 - 1));
}
for (int j = jStart; j <= jEnd; j++)
{
var targetChar = target[j - 1];
characterToLastSeenIndex_inSource[sourceChar] = i;
var i1 = GetValue(characterToLastSeenIndex_inSource, targetChar);
var j1 = lastMatchIndex_inTarget;
// Recall that minimumEditCount is simply the difference in length of our two
// strings. So matrix[i+1,i+1] is the cost for the upper-left diagonal of the
// matrix. matrix[i+1,i+1+minimumEditCount] is the cost for the lower right diagonal.
// Here we are simply getting the lowest cost edit of hese two substrings so far.
// If this lowest cost edit is greater than our threshold, then there is no need
// to proceed.
if (matrix[i + 1, i + minimumEditCount + 1] > threshold)
var matched = sourceChar == targetChar;
if (matched)
{
return BeyondThreshold;
lastMatchIndex_inTarget = j;
}
matrix[i + 1, j + 1] = Min(
matrix[i, j] + (matched ? 0 : 1),
matrix[i + 1, j] + 1,
matrix[i, j + 1] + 1,
matrix[i1, j1] + (i - i1 - 1) + 1 + (j - j1 - 1));
}
return matrix[sourceLength + 1, targetLength + 1];
}
finally
{
ReleaseMatrix(matrix);
s_dictionaryPool.Free(characterToLastSeenIndex_inSource);
characterToLastSeenIndex_inSource[sourceChar] = i;
// Recall that minimumEditCount is simply the difference in length of our two
// strings. So matrix[i+1,i+1] is the cost for the upper-left diagonal of the
// matrix. matrix[i+1,i+1+minimumEditCount] is the cost for the lower right diagonal.
// Here we are simply getting the lowest cost edit of hese two substrings so far.
// If this lowest cost edit is greater than our threshold, then there is no need
// to proceed.
if (matrix[i + 1, i + minimumEditCount + 1] > threshold)
{
return BeyondThreshold;
}
}
return matrix[sourceLength + 1, targetLength + 1];
}
private static string ToString(int[,] matrix, int width, int height)
......@@ -657,18 +645,6 @@ public void Free(T value)
}
}
internal static class SimplePoolExtensions
{
public static Dictionary<TKey, TValue> AllocateAndClear<TKey, TValue>(
this SimplePool<Dictionary<TKey, TValue>> pool)
{
var map = pool.Allocate();
map.Clear();
return map;
}
}
internal static class ArrayPool<T>
{
private const int MaxPooledArraySize = 256;
......
......@@ -396,12 +396,11 @@
<Compile Include="FindSymbols\FindReferences\Finders\ILanguageServiceReferenceFinder.cs" />
<Compile Include="LinkedFileDiffMerging\LinkedFileDiffMergingLogger.cs" />
<Compile Include="Packaging\IPackageInstallerService.cs" />
<Compile Include="Packaging\IPackageSearchService.cs" />
<Compile Include="SymbolSearch\ISymbolSearchService.cs" />
<Compile Include="FindSymbols\SymbolTree\ISymbolTreeInfoCacheService.cs" />
<Compile Include="FindSymbols\FindReferences\MetadataUnifyingEquivalenceComparer.cs" />
<Compile Include="SymbolId\SymbolId.cs" />
<Compile Include="Shared\Utilities\IProgressTracker.cs" />
<Compile Include="Packaging\IReferenceAssemblySearchService.cs" />
<Compile Include="SymbolId\SymbolKey.TupleTypeSymbolKey.cs" />
<Compile Include="Utilities\ArraySlice.cs" />
<Compile Include="Utilities\BKTree.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册