未验证 提交 b9506948 编写于 作者: J Jason Malinowski 提交者: GitHub

Merge pull request #35621 from jasonmalinowski/fix-editorconfig-bugs

Fix three .editorconfig bugs
......@@ -18,7 +18,7 @@ internal sealed class WorkspaceAnalyzerOptions : AnalyzerOptions
private readonly OptionSet _optionSet;
public WorkspaceAnalyzerOptions(AnalyzerOptions options, OptionSet optionSet, Solution solution)
: base(options.AdditionalFiles)
: base(options.AdditionalFiles, options.AnalyzerConfigOptionsProvider)
{
_solution = solution;
_optionSet = optionSet;
......
......@@ -257,12 +257,12 @@ internal VisualStudioProject GetProject_TestOnly()
public void AddAnalyzerConfigFile(string filePath)
{
// TODO: implement. Right now this exists to provide a stub for the project system work to be implemented against.
_visualStudioProject.AddAnalyzerConfigFile(filePath);
}
public void RemoveAnalyzerConfigFile(string filePath)
{
// TODO: implement. Right now this exists to provide a stub for the project system work to be implemented against.
_visualStudioProject.RemoveAnalyzerConfigFile(filePath);
}
}
}
......@@ -533,7 +533,9 @@ public SolutionState AddProject(ProjectInfo projectInfo)
}
private static IEnumerable<TextDocumentState> GetDocumentStates(ProjectState projectState)
=> projectState.DocumentStates.Values.Concat(projectState.AdditionalDocumentStates.Values);
=> projectState.DocumentStates.Values
.Concat(projectState.AdditionalDocumentStates.Values)
.Concat(projectState.AnalyzerConfigDocumentStates.Values);
/// <summary>
/// Create a new solution instance without the project specified.
......
......@@ -1729,6 +1729,29 @@ public async Task TestChangingAnEditorConfigFile()
Assert.True(finalCompilation.ContainsSyntaxTree(syntaxTreeAfterEditorConfigChange));
}
[Fact, Trait(Traits.Feature, Traits.Features.Workspace)]
public void AddingAndRemovingProjectsUpdatesFilePathMap()
{
var solution = CreateSolution();
var projectId = ProjectId.CreateNewId();
var editorConfigDocumentId = DocumentId.CreateNewId(projectId);
const string editorConfigFilePath = @"Z:\.editorconfig";
var projectInfo =
ProjectInfo.Create(projectId, VersionStamp.Default, "Test", "Test", LanguageNames.CSharp)
.WithAnalyzerConfigDocuments(new[] { DocumentInfo.Create(editorConfigDocumentId, ".editorconfig", filePath: editorConfigFilePath) });
solution = solution.AddProject(projectInfo);
Assert.Equal(editorConfigDocumentId, Assert.Single(solution.GetDocumentIdsWithFilePath(editorConfigFilePath)));
solution = solution.RemoveProject(projectId);
Assert.Empty(solution.GetDocumentIdsWithFilePath(editorConfigFilePath));
}
private static void GetMultipleProjects(
out Project csBrokenProject,
out Project vbNormalProject,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册