Closed scabana closed 2 weeks ago
Environments
[*.cs] max_line_length = 160
Steps to reproduce
.vs/$(SolutionName)/v17/csharpier.json
"RunOnSave": true
ctrl-s
Expected behavior
The c# file should be formatted.
Actual behavior
The file based configuration has not been loaded from disk when the file changed.
Experiment
Updated CSharpierOptions.cs's LoadAsync to contain for following code:
CSharpierOptions.cs
LoadAsync
var filePath = await getFilePath(); static FileSystemWatcher Create(string filePath) { FileSystemWatcher fsw = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath)); static void OnSomethingChanged(object sender, FileSystemEventArgs e) { ThreadHelper.Generic.BeginInvoke(() => Instance.Load()); } fsw.Changed += OnSomethingChanged; fsw.Created += OnSomethingChanged; fsw.Renamed += OnSomethingChanged; fsw.EnableRaisingEvents = true; return fsw; } _fileSystemWatcher = _fileSystemWatcher ?? Create(filePath); if (filePath == null || !File.Exists(filePath)) { return; }
And now the config gets reloaded when the file changed.
We are using some automation to enable CSharpier automatically when someone is using VS, the dev experience would be better if it didn't need a VS restart to be picked up.
I can open a PR with the updated code.
This is a great suggestion, if you can open the PR I can get out an updated version of the extension. Thanks!
.assign
Environments
Steps to reproduce
.vs/$(SolutionName)/v17/csharpier.json
containing"RunOnSave": true
ctrl-s
on a c# file in the previously opened VSExpected behavior
The c# file should be formatted.
Actual behavior
The file based configuration has not been loaded from disk when the file changed.
Experiment
Updated
CSharpierOptions.cs
'sLoadAsync
to contain for following code:And now the config gets reloaded when the file changed.
We are using some automation to enable CSharpier automatically when someone is using VS, the dev experience would be better if it didn't need a VS restart to be picked up.
I can open a PR with the updated code.