Update Roslyn snapshot when editorconfig is updated. for now, it only…#26221
Update Roslyn snapshot when editorconfig is updated. for now, it only…#26221heejaechang merged 3 commits intodotnet:dev15.7.xfrom
Conversation
… updates when editorconfig is saved.
|
@jasonmalinowski is this approach look okay for now? |
|
@heejaechang Will look in detail tomorrow, but gist seems OK. |
|
(wrong button) |
| internal Solution WithOptionChanged() | ||
| { | ||
| // just create new snapshot | ||
| return new Solution(_state); |
There was a problem hiding this comment.
this needs more explanation. for example, why this has any effect at all. From just looking it woudl seem that this does nothing since we're just makinga new solution with exactly the same state as the current solution we have.
There was a problem hiding this comment.
there are bunch of comments what it is doing. we made option as part of solution snapshot. but when option is changed, we don't create new snapshot. so it does that now.
There was a problem hiding this comment.
@CyrusNajmabadi Basically, Document holds onto a snapshot of the file's options, so that way that's immutable. When the options change, we aren't (currently) creating a new snapshot so values would be stale. This is at least working around that problem before we integrate .editorconfig more cleanly into workspaces, which is currently underway.
There was a problem hiding this comment.
@jasonmalinowski What i meant was: we need to document that on the call. :)
|
approved to merge via link for 15.7.Preview5 |
|
one more review pending |
sharwell
left a comment
There was a problem hiding this comment.
A couple questions to answer 😄
| { | ||
| var context = t.Result; | ||
|
|
||
| context.CodingConventionsChangedAsync -= OnCodingConventionsChangedAsync; |
There was a problem hiding this comment.
❓ Does this matter if we are disposing of the object anyway?
There was a problem hiding this comment.
I don't know how dispose is implemented in external component. but I won't rely on their implementation but just be good citizen and unsubscribe events handler I subscribed.
if it was our component that we can control implementation, then, might be different story. but not for external one.
There was a problem hiding this comment.
This is an editor's component, but please be a good citizen still :)
I wonder if you need to unsubscribe before scheduling a task though, what if the .editorconfig file has changed in between lines 52 and 57 and OnCodingConventionsChangedAsync gets called?
| defaultValue: EmptyCodingConventionContext.Instance); | ||
| } | ||
|
|
||
| private Task OnCodingConventionsChangedAsync(object sender, CodingConventionsChangedEventArgs arg) |
There was a problem hiding this comment.
❓ @olegtk Is this event ever invoked more often than one invocation for one change of .editorconfig on disk?
There was a problem hiding this comment.
if you are asking whether changing 1 editconfig file that affects multiple files will cause multiple events to be fired. then I tested it, and they do fire events for each file that got affected by the edit config file.
There was a problem hiding this comment.
there should be 1 event per file change (as raised by the VS file watcher service), and it's fired on each affected context instance.
olegtk
left a comment
There was a problem hiding this comment.
looks good from coding conventions side
| { | ||
| var context = t.Result; | ||
|
|
||
| context.CodingConventionsChangedAsync -= OnCodingConventionsChangedAsync; |
There was a problem hiding this comment.
This is an editor's component, but please be a good citizen still :)
I wonder if you need to unsubscribe before scheduling a task though, what if the .editorconfig file has changed in between lines 52 and 57 and OnCodingConventionsChangedAsync gets called?
| defaultValue: EmptyCodingConventionContext.Instance); | ||
| } | ||
|
|
||
| private Task OnCodingConventionsChangedAsync(object sender, CodingConventionsChangedEventArgs arg) |
There was a problem hiding this comment.
there should be 1 event per file change (as raised by the VS file watcher service), and it's fired on each affected context instance.
|
alright. thank you every one. addressed some PR feedbacks. tagging @jinujoseph first, this PR only update snapshot if open file is affected by editor config file change. closed file, it is not easy to do. that will be automatically supported once we have full editor config support from compiler. second, I did event aggregation. this is good for perf but now we have chance that if users use options within 50ms since last editconfig change events, they will not see the option changes. |
|
opened tracking issue |
|
@dotnet/roslyn-infrastructure do I need to keep rerun integration test until it pass or is it okay if one of test (release) passed? |
|
retest windows_debug_vs-integration_prtest please |
… it only… (dotnet#26221)" This reverts commit f56d67a. We are seeing deadlocks where our code tries to fetch the options for a file, and that code runs on the background thread. The background thread is trying to hop back to the foreground thread to apply file watchers for .editorconfig files.
… it only… (dotnet#26221)" This reverts commit f56d67a. We are seeing deadlocks where our code tries to fetch the options for a file, and that code runs on the background thread. The background thread is trying to hop back to the foreground thread to apply file watchers for .editorconfig files.
… updates when editorconfig is saved.
Customer scenario
User updates editorconfig and save the file but the change doesn't get picked up by other files opened in VS until files are closed and reopened.
Bugs this fixes
#15003
Workarounds, if any
modify the file or close and reopen the file.
Risk
Low.
Performance impact
Low
Is this a regression from a previous update?
No
Root cause analysis
We consider options as a part of snapshot. but we didn't update snapshots when editorconfig options are changed. for now, we support it for opened files, but for full experience, it require editorconfig work from compiler.
How was the bug found?
Dogfooding, Feedbacks