提交 66ed015b 编写于 作者: M Manish Vasani

Add ability to run IDE analyzer/fixer tests in CodeStyle layer

上级 7e80d295
......@@ -458,6 +458,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compiler", "Compiler", "{7A
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspace", "Workspace", "{9C1BE25C-5926-4E56-84AE-D2242CB0627E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities", "src\EditorFeatures\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj", "{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5
......@@ -1201,6 +1203,10 @@ Global
{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.Build.0 = Release|Any CPU
{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -1414,6 +1420,7 @@ Global
{DF17AF27-AA02-482B-8946-5CA8A50D5A2B} = {55A62CFA-1155-46F1-ADF3-BEEE51B58AB5}
{7A69EA65-4411-4CD0-B439-035E720C1BD3} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B}
{9C1BE25C-5926-4E56-84AE-D2242CB0627E} = {DF17AF27-AA02-482B-8946-5CA8A50D5A2B}
{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E} = {EE97CB90-33BB-4F3A-9B3D-69375DEC6AC6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29}
......
......@@ -22,7 +22,6 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests" />
</ItemGroup>
......
Microsoft.CodeAnalysis.Internal.Options.CodeStyleOptions
Microsoft.CodeAnalysis.Internal.Options.CodeStyleOptions.CodeStyleOptions() -> void
Microsoft.CodeAnalysis.Internal.Options.IEditorConfigStorageLocation
Microsoft.CodeAnalysis.Internal.Options.IEditorConfigStorageLocation.TryGetOption(System.Collections.Generic.IReadOnlyDictionary<string, string> rawOptions, System.Type type, out object value) -> bool
Microsoft.CodeAnalysis.Internal.Options.IEditorConfigStorageLocation2
Microsoft.CodeAnalysis.Internal.Options.IEditorConfigStorageLocation2.GetEditorConfigString(object value, Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions optionSet) -> string
Microsoft.CodeAnalysis.Internal.Options.IEditorConfigStorageLocation2.KeyName.get -> string
static readonly Microsoft.CodeAnalysis.Internal.Options.CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration -> Microsoft.CodeAnalysis.Internal.Options.PerLanguageOption<Microsoft.CodeAnalysis.Internal.Options.CodeStyleOption<bool>>
static readonly Microsoft.CodeAnalysis.Internal.Options.CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess -> Microsoft.CodeAnalysis.Internal.Options.PerLanguageOption<Microsoft.CodeAnalysis.Internal.Options.CodeStyleOption<bool>>
static readonly Microsoft.CodeAnalysis.Internal.Options.CodeStyleOptions.QualifyEventAccess -> Microsoft.CodeAnalysis.Internal.Options.PerLanguageOption<Microsoft.CodeAnalysis.Internal.Options.CodeStyleOption<bool>>
......
......@@ -16,7 +16,6 @@
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests" />
</ItemGroup>
......
......@@ -9,13 +9,16 @@
<IsShipping>false</IsShipping>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\EditorFeatures\TestUtilities\CodeActions\CodeFixVerifierHelper.cs" Link="CodeFixVerifierHelper.cs" />
<Compile Include="..\..\..\EditorFeatures\TestUtilities\CodeActions\CSharpCodeFixVerifier`2+Test.cs" Link="CSharpCodeFixVerifier`2+Test.cs" />
<Compile Include="..\..\..\EditorFeatures\TestUtilities\CodeActions\CSharpCodeFixVerifier`2.cs" Link="CSharpCodeFixVerifier`2.cs" />
<Compile Include="..\..\..\EditorFeatures\TestUtilities\CodeActions\VisualBasicCodeFixVerifier`2+Test.cs" Link="VisualBasicCodeFixVerifier`2+Test.cs" />
<Compile Include="..\..\..\EditorFeatures\TestUtilities\CodeActions\VisualBasicCodeFixVerifier`2.cs" Link="VisualBasicCodeFixVerifier`2.cs" />
<Compile Include="..\..\..\Test\Utilities\Portable\Assert\WorkItemAttribute.cs" Link="WorkItemAttribute.cs" />
<Compile Include="..\..\..\Test\Utilities\Portable\Traits\Traits.cs" Link="Traits.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CodeFixVerifierHelper.cs" Link="CodeFixVerifierHelper.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CSharpCodeFixVerifier`2+Test.cs" Link="CSharpCodeFixVerifier`2+Test.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\CSharpCodeFixVerifier`2.cs" Link="CSharpCodeFixVerifier`2.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\VisualBasicCodeFixVerifier`2+Test.cs" Link="VisualBasicCodeFixVerifier`2+Test.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\VisualBasicCodeFixVerifier`2.cs" Link="VisualBasicCodeFixVerifier`2.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\OptionsCollection.cs" Link="OptionsCollection.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\CodeActions\AbstractCodeActionOrUserDiagnosticTest.cs" Link="TestFramework\AbstractCodeActionOrUserDiagnosticTest.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\Diagnostics\AbstractDiagnosticProviderBasedUserDiagnosticTest.cs" Link="TestFramework\AbstractDiagnosticProviderBasedUserDiagnosticTest.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\Diagnostics\AbstractUserDiagnosticTest.cs" Link="TestFramework\AbstractUserDiagnosticTest.cs" />
<Compile Include="..\..\..\EditorFeatures\DiagnosticsTestUtilities\Diagnostics\AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs" Link="TestFramework\AbstractUserDiagnosticTest.FixAllDiagnosticProvider.cs" />
</ItemGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\Analyzers\Microsoft.CodeAnalysis.CodeStyle.csproj" />
......@@ -31,6 +34,11 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="$(MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="$(MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion)" />
</ItemGroup>
<ItemGroup Label="Project References">
<!-- TODO: Remove the below project references to workspaces and test utility projects once all analyzer/code fix tests are switched to Microsoft.CodeAnalysis.Testing -->
<ProjectReference Include="..\..\..\EditorFeatures\TestUtilities\Roslyn.Services.Test.Utilities.csproj" />
<ProjectReference Include="..\..\..\Test\Utilities\Portable\Roslyn.Test.Utilities.csproj" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests" />
......
......@@ -32,6 +32,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
</ItemGroup>
......
......@@ -26,6 +26,7 @@
<ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" />
<ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" />
<ProjectReference Include="..\..\Compilers\Test\Resources\Core\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj" />
<ProjectReference Include="..\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj" />
<ProjectReference Include="..\TestUtilities\Roslyn.Services.Test.Utilities.csproj" />
<ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" />
<ProjectReference Include="..\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" />
......
......@@ -24,6 +24,7 @@
<ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" />
<ProjectReference Include="..\..\EditorFeatures\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" />
<ProjectReference Include="..\..\Compilers\Test\Resources\Core\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj" />
<ProjectReference Include="..\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj" />
<ProjectReference Include="..\TestUtilities\Roslyn.Services.Test.Utilities.csproj" />
<ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" />
<ProjectReference Include="..\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" />
......
......@@ -50,6 +50,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" />
......
......@@ -78,6 +78,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
<InternalsVisibleTo Include="Roslyn.Services.UnitTests.Utilities" />
......
......@@ -161,7 +161,7 @@ private string GetSignatureDescriptionString(int[] signature, int? totalParamete
/// described above.</param>
public async Task TestAllSignatureChangesAsync(string languageName, string markup, int[] signaturePartCounts, ParseOptions parseOptions = null)
{
Assert.Equal(signaturePartCounts.Length, 4);
Assert.Equal(4, signaturePartCounts.Length);
Assert.True(signaturePartCounts[0] == 0 || signaturePartCounts[0] == 1);
Assert.True(signaturePartCounts[3] == 0 || signaturePartCounts[3] == 1);
......
......@@ -5,29 +5,35 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Editor.Implementation.Preview;
using Microsoft.CodeAnalysis.Editor.UnitTests.Extensions;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UnitTests;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
#if CODE_STYLE
using Microsoft.CodeAnalysis.Internal.Options;
#else
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Options;
#endif
namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
[UseExportProvider]
public abstract class AbstractCodeActionOrUserDiagnosticTest
public abstract partial class AbstractCodeActionOrUserDiagnosticTest
{
public struct TestParameters
{
......@@ -82,6 +88,8 @@ public TestParameters WithIncludeDiagnosticsOutsideSelection(bool includeDiagnos
=> new TestParameters(parseOptions, compilationOptions, options, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title);
}
private const string AutoGeneratedAnalyzerConfigHeader = @"# auto-generated .editorconfig for code style options";
protected abstract string GetLanguage();
protected abstract ParseOptions GetScriptOptions();
......@@ -92,11 +100,134 @@ public TestParameters WithIncludeDiagnosticsOutsideSelection(bool includeDiagnos
? TestWorkspace.Create(initialMarkup, openDocuments: false)
: CreateWorkspaceFromFile(initialMarkup, parameters);
// For CodeStyle layer testing, we create an .editorconfig at project root
// to apply the options as workspace options are not available in CodeStyle layer.
// Otherwise, we apply the options directly to the workspace.
#if CODE_STYLE
// We need to ensure that our projects/documents are rooted for
// execution from CodeStyle layer as we will be adding a rooted .editorconfig to each project
// to apply the options.
if (parameters.options != null)
{
MakeProjectsAndDocumentsRooted(workspace);
AddAnalyzerConfigDocumentWithOptions(workspace, parameters.options);
}
#else
workspace.ApplyOptions(parameters.options);
#endif
return workspace;
}
private static void MakeProjectsAndDocumentsRooted(TestWorkspace workspace)
{
const string defaultRootFilePath = @"z:\";
var newSolution = workspace.CurrentSolution;
foreach (var projectId in workspace.CurrentSolution.ProjectIds)
{
var project = newSolution.GetProject(projectId);
string projectRootFilePath;
if (!PathUtilities.IsAbsolute(project.FilePath))
{
projectRootFilePath = defaultRootFilePath;
newSolution = newSolution.WithProjectFilePath(projectId, Path.Combine(projectRootFilePath, project.FilePath));
}
else
{
projectRootFilePath = PathUtilities.GetPathRoot(project.FilePath);
}
foreach (var documentId in project.DocumentIds)
{
var document = newSolution.GetDocument(documentId);
if (!PathUtilities.IsAbsolute(document.FilePath))
{
newSolution = newSolution.WithDocumentFilePath(documentId, Path.Combine(projectRootFilePath, document.FilePath));
}
else
{
Assert.Equal(projectRootFilePath, PathUtilities.GetPathRoot(document.FilePath));
}
}
}
var applied = workspace.TryApplyChanges(newSolution);
Assert.True(applied);
return;
}
private static void AddAnalyzerConfigDocumentWithOptions(TestWorkspace workspace, IDictionary<OptionKey, object> options)
{
Debug.Assert(options != null);
var analyzerConfigText = GenerateAnalyzerConfigText(options);
var newSolution = workspace.CurrentSolution;
foreach (var project in workspace.Projects)
{
Assert.True(PathUtilities.IsAbsolute(project.FilePath));
var projectRootFilePath = PathUtilities.GetPathRoot(project.FilePath);
var documentId = DocumentId.CreateNewId(project.Id);
newSolution = newSolution.AddAnalyzerConfigDocument(
documentId,
".editorconfig",
SourceText.From(analyzerConfigText),
filePath: Path.Combine(projectRootFilePath, ".editorconfig"));
}
var applied = workspace.TryApplyChanges(newSolution);
Assert.True(applied);
return;
static string GenerateAnalyzerConfigText(IDictionary<OptionKey, object> options)
{
var textBuilder = new StringBuilder();
// Add an auto-generated header at the top so we can skip this file in expected baseline validation.
textBuilder.AppendLine(AutoGeneratedAnalyzerConfigHeader);
textBuilder.AppendLine();
foreach (var (optionKey, value) in options)
{
foreach (var location in optionKey.Option.StorageLocations)
{
if (location is IEditorConfigStorageLocation2 editorConfigStorageLocation)
{
var editorConfigString = editorConfigStorageLocation.GetEditorConfigString(value, default);
if (editorConfigString != null)
{
textBuilder.AppendLine(GetSectionHeader(optionKey));
textBuilder.AppendLine(editorConfigString);
textBuilder.AppendLine();
break;
}
Assert.False(true, "Unexpected non-editorconfig option");
}
}
}
return textBuilder.ToString();
static string GetSectionHeader(OptionKey optionKey)
{
if (optionKey.Option.IsPerLanguage)
{
switch (optionKey.Language)
{
case LanguageNames.CSharp:
return "[*.cs]";
case LanguageNames.VisualBasic:
return "[*.vb]";
}
}
return "[*]";
}
}
}
protected abstract TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters);
private TestParameters WithRegularOptions(TestParameters parameters)
......@@ -199,138 +330,6 @@ protected Task TestSmartTagGlyphTagsAsync(string initialMarkup, ImmutableArray<s
}
}
protected async Task TestAddDocumentInRegularAndScriptAsync(
string initialMarkup, string expectedMarkup,
ImmutableArray<string> expectedContainers,
string expectedDocumentName,
TestParameters parameters = default)
{
await TestAddDocument(
initialMarkup, expectedMarkup,
expectedContainers, expectedDocumentName,
WithRegularOptions(parameters));
await TestAddDocument(
initialMarkup, expectedMarkup,
expectedContainers, expectedDocumentName,
WithScriptOptions(parameters));
}
protected async Task<Tuple<Solution, Solution>> TestAddDocumentAsync(
TestParameters parameters,
TestWorkspace workspace,
string expectedMarkup,
string expectedDocumentName,
ImmutableArray<string> expectedContainers)
{
var (_, action) = await GetCodeActionsAsync(workspace, parameters);
return await TestAddDocument(
workspace, expectedMarkup, expectedContainers,
expectedDocumentName, action);
}
protected async Task TestAddDocument(
string initialMarkup,
string expectedMarkup,
ImmutableArray<string> expectedContainers,
string expectedDocumentName,
TestParameters parameters = default)
{
using (var workspace = CreateWorkspaceFromOptions(initialMarkup, parameters))
{
var (_, action) = await GetCodeActionsAsync(workspace, parameters);
await TestAddDocument(
workspace, expectedMarkup, expectedContainers,
expectedDocumentName, action);
}
}
private async Task<Tuple<Solution, Solution>> TestAddDocument(
TestWorkspace workspace,
string expectedMarkup,
ImmutableArray<string> expectedFolders,
string expectedDocumentName,
CodeAction action)
{
var operations = await VerifyActionAndGetOperationsAsync(workspace, action, default);
return await TestAddDocument(
workspace,
expectedMarkup,
operations,
hasProjectChange: false,
modifiedProjectId: null,
expectedFolders: expectedFolders,
expectedDocumentName: expectedDocumentName);
}
protected async Task<Tuple<Solution, Solution>> TestAddDocument(
TestWorkspace workspace,
string expected,
ImmutableArray<CodeActionOperation> operations,
bool hasProjectChange,
ProjectId modifiedProjectId,
ImmutableArray<string> expectedFolders,
string expectedDocumentName)
{
var appliedChanges = ApplyOperationsAndGetSolution(workspace, operations);
var oldSolution = appliedChanges.Item1;
var newSolution = appliedChanges.Item2;
Document addedDocument = null;
if (!hasProjectChange)
{
addedDocument = SolutionUtilities.GetSingleAddedDocument(oldSolution, newSolution);
}
else
{
Assert.NotNull(modifiedProjectId);
addedDocument = newSolution.GetProject(modifiedProjectId).Documents.SingleOrDefault(doc => doc.Name == expectedDocumentName);
}
Assert.NotNull(addedDocument);
AssertEx.Equal(expectedFolders, addedDocument.Folders);
Assert.Equal(expectedDocumentName, addedDocument.Name);
Assert.Equal(expected, (await addedDocument.GetTextAsync()).ToString());
var editHandler = workspace.ExportProvider.GetExportedValue<ICodeActionEditHandlerService>();
if (!hasProjectChange)
{
// If there is just one document change then we expect the preview to be a WpfTextView
var content = (await editHandler.GetPreviews(workspace, operations, CancellationToken.None).GetPreviewsAsync())[0];
using (var diffView = content as DifferenceViewerPreview)
{
Assert.NotNull(diffView.Viewer);
}
}
else
{
// If there are more changes than just the document we need to browse all the changes and get the document change
var contents = editHandler.GetPreviews(workspace, operations, CancellationToken.None);
var hasPreview = false;
var previews = await contents.GetPreviewsAsync();
if (previews != null)
{
foreach (var preview in previews)
{
if (preview != null)
{
var diffView = preview as DifferenceViewerPreview;
if (diffView?.Viewer != null)
{
hasPreview = true;
diffView.Dispose();
break;
}
}
}
}
Assert.True(hasPreview);
}
return Tuple.Create(oldSolution, newSolution);
}
internal Task TestInRegularAndScriptAsync(
string initialMarkup,
string expectedMarkup,
......@@ -344,7 +343,7 @@ protected Task TestSmartTagGlyphTagsAsync(string initialMarkup, ImmutableArray<s
{
return TestInRegularAndScript1Async(
initialMarkup, expectedMarkup, index,
new TestParameters(parseOptions, compilationOptions, options, fixProviderData, index, title: title, priority: priority));
new TestParameters(parseOptions, compilationOptions, options, fixProviderData, index, priority, title: title));
}
internal async Task TestInRegularAndScript1Async(
......@@ -621,9 +620,17 @@ private static async Task VerifyAgainstWorkspaceDefinitionAsync(string expectedT
foreach (var analyzerConfigDoc in project.AnalyzerConfigDocuments)
{
var root = await analyzerConfigDoc.GetTextAsync();
var actualString = root.ToString();
if (actualString.StartsWith(AutoGeneratedAnalyzerConfigHeader))
{
// Skip validation for analyzer config file that is auto-generated by test framework
// for applying code style options.
continue;
}
var expectedDocument = expectedProject.AnalyzerConfigDocuments.Single(d => d.FilePath == analyzerConfigDoc.FilePath);
var expectedRoot = await expectedDocument.GetTextAsync();
VerifyExpectedDocumentText(expectedRoot.ToString(), root.ToString());
VerifyExpectedDocumentText(expectedRoot.ToString(), actualString);
}
}
}
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.Editor.Implementation.Preview;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.UnitTests;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
public abstract partial class AbstractCodeActionOrUserDiagnosticTest
{
protected async Task TestAddDocumentInRegularAndScriptAsync(
string initialMarkup, string expectedMarkup,
ImmutableArray<string> expectedContainers,
string expectedDocumentName,
TestParameters parameters = default)
{
await TestAddDocument(
initialMarkup, expectedMarkup,
expectedContainers, expectedDocumentName,
WithRegularOptions(parameters));
await TestAddDocument(
initialMarkup, expectedMarkup,
expectedContainers, expectedDocumentName,
WithScriptOptions(parameters));
}
protected async Task<Tuple<Solution, Solution>> TestAddDocumentAsync(
TestParameters parameters,
TestWorkspace workspace,
string expectedMarkup,
string expectedDocumentName,
ImmutableArray<string> expectedContainers)
{
var (_, action) = await GetCodeActionsAsync(workspace, parameters);
return await TestAddDocument(
workspace, expectedMarkup, expectedContainers,
expectedDocumentName, action);
}
protected async Task TestAddDocument(
string initialMarkup,
string expectedMarkup,
ImmutableArray<string> expectedContainers,
string expectedDocumentName,
TestParameters parameters = default)
{
using (var workspace = CreateWorkspaceFromOptions(initialMarkup, parameters))
{
var (_, action) = await GetCodeActionsAsync(workspace, parameters);
await TestAddDocument(
workspace, expectedMarkup, expectedContainers,
expectedDocumentName, action);
}
}
private async Task<Tuple<Solution, Solution>> TestAddDocument(
TestWorkspace workspace,
string expectedMarkup,
ImmutableArray<string> expectedFolders,
string expectedDocumentName,
CodeAction action)
{
var operations = await VerifyActionAndGetOperationsAsync(workspace, action, default);
return await TestAddDocument(
workspace,
expectedMarkup,
operations,
hasProjectChange: false,
modifiedProjectId: null,
expectedFolders: expectedFolders,
expectedDocumentName: expectedDocumentName);
}
protected async Task<Tuple<Solution, Solution>> TestAddDocument(
TestWorkspace workspace,
string expected,
ImmutableArray<CodeActionOperation> operations,
bool hasProjectChange,
ProjectId modifiedProjectId,
ImmutableArray<string> expectedFolders,
string expectedDocumentName)
{
var appliedChanges = ApplyOperationsAndGetSolution(workspace, operations);
var oldSolution = appliedChanges.Item1;
var newSolution = appliedChanges.Item2;
Document addedDocument = null;
if (!hasProjectChange)
{
addedDocument = SolutionUtilities.GetSingleAddedDocument(oldSolution, newSolution);
}
else
{
Assert.NotNull(modifiedProjectId);
addedDocument = newSolution.GetProject(modifiedProjectId).Documents.SingleOrDefault(doc => doc.Name == expectedDocumentName);
}
Assert.NotNull(addedDocument);
AssertEx.Equal(expectedFolders, addedDocument.Folders);
Assert.Equal(expectedDocumentName, addedDocument.Name);
Assert.Equal(expected, (await addedDocument.GetTextAsync()).ToString());
var editHandler = workspace.ExportProvider.GetExportedValue<ICodeActionEditHandlerService>();
if (!hasProjectChange)
{
// If there is just one document change then we expect the preview to be a WpfTextView
var content = (await editHandler.GetPreviews(workspace, operations, CancellationToken.None).GetPreviewsAsync())[0];
using (var diffView = content as DifferenceViewerPreview)
{
Assert.NotNull(diffView.Viewer);
}
}
else
{
// If there are more changes than just the document we need to browse all the changes and get the document change
var contents = editHandler.GetPreviews(workspace, operations, CancellationToken.None);
var hasPreview = false;
var previews = await contents.GetPreviewsAsync();
if (previews != null)
{
foreach (var preview in previews)
{
if (preview != null)
{
var diffView = preview as DifferenceViewerPreview;
if (diffView?.Viewer != null)
{
hasPreview = true;
diffView.Dispose();
break;
}
}
}
}
Assert.True(hasPreview);
}
return Tuple.Create(oldSolution, newSolution);
}
}
}
......@@ -23,7 +23,7 @@
namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
public abstract class AbstractCodeActionTest : AbstractCodeActionOrUserDiagnosticTest
public abstract partial class AbstractCodeActionTest : AbstractCodeActionOrUserDiagnosticTest
{
protected abstract CodeRefactoringProvider CreateCodeRefactoringProvider(
Workspace workspace, TestParameters parameters);
......
......@@ -44,7 +44,6 @@ public Test()
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItems(s_nullableWarnings));
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions);
#if !CODE_STYLE // TODO: Add support for Options based tests in CodeStyle layer
var (analyzerConfigSource, remainingOptions) = CodeFixVerifierHelper.ConvertOptionsToAnalyzerConfig(DefaultFileExt, Options);
if (analyzerConfigSource is object)
{
......@@ -55,6 +54,7 @@ public Test()
}
}
#if !CODE_STYLE
var options = solution.Options;
foreach (var (key, value) in remainingOptions)
{
......@@ -88,13 +88,11 @@ public Test()
/// </summary>
public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.CSharp8;
#if !CODE_STYLE // TODO: Add support for Options based tests in CodeStyle layer
/// <summary>
/// Gets a collection of options to apply to <see cref="Solution.Options"/> for testing. Values may be added
/// using a collection initializer.
/// </summary>
public OptionsCollection Options { get; } = new OptionsCollection(LanguageNames.CSharp);
#endif
public Func<ImmutableArray<Diagnostic>, Diagnostic?>? DiagnosticSelector { get; set; }
......
......@@ -9,11 +9,17 @@
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using Xunit;
#if CODE_STYLE
using OptionSet = Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions;
using Microsoft.CodeAnalysis.Internal.Options;
#else
using Microsoft.CodeAnalysis.Options;
#endif
namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
internal static class CodeFixVerifierHelper
......@@ -81,7 +87,6 @@ private static void VerifyMessageHelpLinkUri(DiagnosticAnalyzer analyzer)
}
}
#if !CODE_STYLE
public static (SourceText? analyzerConfig, IEnumerable<KeyValuePair<OptionKey, object?>> options) ConvertOptionsToAnalyzerConfig(string defaultFileExtension, OptionsCollection options)
{
if (options.Count == 0)
......@@ -120,6 +125,12 @@ public OptionSetWrapper(Dictionary<OptionKey, object?> options)
_options = options;
}
#if CODE_STYLE
public override bool TryGetValue(string key, out string value)
{
throw new NotImplementedException();
}
#else
public override object? GetOption(OptionKey optionKey)
{
if (!_options.TryGetValue(optionKey, out var value))
......@@ -135,7 +146,8 @@ public override OptionSet WithChangedOption(OptionKey optionAndLanguage, object?
internal override IEnumerable<OptionKey> GetChangedOptions(OptionSet optionSet)
=> SpecializedCollections.EmptyEnumerable<OptionKey>();
}
#endif
}
}
}
......@@ -4,8 +4,13 @@
using System.Collections;
using System.Collections.Generic;
#if CODE_STYLE
using Microsoft.CodeAnalysis.Internal.Options;
#else
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Options;
#endif
namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
{
......
......@@ -31,7 +31,6 @@ public Test()
var parseOptions = (VisualBasicParseOptions)solution.GetRequiredProject(projectId).ParseOptions!;
solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion));
#if !CODE_STYLE // TODO: Add support for Options based tests in CodeStyle layer
var (analyzerConfigSource, remainingOptions) = CodeFixVerifierHelper.ConvertOptionsToAnalyzerConfig(DefaultFileExt, Options);
if (analyzerConfigSource is object)
{
......@@ -42,6 +41,7 @@ public Test()
}
}
#if !CODE_STYLE
var options = solution.Options;
foreach (var (key, value) in remainingOptions)
{
......@@ -61,13 +61,11 @@ public Test()
/// </summary>
public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.VisualBasic16;
#if !CODE_STYLE // TODO: Add support for Options based tests in CodeStyle layer
/// <summary>
/// Gets a collection of options to apply to <see cref="Solution.Options"/> for testing. Values may be added
/// using a collection initializer.
/// </summary>
public OptionsCollection Options { get; } = new OptionsCollection(LanguageNames.VisualBasic);
#endif
public Func<ImmutableArray<Diagnostic>, Diagnostic?>? DiagnosticSelector { get; set; }
......
......@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
......@@ -10,19 +9,23 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UnitTests.Diagnostics;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
#if CODE_STYLE
using Microsoft.CodeAnalysis.Internal.Options;
#else
using Microsoft.CodeAnalysis.Options;
#endif
namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
{
public abstract class AbstractDiagnosticProviderBasedUserDiagnosticTest : AbstractUserDiagnosticTest
public abstract partial class AbstractDiagnosticProviderBasedUserDiagnosticTest : AbstractUserDiagnosticTest
{
private readonly ConcurrentDictionary<Workspace, (DiagnosticAnalyzer, CodeFixProvider)> _analyzerAndFixerMap =
new ConcurrentDictionary<Workspace, (DiagnosticAnalyzer, CodeFixProvider)>();
......@@ -224,56 +227,5 @@ private void AssertNoAnalyzerExceptionDiagnostics(IEnumerable<Diagnostic> diagno
var analyzerExceptionDiagnostics = diagnostics.Where(diag => diag.Descriptor.CustomTags.Contains(WellKnownDiagnosticTags.AnalyzerException));
AssertEx.Empty(analyzerExceptionDiagnostics, "Found analyzer exception diagnostics");
}
#region Parentheses options
private static readonly CodeStyleOption<ParenthesesPreference> IgnorePreference =
new CodeStyleOption<ParenthesesPreference>(ParenthesesPreference.AlwaysForClarity, NotificationOption.None);
private static readonly CodeStyleOption<ParenthesesPreference> RequireForPrecedenceClarityPreference =
new CodeStyleOption<ParenthesesPreference>(ParenthesesPreference.AlwaysForClarity, NotificationOption.Suggestion);
private static readonly CodeStyleOption<ParenthesesPreference> RemoveIfUnnecessaryPreference =
new CodeStyleOption<ParenthesesPreference>(ParenthesesPreference.NeverIfUnnecessary, NotificationOption.Suggestion);
private static IEnumerable<PerLanguageOption<CodeStyleOption<ParenthesesPreference>>> GetAllExceptOtherParenthesesOptions()
{
yield return CodeStyleOptions.ArithmeticBinaryParentheses;
yield return CodeStyleOptions.RelationalBinaryParentheses;
yield return CodeStyleOptions.OtherBinaryParentheses;
}
protected IDictionary<OptionKey, object> RequireArithmeticBinaryParenthesesForClarity
=> GetSingleRequireOption(CodeStyleOptions.ArithmeticBinaryParentheses);
protected IDictionary<OptionKey, object> RequireRelationalBinaryParenthesesForClarity
=> GetSingleRequireOption(CodeStyleOptions.RelationalBinaryParentheses);
protected IDictionary<OptionKey, object> RequireOtherBinaryParenthesesForClarity
=> GetSingleRequireOption(CodeStyleOptions.OtherBinaryParentheses);
private IEnumerable<PerLanguageOption<CodeStyleOption<ParenthesesPreference>>> GetAllParenthesesOptions()
=> GetAllExceptOtherParenthesesOptions().Concat(CodeStyleOptions.OtherParentheses);
protected IDictionary<OptionKey, object> IgnoreAllParentheses
=> OptionsSet(GetAllParenthesesOptions().Select(
o => SingleOption(o, IgnorePreference)).ToArray());
protected IDictionary<OptionKey, object> RemoveAllUnnecessaryParentheses
=> OptionsSet(GetAllParenthesesOptions().Select(
o => SingleOption(o, RemoveIfUnnecessaryPreference)).ToArray());
protected IDictionary<OptionKey, object> RequireAllParenthesesForClarity
=> OptionsSet(GetAllExceptOtherParenthesesOptions()
.Select(o => SingleOption(o, RequireForPrecedenceClarityPreference))
.Concat(SingleOption(CodeStyleOptions.OtherParentheses, RemoveIfUnnecessaryPreference)).ToArray());
private IDictionary<OptionKey, object> GetSingleRequireOption(PerLanguageOption<CodeStyleOption<ParenthesesPreference>> option)
=> OptionsSet(GetAllParenthesesOptions()
.Where(o => o != option)
.Select(o => SingleOption(o, RemoveIfUnnecessaryPreference))
.Concat(SingleOption(option, RequireForPrecedenceClarityPreference)).ToArray());
#endregion
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Options;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
{
public abstract partial class AbstractDiagnosticProviderBasedUserDiagnosticTest : AbstractUserDiagnosticTest
{
#region Parentheses options
private static readonly CodeStyleOption<ParenthesesPreference> IgnorePreference =
new CodeStyleOption<ParenthesesPreference>(ParenthesesPreference.AlwaysForClarity, NotificationOption.None);
private static readonly CodeStyleOption<ParenthesesPreference> RequireForPrecedenceClarityPreference =
new CodeStyleOption<ParenthesesPreference>(ParenthesesPreference.AlwaysForClarity, NotificationOption.Suggestion);
private static readonly CodeStyleOption<ParenthesesPreference> RemoveIfUnnecessaryPreference =
new CodeStyleOption<ParenthesesPreference>(ParenthesesPreference.NeverIfUnnecessary, NotificationOption.Suggestion);
private static IEnumerable<PerLanguageOption<CodeStyleOption<ParenthesesPreference>>> GetAllExceptOtherParenthesesOptions()
{
yield return CodeStyleOptions.ArithmeticBinaryParentheses;
yield return CodeStyleOptions.RelationalBinaryParentheses;
yield return CodeStyleOptions.OtherBinaryParentheses;
}
protected IDictionary<OptionKey, object> RequireArithmeticBinaryParenthesesForClarity
=> GetSingleRequireOption(CodeStyleOptions.ArithmeticBinaryParentheses);
protected IDictionary<OptionKey, object> RequireRelationalBinaryParenthesesForClarity
=> GetSingleRequireOption(CodeStyleOptions.RelationalBinaryParentheses);
protected IDictionary<OptionKey, object> RequireOtherBinaryParenthesesForClarity
=> GetSingleRequireOption(CodeStyleOptions.OtherBinaryParentheses);
private IEnumerable<PerLanguageOption<CodeStyleOption<ParenthesesPreference>>> GetAllParenthesesOptions()
=> GetAllExceptOtherParenthesesOptions().Concat(CodeStyleOptions.OtherParentheses);
protected IDictionary<OptionKey, object> IgnoreAllParentheses
=> OptionsSet(GetAllParenthesesOptions().Select(
o => SingleOption(o, IgnorePreference)).ToArray());
protected IDictionary<OptionKey, object> RemoveAllUnnecessaryParentheses
=> OptionsSet(GetAllParenthesesOptions().Select(
o => SingleOption(o, RemoveIfUnnecessaryPreference)).ToArray());
protected IDictionary<OptionKey, object> RequireAllParenthesesForClarity
=> OptionsSet(GetAllExceptOtherParenthesesOptions()
.Select(o => SingleOption(o, RequireForPrecedenceClarityPreference))
.Concat(SingleOption(CodeStyleOptions.OtherParentheses, RemoveIfUnnecessaryPreference)).ToArray());
private IDictionary<OptionKey, object> GetSingleRequireOption(PerLanguageOption<CodeStyleOption<ParenthesesPreference>> option)
=> OptionsSet(GetAllParenthesesOptions()
.Where(o => o != option)
.Select(o => SingleOption(o, RemoveIfUnnecessaryPreference))
.Concat(SingleOption(option, RequireForPrecedenceClarityPreference)).ToArray());
#endregion
}
}
......@@ -11,23 +11,22 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeFixes.Suppression;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics.GenerateType;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.GenerateType;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UnitTests;
using Microsoft.CodeAnalysis.UnitTests.Diagnostics;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
#if CODE_STYLE
using Microsoft.CodeAnalysis.Internal.Options;
#else
using Microsoft.CodeAnalysis.Options;
#endif
namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
{
public abstract partial class AbstractUserDiagnosticTest : AbstractCodeActionOrUserDiagnosticTest
......@@ -293,158 +292,5 @@ protected Document GetDocumentAndAnnotatedSpan(TestWorkspace workspace, out stri
Assert.True(expectedTextSpans.SetEquals(actualTextSpans));
}
internal async Task TestWithMockedGenerateTypeDialog(
string initial,
string languageName,
string typeName,
string expected = null,
bool isMissing = false,
Accessibility accessibility = Accessibility.NotApplicable,
TypeKind typeKind = TypeKind.Class,
string projectName = null,
bool isNewFile = false,
string existingFilename = null,
ImmutableArray<string> newFileFolderContainers = default,
string fullFilePath = null,
string newFileName = null,
string assertClassName = null,
bool checkIfUsingsIncluded = false,
bool checkIfUsingsNotIncluded = false,
string expectedTextWithUsings = null,
string defaultNamespace = "",
bool areFoldersValidIdentifiers = true,
GenerateTypeDialogOptions assertGenerateTypeDialogOptions = null,
IList<TypeKindOptions> assertTypeKindPresent = null,
IList<TypeKindOptions> assertTypeKindAbsent = null,
bool isCancelled = false)
{
using var testState = GenerateTypeTestState.Create(initial, projectName, typeName, existingFilename, languageName);
// Initialize the viewModel values
testState.TestGenerateTypeOptionsService.SetGenerateTypeOptions(
accessibility: accessibility,
typeKind: typeKind,
typeName: testState.TypeName,
project: testState.ProjectToBeModified,
isNewFile: isNewFile,
newFileName: newFileName,
folders: newFileFolderContainers,
fullFilePath: fullFilePath,
existingDocument: testState.ExistingDocument,
areFoldersValidIdentifiers: areFoldersValidIdentifiers,
isCancelled: isCancelled);
testState.TestProjectManagementService.SetDefaultNamespace(
defaultNamespace: defaultNamespace);
var testOptions = new TestParameters();
var (diagnostics, actions, _) = await GetDiagnosticAndFixesAsync(testState.Workspace, testOptions);
var generateTypeDiagFixes = diagnostics.SingleOrDefault(df => GenerateTypeTestState.FixIds.Contains(df.Id));
if (isMissing)
{
Assert.Empty(actions);
return;
}
var fixActions = MassageActions(actions);
Assert.NotNull(fixActions);
// Since the dialog option is always fed as the last CodeAction
var index = fixActions.Count() - 1;
var action = fixActions.ElementAt(index);
Assert.Equal(action.Title, FeaturesResources.Generate_new_type);
var operations = await action.GetOperationsAsync(CancellationToken.None);
Tuple<Solution, Solution> oldSolutionAndNewSolution = null;
if (!isNewFile)
{
oldSolutionAndNewSolution = await TestOperationsAsync(
testState.Workspace, expected, operations,
conflictSpans: ImmutableArray<TextSpan>.Empty,
renameSpans: ImmutableArray<TextSpan>.Empty,
warningSpans: ImmutableArray<TextSpan>.Empty,
navigationSpans: ImmutableArray<TextSpan>.Empty,
expectedChangedDocumentId: testState.ExistingDocument.Id);
}
else
{
oldSolutionAndNewSolution = await TestAddDocument(
testState.Workspace,
expected,
operations,
projectName != null,
testState.ProjectToBeModified.Id,
newFileFolderContainers,
newFileName);
}
if (checkIfUsingsIncluded)
{
Assert.NotNull(expectedTextWithUsings);
await TestOperationsAsync(testState.Workspace, expectedTextWithUsings, operations,
conflictSpans: ImmutableArray<TextSpan>.Empty,
renameSpans: ImmutableArray<TextSpan>.Empty,
warningSpans: ImmutableArray<TextSpan>.Empty,
navigationSpans: ImmutableArray<TextSpan>.Empty,
expectedChangedDocumentId: testState.InvocationDocument.Id);
}
if (checkIfUsingsNotIncluded)
{
var oldSolution = oldSolutionAndNewSolution.Item1;
var newSolution = oldSolutionAndNewSolution.Item2;
var changedDocumentIds = SolutionUtilities.GetChangedDocuments(oldSolution, newSolution);
Assert.False(changedDocumentIds.Contains(testState.InvocationDocument.Id));
}
// Added into a different project than the triggering project
if (projectName != null)
{
var appliedChanges = ApplyOperationsAndGetSolution(testState.Workspace, operations);
var newSolution = appliedChanges.Item2;
var triggeredProject = newSolution.GetProject(testState.TriggeredProject.Id);
// Make sure the Project reference is present
Assert.True(triggeredProject.ProjectReferences.Any(pr => pr.ProjectId == testState.ProjectToBeModified.Id));
}
// Assert Option Calculation
if (assertClassName != null)
{
Assert.True(assertClassName == testState.TestGenerateTypeOptionsService.ClassName);
}
if (assertGenerateTypeDialogOptions != null || assertTypeKindPresent != null || assertTypeKindAbsent != null)
{
var generateTypeDialogOptions = testState.TestGenerateTypeOptionsService.GenerateTypeDialogOptions;
if (assertGenerateTypeDialogOptions != null)
{
Assert.True(assertGenerateTypeDialogOptions.IsPublicOnlyAccessibility == generateTypeDialogOptions.IsPublicOnlyAccessibility);
Assert.True(assertGenerateTypeDialogOptions.TypeKindOptions == generateTypeDialogOptions.TypeKindOptions);
Assert.True(assertGenerateTypeDialogOptions.IsAttribute == generateTypeDialogOptions.IsAttribute);
}
if (assertTypeKindPresent != null)
{
foreach (var typeKindPresentEach in assertTypeKindPresent)
{
Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) != 0);
}
}
if (assertTypeKindAbsent != null)
{
foreach (var typeKindPresentEach in assertTypeKindAbsent)
{
Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) == 0);
}
}
}
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics.GenerateType;
using Microsoft.CodeAnalysis.GenerateType;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UnitTests;
using Roslyn.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
{
public abstract partial class AbstractUserDiagnosticTest : AbstractCodeActionOrUserDiagnosticTest
{
internal async Task TestWithMockedGenerateTypeDialog(
string initial,
string languageName,
string typeName,
string expected = null,
bool isMissing = false,
Accessibility accessibility = Accessibility.NotApplicable,
TypeKind typeKind = TypeKind.Class,
string projectName = null,
bool isNewFile = false,
string existingFilename = null,
ImmutableArray<string> newFileFolderContainers = default,
string fullFilePath = null,
string newFileName = null,
string assertClassName = null,
bool checkIfUsingsIncluded = false,
bool checkIfUsingsNotIncluded = false,
string expectedTextWithUsings = null,
string defaultNamespace = "",
bool areFoldersValidIdentifiers = true,
GenerateTypeDialogOptions assertGenerateTypeDialogOptions = null,
IList<TypeKindOptions> assertTypeKindPresent = null,
IList<TypeKindOptions> assertTypeKindAbsent = null,
bool isCancelled = false)
{
using var testState = GenerateTypeTestState.Create(initial, projectName, typeName, existingFilename, languageName);
// Initialize the viewModel values
testState.TestGenerateTypeOptionsService.SetGenerateTypeOptions(
accessibility: accessibility,
typeKind: typeKind,
typeName: testState.TypeName,
project: testState.ProjectToBeModified,
isNewFile: isNewFile,
newFileName: newFileName,
folders: newFileFolderContainers,
fullFilePath: fullFilePath,
existingDocument: testState.ExistingDocument,
areFoldersValidIdentifiers: areFoldersValidIdentifiers,
isCancelled: isCancelled);
testState.TestProjectManagementService.SetDefaultNamespace(
defaultNamespace: defaultNamespace);
var testOptions = new TestParameters();
var (diagnostics, actions, _) = await GetDiagnosticAndFixesAsync(testState.Workspace, testOptions);
var generateTypeDiagFixes = diagnostics.SingleOrDefault(df => GenerateTypeTestState.FixIds.Contains(df.Id));
if (isMissing)
{
Assert.Empty(actions);
return;
}
var fixActions = MassageActions(actions);
Assert.False(fixActions.IsDefault);
// Since the dialog option is always fed as the last CodeAction
var index = fixActions.Count() - 1;
var action = fixActions.ElementAt(index);
Assert.Equal(action.Title, FeaturesResources.Generate_new_type);
var operations = await action.GetOperationsAsync(CancellationToken.None);
Tuple<Solution, Solution> oldSolutionAndNewSolution = null;
if (!isNewFile)
{
oldSolutionAndNewSolution = await TestOperationsAsync(
testState.Workspace, expected, operations,
conflictSpans: ImmutableArray<TextSpan>.Empty,
renameSpans: ImmutableArray<TextSpan>.Empty,
warningSpans: ImmutableArray<TextSpan>.Empty,
navigationSpans: ImmutableArray<TextSpan>.Empty,
expectedChangedDocumentId: testState.ExistingDocument.Id);
}
else
{
oldSolutionAndNewSolution = await TestAddDocument(
testState.Workspace,
expected,
operations,
projectName != null,
testState.ProjectToBeModified.Id,
newFileFolderContainers,
newFileName);
}
if (checkIfUsingsIncluded)
{
Assert.NotNull(expectedTextWithUsings);
await TestOperationsAsync(testState.Workspace, expectedTextWithUsings, operations,
conflictSpans: ImmutableArray<TextSpan>.Empty,
renameSpans: ImmutableArray<TextSpan>.Empty,
warningSpans: ImmutableArray<TextSpan>.Empty,
navigationSpans: ImmutableArray<TextSpan>.Empty,
expectedChangedDocumentId: testState.InvocationDocument.Id);
}
if (checkIfUsingsNotIncluded)
{
var oldSolution = oldSolutionAndNewSolution.Item1;
var newSolution = oldSolutionAndNewSolution.Item2;
var changedDocumentIds = SolutionUtilities.GetChangedDocuments(oldSolution, newSolution);
Assert.False(changedDocumentIds.Contains(testState.InvocationDocument.Id));
}
// Added into a different project than the triggering project
if (projectName != null)
{
var appliedChanges = ApplyOperationsAndGetSolution(testState.Workspace, operations);
var newSolution = appliedChanges.Item2;
var triggeredProject = newSolution.GetProject(testState.TriggeredProject.Id);
// Make sure the Project reference is present
Assert.True(triggeredProject.ProjectReferences.Any(pr => pr.ProjectId == testState.ProjectToBeModified.Id));
}
// Assert Option Calculation
if (assertClassName != null)
{
Assert.True(assertClassName == testState.TestGenerateTypeOptionsService.ClassName);
}
if (assertGenerateTypeDialogOptions != null || assertTypeKindPresent != null || assertTypeKindAbsent != null)
{
var generateTypeDialogOptions = testState.TestGenerateTypeOptionsService.GenerateTypeDialogOptions;
if (assertGenerateTypeDialogOptions != null)
{
Assert.True(assertGenerateTypeDialogOptions.IsPublicOnlyAccessibility == generateTypeDialogOptions.IsPublicOnlyAccessibility);
Assert.True(assertGenerateTypeDialogOptions.TypeKindOptions == generateTypeDialogOptions.TypeKindOptions);
Assert.True(assertGenerateTypeDialogOptions.IsAttribute == generateTypeDialogOptions.IsAttribute);
}
if (assertTypeKindPresent != null)
{
foreach (var typeKindPresentEach in assertTypeKindPresent)
{
Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) != 0);
}
}
if (assertTypeKindAbsent != null)
{
foreach (var typeKindPresentEach in assertTypeKindAbsent)
{
Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) == 0);
}
}
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.Test.Utilities</RootNamespace>
<TargetFramework>net472</TargetFramework>
<UseWpf>true</UseWpf>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsShipping>false</IsShipping>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
<ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" />
<ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" />
<ProjectReference Include="..\..\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj" />
<ProjectReference Include="..\..\Features\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Features.csproj" />
<ProjectReference Include="..\..\Features\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" />
<ProjectReference Include="..\..\Features\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Features.vbproj" />
<ProjectReference Include="..\..\EditorFeatures\CSharp.Wpf\Microsoft.CodeAnalysis.CSharp.EditorFeatures.Wpf.csproj" />
<ProjectReference Include="..\..\Test\Utilities\Portable\Roslyn.Test.Utilities.csproj" />
<ProjectReference Include="..\..\Workspaces\CoreTestUtilities\Roslyn.Services.UnitTests.Utilities.csproj" />
<ProjectReference Include="..\TestUtilities\Roslyn.Services.Test.Utilities.csproj" />
<ProjectReference Include="..\..\Workspaces\Core\Portable\Microsoft.CodeAnalysis.Workspaces.csproj">
<Aliases>global,WORKSPACES</Aliases>
</ProjectReference>
<ProjectReference Include="..\..\Workspaces\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.Workspaces.csproj" />
<ProjectReference Include="..\..\Workspaces\Remote\Core\Microsoft.CodeAnalysis.Remote.Workspaces.csproj" />
<ProjectReference Include="..\..\Workspaces\Remote\ServiceHub\Microsoft.CodeAnalysis.Remote.ServiceHub.csproj" />
<ProjectReference Include="..\..\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj" />
<ProjectReference Include="..\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" />
<ProjectReference Include="..\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" />
<ProjectReference Include="..\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" />
<ProjectReference Include="..\Text\Microsoft.CodeAnalysis.EditorFeatures.Text.csproj" />
<ProjectReference Include="..\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Test.Utilities2" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Utilities" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Test.Utilities2" />
</ItemGroup>
<ItemGroup>
<!-- TODO: Remove the below IVTs to CodeStyle Unit test projects once all analyzer/code fix tests are switched to Microsoft.CodeAnalysis.Testing -->
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests" />
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -34,6 +34,7 @@
<ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" />
<ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" />
<ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj" />
<ProjectReference Include="..\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj" />
<ProjectReference Include="..\TestUtilities\Roslyn.Services.Test.Utilities.csproj" />
<ProjectReference Include="..\..\Scripting\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Scripting.vbproj" />
<ProjectReference Include="..\..\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj" />
......
......@@ -100,6 +100,13 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Utilities" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Test.Utilities2" />
</ItemGroup>
<ItemGroup>
<!-- TODO: Remove the below IVTs to CodeStyle Unit test projects once all analyzer/code fix tests are switched to Microsoft.CodeAnalysis.Testing -->
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
......
......@@ -27,7 +27,6 @@ public class TestHostProject
private readonly string _assemblyName;
private readonly Type _hostObjectType;
private readonly VersionStamp _version;
private readonly string _filePath;
private readonly string _outputFilePath;
private readonly string _defaultNamespace;
......@@ -35,6 +34,7 @@ public class TestHostProject
public IEnumerable<TestHostDocument> AdditionalDocuments;
public IEnumerable<TestHostDocument> AnalyzerConfigDocuments;
public IEnumerable<ProjectReference> ProjectReferences;
private string _filePath;
public string Name
{
......@@ -124,6 +124,9 @@ public string FilePath
}
}
internal void OnProjectFilePathChanged(string filePath)
=> _filePath = filePath;
public string OutputFilePath
{
get { return _outputFilePath; }
......
......@@ -341,7 +341,7 @@ protected override void ApplyAnalyzerConfigDocumentTextChanged(DocumentId docume
protected override void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text)
{
var hostProject = this.GetTestProject(info.Id.ProjectId);
var hostDocument = new TestHostDocument(text.ToString(), info.Name, id: info.Id);
var hostDocument = new TestHostDocument(text.ToString(), info.Name, id: info.Id, filePath: info.FilePath, folders: info.Folders);
hostProject.AddAnalyzerConfigDocument(hostDocument);
this.OnAnalyzerConfigDocumentAdded(hostDocument.ToDocumentInfo());
}
......@@ -354,6 +354,18 @@ protected override void ApplyAnalyzerConfigDocumentRemoved(DocumentId documentId
this.OnAnalyzerConfigDocumentRemoved(documentId);
}
protected override void ApplyProjectChanges(ProjectChanges projectChanges)
{
if (projectChanges.OldProject.FilePath != projectChanges.NewProject.FilePath)
{
var hostProject = this.GetTestProject(projectChanges.NewProject.Id);
hostProject.OnProjectFilePathChanged(projectChanges.NewProject.FilePath);
base.OnProjectNameChanged(projectChanges.NewProject.Id, projectChanges.NewProject.Name, projectChanges.NewProject.FilePath);
}
base.ApplyProjectChanges(projectChanges);
}
internal override void SetDocumentContext(DocumentId documentId)
{
OnDocumentContextUpdated(documentId);
......
......@@ -37,6 +37,7 @@
<ProjectReference Include="..\..\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" />
<ProjectReference Include="..\..\EditorFeatures\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.vbproj" />
<ProjectReference Include="..\CSharp\Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj" />
<ProjectReference Include="..\DiagnosticsTestUtilities\Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj" />
<ProjectReference Include="..\TestUtilities\Roslyn.Services.Test.Utilities.csproj" />
</ItemGroup>
<ItemGroup>
......
......@@ -42,6 +42,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
......
......@@ -77,6 +77,7 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.IntegrationTest.Utilities" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests" />
......
......@@ -37,6 +37,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
......
......@@ -96,6 +96,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures2.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
<InternalsVisibleTo Include="Roslyn.Services.Test.Utilities" />
<InternalsVisibleTo Include="IdeBenchmarks" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
......@@ -123,6 +124,12 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.Editor.Razor" Key="$(RazorKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35079" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Razor" Key="$(RazorKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35079" />
</ItemGroup>
<ItemGroup>
<!-- TODO: Remove the below IVTs to CodeStyle Unit test projects once all analyzer/code fix tests are switched to Microsoft.CodeAnalysis.Testing -->
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="WorkspacesResources.resx" GenerateSource="true" />
</ItemGroup>
......
......@@ -9,11 +9,13 @@
#if CODE_STYLE
namespace Microsoft.CodeAnalysis.Internal.Options
{
public interface IEditorConfigStorageLocation
#else
namespace Microsoft.CodeAnalysis.Options
#endif
{
internal interface IEditorConfigStorageLocation
#endif
{
bool TryGetOption(IReadOnlyDictionary<string, string?> rawOptions, Type type, out object? value);
}
......
......@@ -10,11 +10,13 @@
#if CODE_STYLE
namespace Microsoft.CodeAnalysis.Internal.Options
{
public interface IEditorConfigStorageLocation2 : IEditorConfigStorageLocation
#else
namespace Microsoft.CodeAnalysis.Options
#endif
{
internal interface IEditorConfigStorageLocation2 : IEditorConfigStorageLocation
#endif
{
string KeyName { get; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册