Skip to content

Update Roslyn snapshot when editorconfig is updated. for now, it only…#26221

Merged
heejaechang merged 3 commits intodotnet:dev15.7.xfrom
heejaechang:editorconfig
Apr 19, 2018
Merged

Update Roslyn snapshot when editorconfig is updated. for now, it only…#26221
heejaechang merged 3 commits intodotnet:dev15.7.xfrom
heejaechang:editorconfig

Conversation

@heejaechang
Copy link
Copy Markdown
Contributor

@heejaechang heejaechang commented Apr 18, 2018

… 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

@heejaechang heejaechang requested a review from a team as a code owner April 18, 2018 01:23
@heejaechang heejaechang changed the base branch from master to dev15.7.x April 18, 2018 01:23
@heejaechang
Copy link
Copy Markdown
Contributor Author

@jasonmalinowski is this approach look okay for now?

@jasonmalinowski
Copy link
Copy Markdown
Member

@heejaechang Will look in detail tomorrow, but gist seems OK.

@jasonmalinowski
Copy link
Copy Markdown
Member

(wrong button)

internal Solution WithOptionChanged()
{
// just create new snapshot
return new Solution(_state);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@heejaechang heejaechang Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonmalinowski What i meant was: we need to document that on the call. :)

@jinujoseph
Copy link
Copy Markdown
Contributor

approved to merge via link for 15.7.Preview5

@jinujoseph
Copy link
Copy Markdown
Contributor

one more review pending

Copy link
Copy Markdown
Contributor

@sharwell sharwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions to answer 😄

{
var context = t.Result;

context.CodingConventionsChangedAsync -= OnCodingConventionsChangedAsync;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Does this matter if we are disposing of the object anyway?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olegtk Is this event ever invoked more often than one invocation for one change of .editorconfig on disk?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

@olegtk olegtk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good from coding conventions side

{
var context = t.Result;

context.CodingConventionsChangedAsync -= OnCodingConventionsChangedAsync;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@heejaechang
Copy link
Copy Markdown
Contributor Author

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.

@heejaechang
Copy link
Copy Markdown
Contributor Author

opened tracking issue
#26250

@sharwell sharwell dismissed their stale review April 19, 2018 01:31

Questions were answered

@heejaechang
Copy link
Copy Markdown
Contributor Author

@dotnet/roslyn-infrastructure do I need to keep rerun integration test until it pass or is it okay if one of test (release) passed?

@heejaechang
Copy link
Copy Markdown
Contributor Author

retest windows_debug_vs-integration_prtest please

@heejaechang heejaechang merged commit f56d67a into dotnet:dev15.7.x Apr 19, 2018
@jcouv jcouv added the Area-IDE label Apr 19, 2018
jasonmalinowski added a commit to jasonmalinowski/roslyn that referenced this pull request Apr 25, 2018
… 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.
jasonmalinowski added a commit to jasonmalinowski/roslyn that referenced this pull request May 8, 2018
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants