Be smarter for how we raise WorkspaceChange events when ending batches
When we completed a batch, we'd always raise a generic ProjectChanged event, even if the change could be represented more precisely: if we only added a single Document we could still raise DocumentAdded but we'd still raise the generic ProjectChanged. This now raises more precise events, when possible. This should allow for downstream optimizations: adding a new document won't have to rerun syntax analyzers on everything else, for example. There was also a second issue where if the batch was closed and nothing happened at all, we'd still raise a ProjectChanged. This was because the old code tried having a special case where if it mutated the Solution and ended up with the same Solution at the end, it'd skip the actual change. However there was a bug where if it called Solution.AddProjectReferences or Solution.AddMetadataReferences and passed an empty list, it'd make a new solution snapshot. That's not necessary to do, so we optimize that at the Workspaces layer. Fixes https://github.com/dotnet/roslyn/issues/34309
Showing
想要评论请 注册 或 登录