Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit f9cba2d

Browse files
committed
[Ide] Refresh type system for all projects when editorconfig added
If Configure and Suppress issues is used when the solution has multiple projects the updated analyzer setting in the added editorconfig file was not applied to all projects. To fix this when the ApplyAnalyzerConfigDocumentAdded method is called for the Roslyn workspace the project info is refreshed in the type system. Currently there is some odd behaviour here. The .editorconfig file does not always get added as a link to the current project. The ApplyAnalyzerConfigDocumentAdded method is only called once for a single project. Also handle any errors when an .editorconfig file is removed and the associated document id is not in the workspace.
1 parent 2d5cf8f commit f9cba2d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,11 @@ protected override void ApplyAnalyzerConfigDocumentAdded (DocumentInfo info, Sou
11811181
// Need to trigger Project.Modified event after TryApp is run so project is reloaded by the type system
11821182
// service. Adding the file to the Files collection will not trigger the modified event since
11831183
// the build action is not EditorConfigFiles. Also this event would be ignored anyway during TryApply.
1184-
// Also handles if the link already existed.
1185-
tryApplyState_modifiedProjects.Add (mdProject);
1184+
// Also handles if the link already existed. Need to refresh all projects since the document added
1185+
// method will only be called once.
1186+
foreach (var affectedProject in mdProject.ParentSolution.GetAllProjects ()) {
1187+
tryApplyState_modifiedProjects.Add (affectedProject);
1188+
}
11861189
tryApplyState_changedProjects.Add (mdProject);
11871190
}
11881191

main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ void OnEditorConfigDocumentRemoved (FilePath fileName)
201201
var docId = mdWorkspace.GetDocumentId (projectId, fileName);
202202
if (docId != null) {
203203
projects.Add (mdProject);
204-
mdWorkspace.OnAnalyzerConfigDocumentRemoved (docId);
204+
try {
205+
mdWorkspace.OnAnalyzerConfigDocumentRemoved (docId);
206+
} catch (Exception ex) {
207+
// Ignore error so other projects can be updated.
208+
LoggingService.LogError ("OnAnalyzerConfigDocumentRemoved error", ex);
209+
}
205210
}
206211
}
207212
}

0 commit comments

Comments
 (0)